focalboard/server/app/user.go
Paul Esch-Laurent 15e13fcdac
fix: filter out bots for sharing, @mention-ing, and Person property (#3762)
* fix: filter out bots for sharing and @mention-ing

* feat: add `?exclude_bots` to `getTeamUsers` API

* chore: `make swagger`

* chore: `make generate`

* fix: plugin store test function implementation

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-09-09 19:56:44 -06:00

62 lines
1.7 KiB
Go

package app
import (
"github.com/mattermost/focalboard/server/model"
mmModel "github.com/mattermost/mattermost-server/v6/model"
)
func (a *App) GetTeamUsers(teamID string, asGuestID string) ([]*model.User, error) {
return a.store.GetUsersByTeam(teamID, asGuestID)
}
func (a *App) SearchTeamUsers(teamID string, searchQuery string, asGuestID string, excludeBots bool) ([]*model.User, error) {
return a.store.SearchUsersByTeam(teamID, searchQuery, asGuestID, excludeBots)
}
func (a *App) UpdateUserConfig(userID string, patch model.UserPropPatch) ([]mmModel.Preference, error) {
if err := a.store.PatchUserProps(userID, patch); err != nil {
return nil, err
}
updatedPreferences, err := a.store.GetUserPreferences(userID)
if err != nil {
return nil, err
}
return updatedPreferences, nil
}
func (a *App) GetUserPreferences(userID string) ([]mmModel.Preference, error) {
return a.store.GetUserPreferences(userID)
}
func (a *App) UserIsGuest(userID string) (bool, error) {
user, err := a.store.GetUserByID(userID)
if err != nil {
return false, err
}
return user.IsGuest, nil
}
func (a *App) CanSeeUser(seerUser string, seenUser string) (bool, error) {
isGuest, err := a.UserIsGuest(seerUser)
if err != nil {
return false, err
}
if isGuest {
hasSharedChannels, err := a.store.CanSeeUser(seerUser, seenUser)
if err != nil {
return false, err
}
return hasSharedChannels, nil
}
return true, nil
}
func (a *App) SearchUserChannels(teamID string, userID string, query string) ([]*mmModel.Channel, error) {
return a.store.SearchUserChannels(teamID, userID, query)
}
func (a *App) GetChannel(teamID string, channelID string) (*mmModel.Channel, error) {
return a.store.GetChannel(teamID, channelID)
}