本文整理汇总了Golang中github.com/mattermost/platform/model.Client.SearchUsers方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.SearchUsers方法的具体用法?Golang Client.SearchUsers怎么用?Golang Client.SearchUsers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/mattermost/platform/model.Client
的用法示例。
在下文中一共展示了Client.SearchUsers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getDirectChannelIDByName
func (m *MatterMail) getDirectChannelIDByName(client *model.Client, channelList *model.ChannelList, userName string) string {
if m.user.Username == userName {
m.eror.Printf("Impossible create a Direct channel, Mattermail user (%v) equals destination user (%v)\n", m.user.Username, userName)
return ""
}
//result, err := client.GetProfilesForDirectMessageList(client.GetTeamId())
result, err := client.SearchUsers(model.UserSearch{
AllowInactive: false,
TeamId: client.GetTeamId(),
Term: userName,
})
if err != nil {
m.eror.Println("Error on SearchUsers: ", err.Error())
return ""
}
profiles := result.Data.([]*model.User)
var userID string
for _, p := range profiles {
if p.Username == userName {
userID = p.Id
break
}
}
if userID == "" {
m.debg.Println("Did not find the username:", userName)
return ""
}
dmName := model.GetDMNameFromIds(m.user.Id, userID)
dmID := getChannelIDByName(channelList, dmName)
if dmID != "" {
return dmID
}
m.debg.Println("Create direct channel to user:", userName)
result, err = client.CreateDirectChannel(userID)
if err != nil {
m.eror.Println("Error on CreateDirectChannel: ", err.Error())
return ""
}
directChannel := result.Data.(*model.Channel)
return directChannel.Id
}