[MM-28985] Remove pointers to slice (part 1) (#18034)
* Remove pointers to slice (part 1) * Remove use of pointers to slice from model package (#18045) * Fix after merge
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
132f114793
Коммит
04b27ce93c
@@ -281,7 +281,7 @@ type AppIface interface {
|
||||
// SaveConfig replaces the active configuration, optionally notifying cluster peers.
|
||||
SaveConfig(newCfg *model.Config, sendConfigChangeClusterMessage bool) (*model.Config, *model.Config, *model.AppError)
|
||||
// SearchAllChannels returns a list of channels, the total count of the results of the search (if the paginate search option is true), and an error.
|
||||
SearchAllChannels(term string, opts model.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, *model.AppError)
|
||||
SearchAllChannels(term string, opts model.ChannelSearchOpts) (model.ChannelListWithTeamData, int64, *model.AppError)
|
||||
// SearchAllTeams returns a team list and the total count of the results
|
||||
SearchAllTeams(searchOpts *model.TeamSearch) ([]*model.Team, int64, *model.AppError)
|
||||
// SendAdminUpgradeRequestEmail takes the username of user trying to alert admins and then applies rate limit of n (number of admins) emails per user per day
|
||||
@@ -410,8 +410,8 @@ type AppIface interface {
|
||||
AttachSessionCookies(c *request.Context, w http.ResponseWriter, r *http.Request)
|
||||
AuthenticateUserForLogin(c *request.Context, id, loginId, password, mfaToken, cwsToken string, ldapOnly bool) (user *model.User, err *model.AppError)
|
||||
AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service, code, state, redirectURI string) (io.ReadCloser, string, map[string]string, *model.User, *model.AppError)
|
||||
AutocompleteChannels(teamID string, term string) (*model.ChannelList, *model.AppError)
|
||||
AutocompleteChannelsForSearch(teamID string, userID string, term string) (*model.ChannelList, *model.AppError)
|
||||
AutocompleteChannels(teamID string, term string) (model.ChannelList, *model.AppError)
|
||||
AutocompleteChannelsForSearch(teamID string, userID string, term string) (model.ChannelList, *model.AppError)
|
||||
AutocompleteUsersInChannel(teamID string, channelID string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, *model.AppError)
|
||||
AutocompleteUsersInTeam(teamID string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInTeam, *model.AppError)
|
||||
BroadcastStatus(status *model.Status)
|
||||
@@ -543,14 +543,14 @@ type AppIface interface {
|
||||
FileModTime(path string) (time.Time, *model.AppError)
|
||||
FileSize(path string) (int64, *model.AppError)
|
||||
FillInChannelProps(channel *model.Channel) *model.AppError
|
||||
FillInChannelsProps(channelList *model.ChannelList) *model.AppError
|
||||
FillInChannelsProps(channelList model.ChannelList) *model.AppError
|
||||
FilterUsersByVisible(viewer *model.User, otherUsers []*model.User) ([]*model.User, *model.AppError)
|
||||
FindTeamByName(name string) bool
|
||||
GenerateMfaSecret(userID string) (*model.MfaSecret, *model.AppError)
|
||||
GeneratePublicLink(siteURL string, info *model.FileInfo) string
|
||||
GenerateSupportPacket() []model.FileData
|
||||
GetActivePluginManifests() ([]*model.Manifest, *model.AppError)
|
||||
GetAllChannels(page, perPage int, opts model.ChannelSearchOpts) (*model.ChannelListWithTeamData, *model.AppError)
|
||||
GetAllChannels(page, perPage int, opts model.ChannelSearchOpts) (model.ChannelListWithTeamData, *model.AppError)
|
||||
GetAllChannelsCount(opts model.ChannelSearchOpts) (int64, *model.AppError)
|
||||
GetAllPrivateTeams() ([]*model.Team, *model.AppError)
|
||||
GetAllPublicTeams() ([]*model.Team, *model.AppError)
|
||||
@@ -573,10 +573,10 @@ type AppIface interface {
|
||||
GetChannelGuestCount(channelID string) (int64, *model.AppError)
|
||||
GetChannelMember(ctx context.Context, channelID string, userID string) (*model.ChannelMember, *model.AppError)
|
||||
GetChannelMemberCount(channelID string) (int64, *model.AppError)
|
||||
GetChannelMembersByIds(channelID string, userIDs []string) (*model.ChannelMembers, *model.AppError)
|
||||
GetChannelMembersForUser(teamID string, userID string) (*model.ChannelMembers, *model.AppError)
|
||||
GetChannelMembersByIds(channelID string, userIDs []string) (model.ChannelMembers, *model.AppError)
|
||||
GetChannelMembersForUser(teamID string, userID string) (model.ChannelMembers, *model.AppError)
|
||||
GetChannelMembersForUserWithPagination(teamID, userID string, page, perPage int) ([]*model.ChannelMember, *model.AppError)
|
||||
GetChannelMembersPage(channelID string, page, perPage int) (*model.ChannelMembers, *model.AppError)
|
||||
GetChannelMembersPage(channelID string, page, perPage int) (model.ChannelMembers, *model.AppError)
|
||||
GetChannelMembersTimezones(channelID string) ([]string, *model.AppError)
|
||||
GetChannelPinnedPostCount(channelID string) (int64, *model.AppError)
|
||||
GetChannelPoliciesForUser(userID string, offset, limit int) (*model.RetentionPolicyForChannelList, *model.AppError)
|
||||
@@ -585,8 +585,8 @@ type AppIface interface {
|
||||
GetChannelsForRetentionPolicy(policyID string, offset, limit int) (*model.ChannelsWithCount, *model.AppError)
|
||||
GetChannelsForScheme(scheme *model.Scheme, offset int, limit int) (model.ChannelList, *model.AppError)
|
||||
GetChannelsForSchemePage(scheme *model.Scheme, page int, perPage int) (model.ChannelList, *model.AppError)
|
||||
GetChannelsForUser(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, *model.AppError)
|
||||
GetChannelsUserNotIn(teamID string, userID string, offset int, limit int) (*model.ChannelList, *model.AppError)
|
||||
GetChannelsForUser(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (model.ChannelList, *model.AppError)
|
||||
GetChannelsUserNotIn(teamID string, userID string, offset int, limit int) (model.ChannelList, *model.AppError)
|
||||
GetCloudSession(token string) (*model.Session, *model.AppError)
|
||||
GetClusterId() string
|
||||
GetClusterStatus() []*model.ClusterInfo
|
||||
@@ -597,7 +597,7 @@ type AppIface interface {
|
||||
GetComplianceReports(page, perPage int) (model.Compliances, *model.AppError)
|
||||
GetCookieDomain() string
|
||||
GetDefaultProfileImage(user *model.User) ([]byte, *model.AppError)
|
||||
GetDeletedChannels(teamID string, offset int, limit int, userID string) (*model.ChannelList, *model.AppError)
|
||||
GetDeletedChannels(teamID string, offset int, limit int, userID string) (model.ChannelList, *model.AppError)
|
||||
GetEmoji(emojiId string) (*model.Emoji, *model.AppError)
|
||||
GetEmojiByName(emojiName string) (*model.Emoji, *model.AppError)
|
||||
GetEmojiImage(emojiId string) ([]byte, string, *model.AppError)
|
||||
@@ -690,10 +690,10 @@ type AppIface interface {
|
||||
GetPreferenceByCategoryForUser(userID string, category string) (model.Preferences, *model.AppError)
|
||||
GetPreferencesForUser(userID string) (model.Preferences, *model.AppError)
|
||||
GetPrevPostIdFromPostList(postList *model.PostList, collapsedThreads bool) string
|
||||
GetPrivateChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, *model.AppError)
|
||||
GetPrivateChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, *model.AppError)
|
||||
GetProfileImage(user *model.User) ([]byte, bool, *model.AppError)
|
||||
GetPublicChannelsByIdsForTeam(teamID string, channelIDs []string) (*model.ChannelList, *model.AppError)
|
||||
GetPublicChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, *model.AppError)
|
||||
GetPublicChannelsByIdsForTeam(teamID string, channelIDs []string) (model.ChannelList, *model.AppError)
|
||||
GetPublicChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, *model.AppError)
|
||||
GetReactionsForPost(postID string) ([]*model.Reaction, *model.AppError)
|
||||
GetRecentlyActiveUsersForTeam(teamID string) (map[string]*model.User, *model.AppError)
|
||||
GetRecentlyActiveUsersForTeamPage(teamID string, page, perPage int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
|
||||
@@ -947,14 +947,14 @@ type AppIface interface {
|
||||
SaveSharedChannelRemote(remote *model.SharedChannelRemote) (*model.SharedChannelRemote, error)
|
||||
SaveUserTermsOfService(userID, termsOfServiceId string, accepted bool) *model.AppError
|
||||
SchemesIterator(scope string, batchSize int) func() []*model.Scheme
|
||||
SearchArchivedChannels(teamID string, term string, userID string) (*model.ChannelList, *model.AppError)
|
||||
SearchChannels(teamID string, term string) (*model.ChannelList, *model.AppError)
|
||||
SearchChannelsForUser(userID, teamID, term string) (*model.ChannelList, *model.AppError)
|
||||
SearchChannelsUserNotIn(teamID string, userID string, term string) (*model.ChannelList, *model.AppError)
|
||||
SearchArchivedChannels(teamID string, term string, userID string) (model.ChannelList, *model.AppError)
|
||||
SearchChannels(teamID string, term string) (model.ChannelList, *model.AppError)
|
||||
SearchChannelsForUser(userID, teamID, term string) (model.ChannelList, *model.AppError)
|
||||
SearchChannelsUserNotIn(teamID string, userID string, term string) (model.ChannelList, *model.AppError)
|
||||
SearchEmoji(name string, prefixOnly bool, limit int) ([]*model.Emoji, *model.AppError)
|
||||
SearchEngine() *searchengine.Broker
|
||||
SearchFilesInTeamForUser(c *request.Context, terms string, userId string, teamId string, isOrSearch bool, includeDeletedChannels bool, timeZoneOffset int, page, perPage int) (*model.FileInfoList, *model.AppError)
|
||||
SearchGroupChannels(userID, term string) (*model.ChannelList, *model.AppError)
|
||||
SearchGroupChannels(userID, term string) (model.ChannelList, *model.AppError)
|
||||
SearchPostsInTeam(teamID string, paramsList []*model.SearchParams) (*model.PostList, *model.AppError)
|
||||
SearchPostsInTeamForUser(c *request.Context, terms string, userID string, teamID string, isOrSearch bool, includeDeletedChannels bool, timeZoneOffset int, page, perPage int) (*model.PostSearchResults, *model.AppError)
|
||||
SearchPrivateTeams(searchOpts *model.TeamSearch) ([]*model.Team, *model.AppError)
|
||||
|
||||
@@ -1573,7 +1573,7 @@ func (a *App) AddDirectChannels(teamID string, user *model.User) *model.AppError
|
||||
}
|
||||
}
|
||||
|
||||
if err := a.Srv().Store.Preference().Save(&preferences); err != nil {
|
||||
if err := a.Srv().Store.Preference().Save(preferences); err != nil {
|
||||
return model.NewAppError("AddDirectChannels", "api.user.add_direct_channels_and_forget.failed.error", map[string]interface{}{"UserId": user.Id, "TeamId": teamID, "Error": err.Error()}, "", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
@@ -1755,7 +1755,7 @@ func (a *App) GetChannelByNameForTeamName(channelName, teamName string, includeD
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (a *App) GetChannelsForUser(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, *model.AppError) {
|
||||
func (a *App) GetChannelsForUser(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (model.ChannelList, *model.AppError) {
|
||||
list, err := a.Srv().Store.Channel().GetChannels(teamID, userID, includeDeleted, lastDeleteAt)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
@@ -1770,7 +1770,7 @@ func (a *App) GetChannelsForUser(teamID string, userID string, includeDeleted bo
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (a *App) GetAllChannels(page, perPage int, opts model.ChannelSearchOpts) (*model.ChannelListWithTeamData, *model.AppError) {
|
||||
func (a *App) GetAllChannels(page, perPage int, opts model.ChannelSearchOpts) (model.ChannelListWithTeamData, *model.AppError) {
|
||||
if opts.ExcludeDefaultChannels {
|
||||
opts.ExcludeChannelNames = a.DefaultChannelNames()
|
||||
}
|
||||
@@ -1806,7 +1806,7 @@ func (a *App) GetAllChannelsCount(opts model.ChannelSearchOpts) (int64, *model.A
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func (a *App) GetDeletedChannels(teamID string, offset int, limit int, userID string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *App) GetDeletedChannels(teamID string, offset int, limit int, userID string) (model.ChannelList, *model.AppError) {
|
||||
list, err := a.Srv().Store.Channel().GetDeleted(teamID, offset, limit, userID)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
@@ -1821,7 +1821,7 @@ func (a *App) GetDeletedChannels(teamID string, offset int, limit int, userID st
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (a *App) GetChannelsUserNotIn(teamID string, userID string, offset int, limit int) (*model.ChannelList, *model.AppError) {
|
||||
func (a *App) GetChannelsUserNotIn(teamID string, userID string, offset int, limit int) (model.ChannelList, *model.AppError) {
|
||||
channels, err := a.Srv().Store.Channel().GetMoreChannels(teamID, userID, offset, limit)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetChannelsUserNotIn", "app.channel.get_more_channels.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
@@ -1829,7 +1829,7 @@ func (a *App) GetChannelsUserNotIn(teamID string, userID string, offset int, lim
|
||||
return channels, nil
|
||||
}
|
||||
|
||||
func (a *App) GetPublicChannelsByIdsForTeam(teamID string, channelIDs []string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *App) GetPublicChannelsByIdsForTeam(teamID string, channelIDs []string) (model.ChannelList, *model.AppError) {
|
||||
list, err := a.Srv().Store.Channel().GetPublicChannelsByIdsForTeam(teamID, channelIDs)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
@@ -1844,7 +1844,7 @@ func (a *App) GetPublicChannelsByIdsForTeam(teamID string, channelIDs []string)
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (a *App) GetPublicChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, *model.AppError) {
|
||||
func (a *App) GetPublicChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, *model.AppError) {
|
||||
list, err := a.Srv().Store.Channel().GetPublicChannelsForTeam(teamID, offset, limit)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetPublicChannelsForTeam", "app.channel.get_public_channels.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
@@ -1853,7 +1853,7 @@ func (a *App) GetPublicChannelsForTeam(teamID string, offset int, limit int) (*m
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (a *App) GetPrivateChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, *model.AppError) {
|
||||
func (a *App) GetPrivateChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, *model.AppError) {
|
||||
list, err := a.Srv().Store.Channel().GetPrivateChannelsForTeam(teamID, offset, limit)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetPrivateChannelsForTeam", "app.channel.get_private_channels.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
@@ -1877,7 +1877,7 @@ func (a *App) GetChannelMember(ctx context.Context, channelID string, userID str
|
||||
return channelMember, nil
|
||||
}
|
||||
|
||||
func (a *App) GetChannelMembersPage(channelID string, page, perPage int) (*model.ChannelMembers, *model.AppError) {
|
||||
func (a *App) GetChannelMembersPage(channelID string, page, perPage int) (model.ChannelMembers, *model.AppError) {
|
||||
channelMembers, err := a.Srv().Store.Channel().GetMembers(channelID, page*perPage, perPage)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetChannelMembersPage", "app.channel.get_members.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
@@ -1903,7 +1903,7 @@ func (a *App) GetChannelMembersTimezones(channelID string) ([]string, *model.App
|
||||
return model.RemoveDuplicateStrings(timezones), nil
|
||||
}
|
||||
|
||||
func (a *App) GetChannelMembersByIds(channelID string, userIDs []string) (*model.ChannelMembers, *model.AppError) {
|
||||
func (a *App) GetChannelMembersByIds(channelID string, userIDs []string) (model.ChannelMembers, *model.AppError) {
|
||||
members, err := a.Srv().Store.Channel().GetMembersByIds(channelID, userIDs)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetChannelMembersByIds", "app.channel.get_members_by_ids.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
@@ -1912,7 +1912,7 @@ func (a *App) GetChannelMembersByIds(channelID string, userIDs []string) (*model
|
||||
return members, nil
|
||||
}
|
||||
|
||||
func (a *App) GetChannelMembersForUser(teamID string, userID string) (*model.ChannelMembers, *model.AppError) {
|
||||
func (a *App) GetChannelMembersForUser(teamID string, userID string) (model.ChannelMembers, *model.AppError) {
|
||||
channelMembers, err := a.Srv().Store.Channel().GetMembersForUser(teamID, userID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetChannelMembersForUser", "app.channel.get_members.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
@@ -1928,11 +1928,9 @@ func (a *App) GetChannelMembersForUserWithPagination(teamID, userID string, page
|
||||
}
|
||||
|
||||
members := make([]*model.ChannelMember, 0)
|
||||
if m != nil {
|
||||
for _, member := range *m {
|
||||
member := member
|
||||
members = append(members, &member)
|
||||
}
|
||||
for _, member := range m {
|
||||
member := member
|
||||
members = append(members, &member)
|
||||
}
|
||||
return members, nil
|
||||
}
|
||||
@@ -2322,7 +2320,7 @@ func (a *App) removeUserFromChannel(c *request.Context, userIDToRemove string, r
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(*currentMembers) == 0 {
|
||||
if len(currentMembers) == 0 {
|
||||
teamMember, err := a.GetTeamMember(channel.TeamId, userIDToRemove)
|
||||
if err != nil {
|
||||
return model.NewAppError("removeUserFromChannel", "api.team.remove_user_from_team.missing.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
@@ -2405,7 +2403,7 @@ func (a *App) GetNumberOfChannelsOnTeam(teamID string) (int, *model.AppError) {
|
||||
return 0, model.NewAppError("GetNumberOfChannelsOnTeam", "app.channel.get_channels.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
return len(*list), nil
|
||||
return len(list), nil
|
||||
}
|
||||
|
||||
func (a *App) SetActiveChannel(userID string, channelID string) *model.AppError {
|
||||
@@ -2678,7 +2676,7 @@ func (a *App) sendWebSocketPostUnreadEvent(channelUnread *model.ChannelUnreadAt,
|
||||
a.Publish(message)
|
||||
}
|
||||
|
||||
func (a *App) AutocompleteChannels(teamID string, term string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *App) AutocompleteChannels(teamID string, term string) (model.ChannelList, *model.AppError) {
|
||||
includeDeleted := *a.Config().TeamSettings.ExperimentalViewArchivedChannels
|
||||
term = strings.TrimSpace(term)
|
||||
|
||||
@@ -2690,7 +2688,7 @@ func (a *App) AutocompleteChannels(teamID string, term string) (*model.ChannelLi
|
||||
return channelList, nil
|
||||
}
|
||||
|
||||
func (a *App) AutocompleteChannelsForSearch(teamID string, userID string, term string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *App) AutocompleteChannelsForSearch(teamID string, userID string, term string) (model.ChannelList, *model.AppError) {
|
||||
includeDeleted := *a.Config().TeamSettings.ExperimentalViewArchivedChannels
|
||||
|
||||
term = strings.TrimSpace(term)
|
||||
@@ -2704,7 +2702,7 @@ func (a *App) AutocompleteChannelsForSearch(teamID string, userID string, term s
|
||||
}
|
||||
|
||||
// SearchAllChannels returns a list of channels, the total count of the results of the search (if the paginate search option is true), and an error.
|
||||
func (a *App) SearchAllChannels(term string, opts model.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, *model.AppError) {
|
||||
func (a *App) SearchAllChannels(term string, opts model.ChannelSearchOpts) (model.ChannelListWithTeamData, int64, *model.AppError) {
|
||||
if opts.ExcludeDefaultChannels {
|
||||
opts.ExcludeChannelNames = a.DefaultChannelNames()
|
||||
}
|
||||
@@ -2735,7 +2733,7 @@ func (a *App) SearchAllChannels(term string, opts model.ChannelSearchOpts) (*mod
|
||||
return channelList, totalCount, nil
|
||||
}
|
||||
|
||||
func (a *App) SearchChannels(teamID string, term string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *App) SearchChannels(teamID string, term string) (model.ChannelList, *model.AppError) {
|
||||
includeDeleted := *a.Config().TeamSettings.ExperimentalViewArchivedChannels
|
||||
|
||||
term = strings.TrimSpace(term)
|
||||
@@ -2748,7 +2746,7 @@ func (a *App) SearchChannels(teamID string, term string) (*model.ChannelList, *m
|
||||
return channelList, nil
|
||||
}
|
||||
|
||||
func (a *App) SearchArchivedChannels(teamID string, term string, userID string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *App) SearchArchivedChannels(teamID string, term string, userID string) (model.ChannelList, *model.AppError) {
|
||||
term = strings.TrimSpace(term)
|
||||
|
||||
channelList, err := a.Srv().Store.Channel().SearchArchivedInTeam(teamID, term, userID)
|
||||
@@ -2759,7 +2757,7 @@ func (a *App) SearchArchivedChannels(teamID string, term string, userID string)
|
||||
return channelList, nil
|
||||
}
|
||||
|
||||
func (a *App) SearchChannelsForUser(userID, teamID, term string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *App) SearchChannelsForUser(userID, teamID, term string) (model.ChannelList, *model.AppError) {
|
||||
includeDeleted := *a.Config().TeamSettings.ExperimentalViewArchivedChannels
|
||||
|
||||
term = strings.TrimSpace(term)
|
||||
@@ -2772,9 +2770,9 @@ func (a *App) SearchChannelsForUser(userID, teamID, term string) (*model.Channel
|
||||
return channelList, nil
|
||||
}
|
||||
|
||||
func (a *App) SearchGroupChannels(userID, term string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *App) SearchGroupChannels(userID, term string) (model.ChannelList, *model.AppError) {
|
||||
if term == "" {
|
||||
return &model.ChannelList{}, nil
|
||||
return model.ChannelList{}, nil
|
||||
}
|
||||
|
||||
channelList, err := a.Srv().Store.Channel().SearchGroupChannels(userID, term)
|
||||
@@ -2784,7 +2782,7 @@ func (a *App) SearchGroupChannels(userID, term string) (*model.ChannelList, *mod
|
||||
return channelList, nil
|
||||
}
|
||||
|
||||
func (a *App) SearchChannelsUserNotIn(teamID string, userID string, term string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *App) SearchChannelsUserNotIn(teamID string, userID string, term string) (model.ChannelList, *model.AppError) {
|
||||
term = strings.TrimSpace(term)
|
||||
channelList, err := a.Srv().Store.Channel().SearchMore(userID, teamID, term)
|
||||
if err != nil {
|
||||
@@ -2948,7 +2946,7 @@ func (a *App) MoveChannel(c *request.Context, team *model.Team, channel *model.C
|
||||
}
|
||||
|
||||
channelMemberIds := []string{}
|
||||
for _, channelMember := range *channelMembers {
|
||||
for _, channelMember := range channelMembers {
|
||||
channelMemberIds = append(channelMemberIds, channelMember.UserId)
|
||||
}
|
||||
|
||||
@@ -2958,12 +2956,12 @@ func (a *App) MoveChannel(c *request.Context, team *model.Team, channel *model.C
|
||||
return err2
|
||||
}
|
||||
|
||||
if len(teamMembers) != len(*channelMembers) {
|
||||
if len(teamMembers) != len(channelMembers) {
|
||||
teamMembersMap := make(map[string]*model.TeamMember, len(teamMembers))
|
||||
for _, teamMember := range teamMembers {
|
||||
teamMembersMap[teamMember.UserId] = teamMember
|
||||
}
|
||||
for _, channelMember := range *channelMembers {
|
||||
for _, channelMember := range channelMembers {
|
||||
if _, ok := teamMembersMap[channelMember.UserId]; !ok {
|
||||
mlog.Warn("Not member of the target team", mlog.String("userId", channelMember.UserId))
|
||||
}
|
||||
@@ -3068,7 +3066,7 @@ func (a *App) RemoveUsersFromChannelNotMemberOfTeam(c *request.Context, remover
|
||||
|
||||
channelMemberIds := []string{}
|
||||
channelMemberMap := make(map[string]struct{})
|
||||
for _, channelMember := range *channelMembers {
|
||||
for _, channelMember := range channelMembers {
|
||||
channelMemberMap[channelMember.UserId] = struct{}{}
|
||||
channelMemberIds = append(channelMemberIds, channelMember.UserId)
|
||||
}
|
||||
@@ -3079,7 +3077,7 @@ func (a *App) RemoveUsersFromChannelNotMemberOfTeam(c *request.Context, remover
|
||||
return err
|
||||
}
|
||||
|
||||
if len(teamMembers) != len(*channelMembers) {
|
||||
if len(teamMembers) != len(channelMembers) {
|
||||
for _, teamMember := range teamMembers {
|
||||
delete(channelMemberMap, teamMember.UserId)
|
||||
}
|
||||
@@ -3148,7 +3146,7 @@ func (a *App) setChannelsMuted(channelIDs []string, userID string, muted bool) (
|
||||
}
|
||||
|
||||
var membersToUpdate []*model.ChannelMember
|
||||
for _, member := range *members {
|
||||
for _, member := range members {
|
||||
if muted == member.IsChannelMuted() {
|
||||
continue
|
||||
}
|
||||
@@ -3189,13 +3187,13 @@ func (a *App) setChannelsMuted(channelIDs []string, userID string, muted bool) (
|
||||
}
|
||||
|
||||
func (a *App) FillInChannelProps(channel *model.Channel) *model.AppError {
|
||||
return a.FillInChannelsProps(&model.ChannelList{channel})
|
||||
return a.FillInChannelsProps(model.ChannelList{channel})
|
||||
}
|
||||
|
||||
func (a *App) FillInChannelsProps(channelList *model.ChannelList) *model.AppError {
|
||||
func (a *App) FillInChannelsProps(channelList model.ChannelList) *model.AppError {
|
||||
// Group the channels by team and call GetChannelsByNames just once per team.
|
||||
channelsByTeam := make(map[string]model.ChannelList)
|
||||
for _, channel := range *channelList {
|
||||
for _, channel := range channelList {
|
||||
channelsByTeam[channel.TeamId] = append(channelsByTeam[channel.TeamId], channel)
|
||||
}
|
||||
|
||||
@@ -3262,13 +3260,13 @@ func (a *App) forEachChannelMember(channelID string, f func(model.ChannelMember)
|
||||
return err
|
||||
}
|
||||
|
||||
for _, channelMember := range *channelMembers {
|
||||
for _, channelMember := range channelMembers {
|
||||
if err = f(channelMember); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
length := len(*(channelMembers))
|
||||
length := len(channelMembers)
|
||||
if length < perPage {
|
||||
break
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ func TestRemoveAllDeactivatedMembersFromChannel(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
channelMembers, err := th.App.GetChannelMembersPage(channel.Id, 0, 10000000)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, *channelMembers, 2)
|
||||
require.Len(t, channelMembers, 2)
|
||||
_, err = th.App.UpdateActive(th.Context, deacivatedUser, false)
|
||||
require.Nil(t, err)
|
||||
|
||||
@@ -103,7 +103,7 @@ func TestRemoveAllDeactivatedMembersFromChannel(t *testing.T) {
|
||||
|
||||
channelMembers, err = th.App.GetChannelMembersPage(channel.Id, 0, 10000000)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, *channelMembers, 1)
|
||||
require.Len(t, channelMembers, 1)
|
||||
}
|
||||
|
||||
func TestMoveChannel(t *testing.T) {
|
||||
@@ -254,9 +254,9 @@ func TestRemoveUsersFromChannelNotMemberOfTeam(t *testing.T) {
|
||||
|
||||
channelMembers, err := th.App.GetChannelMembersPage(channel1.Id, 0, 10000000)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, *channelMembers, 1)
|
||||
members := make([]model.ChannelMember, len(*channelMembers))
|
||||
for i, m := range *channelMembers {
|
||||
require.Len(t, channelMembers, 1)
|
||||
members := make([]model.ChannelMember, len(channelMembers))
|
||||
for i, m := range channelMembers {
|
||||
members[i] = m
|
||||
}
|
||||
require.Equal(t, members[0].UserId, th.BasicUser.Id)
|
||||
@@ -771,12 +771,12 @@ func TestFillInChannelProps(t *testing.T) {
|
||||
t.Run("multiple channels", func(t *testing.T) {
|
||||
testCases := []struct {
|
||||
Description string
|
||||
Channels *model.ChannelList
|
||||
Channels model.ChannelList
|
||||
ExpectedChannelProps map[string]interface{}
|
||||
}{
|
||||
{
|
||||
"single channel on basic team",
|
||||
&model.ChannelList{
|
||||
model.ChannelList{
|
||||
{
|
||||
Name: "test",
|
||||
TeamId: th.BasicTeam.Id,
|
||||
@@ -796,7 +796,7 @@ func TestFillInChannelProps(t *testing.T) {
|
||||
},
|
||||
{
|
||||
"multiple channels on basic team",
|
||||
&model.ChannelList{
|
||||
model.ChannelList{
|
||||
{
|
||||
Name: "test",
|
||||
TeamId: th.BasicTeam.Id,
|
||||
@@ -830,7 +830,7 @@ func TestFillInChannelProps(t *testing.T) {
|
||||
},
|
||||
{
|
||||
"multiple channels across teams",
|
||||
&model.ChannelList{
|
||||
model.ChannelList{
|
||||
{
|
||||
Name: "test",
|
||||
TeamId: th.BasicTeam.Id,
|
||||
@@ -875,7 +875,7 @@ func TestFillInChannelProps(t *testing.T) {
|
||||
err = th.App.FillInChannelsProps(testCase.Channels)
|
||||
require.Nil(t, err)
|
||||
|
||||
for _, channel := range *testCase.Channels {
|
||||
for _, channel := range testCase.Channels {
|
||||
assert.Equal(t, testCase.ExpectedChannelProps[channel.Name], channel.Props)
|
||||
}
|
||||
})
|
||||
@@ -998,19 +998,19 @@ func TestGetChannelsForUser(t *testing.T) {
|
||||
|
||||
channelList, err := th.App.GetChannelsForUser(th.BasicTeam.Id, th.BasicUser.Id, false, 0)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, *channelList, 4)
|
||||
require.Len(t, channelList, 4)
|
||||
|
||||
th.App.DeleteChannel(th.Context, channel, th.BasicUser.Id)
|
||||
|
||||
// Now we get all the non-archived channels for the user
|
||||
channelList, err = th.App.GetChannelsForUser(th.BasicTeam.Id, th.BasicUser.Id, false, 0)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, *channelList, 3)
|
||||
require.Len(t, channelList, 3)
|
||||
|
||||
// Now we get all the channels, even though are archived, for the user
|
||||
channelList, err = th.App.GetChannelsForUser(th.BasicTeam.Id, th.BasicUser.Id, true, 0)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, *channelList, 4)
|
||||
require.Len(t, channelList, 4)
|
||||
}
|
||||
|
||||
func TestGetPublicChannelsForTeam(t *testing.T) {
|
||||
@@ -1053,7 +1053,7 @@ func TestGetPublicChannelsForTeam(t *testing.T) {
|
||||
channelList2, err := th.App.GetPublicChannelsForTeam(team.Id, 5, 5)
|
||||
require.Nil(t, err)
|
||||
|
||||
channels := append(*channelList, *channelList2...)
|
||||
channels := append(channelList, channelList2...)
|
||||
assert.ElementsMatch(t, expectedChannels, channels)
|
||||
}
|
||||
|
||||
@@ -1086,7 +1086,7 @@ func TestGetPrivateChannelsForTeam(t *testing.T) {
|
||||
channelList2, err := th.App.GetPrivateChannelsForTeam(team.Id, 5, 5)
|
||||
require.Nil(t, err)
|
||||
|
||||
channels := append(*channelList, *channelList2...)
|
||||
channels := append(channelList, channelList2...)
|
||||
assert.ElementsMatch(t, expectedChannels, channels)
|
||||
}
|
||||
|
||||
@@ -1213,10 +1213,10 @@ func TestSearchChannelsForUser(t *testing.T) {
|
||||
searchAndCheck := func(t *testing.T, term string, expectedDisplayNames []string) {
|
||||
res, searchErr := th.App.SearchChannelsForUser(th.BasicUser.Id, th.BasicTeam.Id, term)
|
||||
require.Nil(t, searchErr)
|
||||
require.Len(t, *res, len(expectedDisplayNames))
|
||||
require.Len(t, res, len(expectedDisplayNames))
|
||||
|
||||
resultDisplayNames := []string{}
|
||||
for _, c := range *res {
|
||||
for _, c := range res {
|
||||
resultDisplayNames = append(resultDisplayNames, c.Name)
|
||||
}
|
||||
require.ElementsMatch(t, expectedDisplayNames, resultDisplayNames)
|
||||
@@ -2004,8 +2004,8 @@ func TestClearChannelMembersCache(t *testing.T) {
|
||||
ChannelId: "1",
|
||||
})
|
||||
}
|
||||
mockChannelStore.On("GetMembers", "channelID", 0, 100).Return(&cms, nil)
|
||||
mockChannelStore.On("GetMembers", "channelID", 100, 100).Return(&model.ChannelMembers{
|
||||
mockChannelStore.On("GetMembers", "channelID", 0, 100).Return(cms, nil)
|
||||
mockChannelStore.On("GetMembers", "channelID", 100, 100).Return(model.ChannelMembers{
|
||||
model.ChannelMember{
|
||||
ChannelId: "1",
|
||||
}}, nil)
|
||||
@@ -2061,7 +2061,7 @@ func TestViewChannelCollapsedThreadsTurnedOff(t *testing.T) {
|
||||
}
|
||||
var preferences model.Preferences
|
||||
preferences = append(preferences, preference)
|
||||
err := th.App.Srv().Store.Preference().Save(&preferences)
|
||||
err := th.App.Srv().Store.Preference().Save(preferences)
|
||||
require.NoError(t, err)
|
||||
|
||||
// mention the user in a root post
|
||||
@@ -2137,7 +2137,7 @@ func TestMarkChannelAsUnreadFromPostCollapsedThreadsTurnedOff(t *testing.T) {
|
||||
}
|
||||
var preferences model.Preferences
|
||||
preferences = append(preferences, preference)
|
||||
err := th.App.Srv().Store.Preference().Save(&preferences)
|
||||
err := th.App.Srv().Store.Preference().Save(preferences)
|
||||
require.NoError(t, err)
|
||||
|
||||
// user2: first root mention @user1
|
||||
|
||||
@@ -170,7 +170,7 @@ func (job *EmailBatchingJob) checkPendingNotifications(now time.Time, handler fu
|
||||
continue
|
||||
}
|
||||
|
||||
for _, channelMember := range *channelMembers {
|
||||
for _, channelMember := range channelMembers {
|
||||
if channelMember.LastViewedAt >= batchStartTime {
|
||||
mlog.Debug("Deleted notifications for user", mlog.String("user_id", userID))
|
||||
delete(job.pendingNotifications, userID)
|
||||
|
||||
@@ -96,7 +96,7 @@ func TestCheckPendingNotifications(t *testing.T) {
|
||||
_, err = th.store.Channel().UpdateMember(channelMember)
|
||||
require.NoError(t, err)
|
||||
|
||||
nErr := th.store.Preference().Save(&model.Preferences{{
|
||||
nErr := th.store.Preference().Save(model.Preferences{{
|
||||
UserId: th.BasicUser.Id,
|
||||
Category: model.PreferenceCategoryNotifications,
|
||||
Name: model.PreferenceNameEmailInterval,
|
||||
@@ -118,7 +118,7 @@ func TestCheckPendingNotifications(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// We reset the interval to something shorter
|
||||
nErr = th.store.Preference().Save(&model.Preferences{{
|
||||
nErr = th.store.Preference().Save(model.Preferences{{
|
||||
UserId: th.BasicUser.Id,
|
||||
Category: model.PreferenceCategoryNotifications,
|
||||
Name: model.PreferenceNameEmailInterval,
|
||||
@@ -254,7 +254,7 @@ func TestCheckPendingNotificationsCantParseInterval(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// preference value is not an integer, so we'll fall back to the default 15min value
|
||||
nErr := th.store.Preference().Save(&model.Preferences{{
|
||||
nErr := th.store.Preference().Save(model.Preferences{{
|
||||
UserId: th.BasicUser.Id,
|
||||
Category: model.PreferenceCategoryNotifications,
|
||||
Name: model.PreferenceNameEmailInterval,
|
||||
|
||||
@@ -93,7 +93,7 @@ func TestExportUserChannels(t *testing.T) {
|
||||
}
|
||||
var preferences model.Preferences
|
||||
preferences = append(preferences, preference)
|
||||
err := th.App.Srv().Store.Preference().Save(&preferences)
|
||||
err := th.App.Srv().Store.Preference().Save(preferences)
|
||||
require.NoError(t, err)
|
||||
|
||||
th.App.UpdateChannelMemberNotifyProps(notifyProps, channel.Id, user.Id)
|
||||
|
||||
@@ -510,7 +510,7 @@ func (a *App) importUser(data *UserImportData, dryRun bool) *model.AppError {
|
||||
}
|
||||
|
||||
pref := model.Preference{UserId: savedUser.Id, Category: model.PreferenceCategoryTutorialSteps, Name: savedUser.Id, Value: "0"}
|
||||
if err := a.Srv().Store.Preference().Save(&model.Preferences{pref}); err != nil {
|
||||
if err := a.Srv().Store.Preference().Save(model.Preferences{pref}); err != nil {
|
||||
mlog.Warn("Encountered error saving tutorial preference", mlog.Err(err))
|
||||
}
|
||||
|
||||
@@ -686,7 +686,7 @@ func (a *App) importUser(data *UserImportData, dryRun bool) *model.AppError {
|
||||
}
|
||||
|
||||
if len(preferences) > 0 {
|
||||
if err := a.Srv().Store.Preference().Save(&preferences); err != nil {
|
||||
if err := a.Srv().Store.Preference().Save(preferences); err != nil {
|
||||
return model.NewAppError("BulkImport", "app.import.import_user.save_preferences.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
@@ -840,7 +840,7 @@ func (a *App) importUserTeams(user *model.User, data *[]UserTeamImportData) *mod
|
||||
for _, team := range allTeams {
|
||||
if len(teamThemePreferencesByID[team.Id]) > 0 {
|
||||
pref := teamThemePreferencesByID[team.Id]
|
||||
if err := a.Srv().Store.Preference().Save(&pref); err != nil {
|
||||
if err := a.Srv().Store.Preference().Save(pref); err != nil {
|
||||
return model.NewAppError("BulkImport", "app.import.import_user_teams.save_preferences.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
@@ -881,7 +881,7 @@ func (a *App) importUserChannels(user *model.User, team *model.Team, data *[]Use
|
||||
return model.NewAppError("importUserChannels", "app.channel.get_members.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
existingMembershipsByChannelId := map[string]model.ChannelMember{}
|
||||
for _, channelMembership := range *existingMemberships {
|
||||
for _, channelMembership := range existingMemberships {
|
||||
existingMembershipsByChannelId[channelMembership.ChannelId] = channelMembership
|
||||
}
|
||||
for _, cdata := range *data {
|
||||
@@ -1014,7 +1014,7 @@ func (a *App) importUserChannels(user *model.User, team *model.Team, data *[]Use
|
||||
for _, channel := range allChannels {
|
||||
if len(channelPreferencesByID[channel.Id]) > 0 {
|
||||
pref := channelPreferencesByID[channel.Id]
|
||||
if err := a.Srv().Store.Preference().Save(&pref); err != nil {
|
||||
if err := a.Srv().Store.Preference().Save(pref); err != nil {
|
||||
return model.NewAppError("BulkImport", "app.import.import_user_channels.save_preferences.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
@@ -1455,7 +1455,7 @@ func (a *App) importMultiplePostLines(c *request.Context, lines []LineImportWork
|
||||
}
|
||||
|
||||
if len(preferences) > 0 {
|
||||
if err := a.Srv().Store.Preference().Save(&preferences); err != nil {
|
||||
if err := a.Srv().Store.Preference().Save(preferences); err != nil {
|
||||
return postWithData.lineNumber, model.NewAppError("BulkImport", "app.import.import_post.save_preferences.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
@@ -1563,7 +1563,7 @@ func (a *App) importDirectChannel(data *DirectChannelImportData, dryRun bool) *m
|
||||
}
|
||||
}
|
||||
|
||||
if err := a.Srv().Store.Preference().Save(&preferences); err != nil {
|
||||
if err := a.Srv().Store.Preference().Save(preferences); err != nil {
|
||||
var appErr *model.AppError
|
||||
switch {
|
||||
case errors.As(err, &appErr):
|
||||
@@ -1749,7 +1749,7 @@ func (a *App) importMultipleDirectPostLines(c *request.Context, lines []LineImpo
|
||||
}
|
||||
|
||||
if len(preferences) > 0 {
|
||||
if err := a.Srv().Store.Preference().Save(&preferences); err != nil {
|
||||
if err := a.Srv().Store.Preference().Save(preferences); err != nil {
|
||||
return postWithData.lineNumber, model.NewAppError("BulkImport", "app.import.import_post.save_preferences.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1733,7 +1733,7 @@ func TestImportUserTeams(t *testing.T) {
|
||||
for _, teamMember := range teamMembers {
|
||||
channelMembers, err := th.App.Srv().Store.Channel().GetMembersForUser(teamMember.TeamId, user.Id)
|
||||
require.NoError(t, err)
|
||||
totalMembers += len(*channelMembers)
|
||||
totalMembers += len(channelMembers)
|
||||
}
|
||||
require.Equal(t, tc.expectedUserChannels, totalMembers)
|
||||
}
|
||||
@@ -1871,9 +1871,9 @@ func TestImportUserChannels(t *testing.T) {
|
||||
}
|
||||
channelMembers, err := th.App.Srv().Store.Channel().GetMembersForUser(th.BasicTeam.Id, user.Id)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, *channelMembers, tc.expectedUserChannels)
|
||||
require.Len(t, channelMembers, tc.expectedUserChannels)
|
||||
if tc.expectedUserChannels == 1 {
|
||||
channelMember := (*channelMembers)[0]
|
||||
channelMember := channelMembers[0]
|
||||
require.Equal(t, tc.expectedExplicitRoles, channelMember.ExplicitRoles, "Not matching expected explicit roles")
|
||||
require.Equal(t, tc.expectedRoles, channelMember.Roles, "not matching expected roles")
|
||||
if tc.expectedNotifyProps != nil {
|
||||
|
||||
@@ -221,7 +221,7 @@ func (a *App) AllowOAuthAppAccessToUser(userID string, authRequest *model.Author
|
||||
Value: authRequest.Scope,
|
||||
}
|
||||
|
||||
if nErr := a.Srv().Store.Preference().Save(&model.Preferences{authorizedApp}); nErr != nil {
|
||||
if nErr := a.Srv().Store.Preference().Save(model.Preferences{authorizedApp}); nErr != nil {
|
||||
mlog.Warn("error saving store preference", mlog.Err(nErr))
|
||||
return authRequest.RedirectURI + "?error=server_error&state=" + authRequest.State, nil
|
||||
}
|
||||
|
||||
@@ -768,7 +768,7 @@ func (a *OpenTracingAppLayer) AuthorizeOAuthUser(w http.ResponseWriter, r *http.
|
||||
return resultVar0, resultVar1, resultVar2, resultVar3, resultVar4
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) AutocompleteChannels(teamID string, term string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) AutocompleteChannels(teamID string, term string) (model.ChannelList, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.AutocompleteChannels")
|
||||
|
||||
@@ -790,7 +790,7 @@ func (a *OpenTracingAppLayer) AutocompleteChannels(teamID string, term string) (
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) AutocompleteChannelsForSearch(teamID string, userID string, term string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) AutocompleteChannelsForSearch(teamID string, userID string, term string) (model.ChannelList, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.AutocompleteChannelsForSearch")
|
||||
|
||||
@@ -4085,7 +4085,7 @@ func (a *OpenTracingAppLayer) FillInChannelProps(channel *model.Channel) *model.
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) FillInChannelsProps(channelList *model.ChannelList) *model.AppError {
|
||||
func (a *OpenTracingAppLayer) FillInChannelsProps(channelList model.ChannelList) *model.AppError {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.FillInChannelsProps")
|
||||
|
||||
@@ -4290,7 +4290,7 @@ func (a *OpenTracingAppLayer) GetActivePluginManifests() ([]*model.Manifest, *mo
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetAllChannels(page int, perPage int, opts model.ChannelSearchOpts) (*model.ChannelListWithTeamData, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetAllChannels(page int, perPage int, opts model.ChannelSearchOpts) (model.ChannelListWithTeamData, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetAllChannels")
|
||||
|
||||
@@ -4879,7 +4879,7 @@ func (a *OpenTracingAppLayer) GetChannelMemberCount(channelID string) (int64, *m
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetChannelMembersByIds(channelID string, userIDs []string) (*model.ChannelMembers, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetChannelMembersByIds(channelID string, userIDs []string) (model.ChannelMembers, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetChannelMembersByIds")
|
||||
|
||||
@@ -4901,7 +4901,7 @@ func (a *OpenTracingAppLayer) GetChannelMembersByIds(channelID string, userIDs [
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetChannelMembersForUser(teamID string, userID string) (*model.ChannelMembers, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetChannelMembersForUser(teamID string, userID string) (model.ChannelMembers, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetChannelMembersForUser")
|
||||
|
||||
@@ -4945,7 +4945,7 @@ func (a *OpenTracingAppLayer) GetChannelMembersForUserWithPagination(teamID stri
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetChannelMembersPage(channelID string, page int, perPage int) (*model.ChannelMembers, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetChannelMembersPage(channelID string, page int, perPage int) (model.ChannelMembers, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetChannelMembersPage")
|
||||
|
||||
@@ -5165,7 +5165,7 @@ func (a *OpenTracingAppLayer) GetChannelsForSchemePage(scheme *model.Scheme, pag
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetChannelsForUser(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetChannelsForUser(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (model.ChannelList, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetChannelsForUser")
|
||||
|
||||
@@ -5187,7 +5187,7 @@ func (a *OpenTracingAppLayer) GetChannelsForUser(teamID string, userID string, i
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetChannelsUserNotIn(teamID string, userID string, offset int, limit int) (*model.ChannelList, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetChannelsUserNotIn(teamID string, userID string, offset int, limit int) (model.ChannelList, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetChannelsUserNotIn")
|
||||
|
||||
@@ -5458,7 +5458,7 @@ func (a *OpenTracingAppLayer) GetDefaultProfileImage(user *model.User) ([]byte,
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetDeletedChannels(teamID string, offset int, limit int, userID string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetDeletedChannels(teamID string, offset int, limit int, userID string) (model.ChannelList, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetDeletedChannels")
|
||||
|
||||
@@ -7701,7 +7701,7 @@ func (a *OpenTracingAppLayer) GetPrevPostIdFromPostList(postList *model.PostList
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetPrivateChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetPrivateChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetPrivateChannelsForTeam")
|
||||
|
||||
@@ -7767,7 +7767,7 @@ func (a *OpenTracingAppLayer) GetProfileImage(user *model.User) ([]byte, bool, *
|
||||
return resultVar0, resultVar1, resultVar2
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetPublicChannelsByIdsForTeam(teamID string, channelIDs []string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetPublicChannelsByIdsForTeam(teamID string, channelIDs []string) (model.ChannelList, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetPublicChannelsByIdsForTeam")
|
||||
|
||||
@@ -7789,7 +7789,7 @@ func (a *OpenTracingAppLayer) GetPublicChannelsByIdsForTeam(teamID string, chann
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetPublicChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetPublicChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetPublicChannelsForTeam")
|
||||
|
||||
@@ -13684,7 +13684,7 @@ func (a *OpenTracingAppLayer) SchemesIterator(scope string, batchSize int) func(
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) SearchAllChannels(term string, opts model.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) SearchAllChannels(term string, opts model.ChannelSearchOpts) (model.ChannelListWithTeamData, int64, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SearchAllChannels")
|
||||
|
||||
@@ -13728,7 +13728,7 @@ func (a *OpenTracingAppLayer) SearchAllTeams(searchOpts *model.TeamSearch) ([]*m
|
||||
return resultVar0, resultVar1, resultVar2
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) SearchArchivedChannels(teamID string, term string, userID string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) SearchArchivedChannels(teamID string, term string, userID string) (model.ChannelList, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SearchArchivedChannels")
|
||||
|
||||
@@ -13750,7 +13750,7 @@ func (a *OpenTracingAppLayer) SearchArchivedChannels(teamID string, term string,
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) SearchChannels(teamID string, term string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) SearchChannels(teamID string, term string) (model.ChannelList, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SearchChannels")
|
||||
|
||||
@@ -13772,7 +13772,7 @@ func (a *OpenTracingAppLayer) SearchChannels(teamID string, term string) (*model
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) SearchChannelsForUser(userID string, teamID string, term string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) SearchChannelsForUser(userID string, teamID string, term string) (model.ChannelList, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SearchChannelsForUser")
|
||||
|
||||
@@ -13794,7 +13794,7 @@ func (a *OpenTracingAppLayer) SearchChannelsForUser(userID string, teamID string
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) SearchChannelsUserNotIn(teamID string, userID string, term string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) SearchChannelsUserNotIn(teamID string, userID string, term string) (model.ChannelList, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SearchChannelsUserNotIn")
|
||||
|
||||
@@ -13877,7 +13877,7 @@ func (a *OpenTracingAppLayer) SearchFilesInTeamForUser(c *request.Context, terms
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) SearchGroupChannels(userID string, term string) (*model.ChannelList, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) SearchGroupChannels(userID string, term string) (model.ChannelList, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SearchGroupChannels")
|
||||
|
||||
|
||||
@@ -397,7 +397,7 @@ func (api *PluginAPI) GetPublicChannelsForTeam(teamID string, page, perPage int)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return *channels, err
|
||||
return channels, err
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetChannel(channelID string) (*model.Channel, *model.AppError) {
|
||||
@@ -417,7 +417,7 @@ func (api *PluginAPI) GetChannelsForTeamForUser(teamID, userID string, includeDe
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return *channels, err
|
||||
return channels, err
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetChannelStats(channelID string) (*model.ChannelStats, *model.AppError) {
|
||||
@@ -449,7 +449,7 @@ func (api *PluginAPI) SearchChannels(teamID string, term string) ([]*model.Chann
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return *channels, err
|
||||
return channels, err
|
||||
}
|
||||
|
||||
func (api *PluginAPI) CreateChannelSidebarCategory(userID, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError) {
|
||||
@@ -543,11 +543,11 @@ func (api *PluginAPI) GetChannelMember(channelID, userID string) (*model.Channel
|
||||
return api.app.GetChannelMember(context.Background(), channelID, userID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetChannelMembers(channelID string, page, perPage int) (*model.ChannelMembers, *model.AppError) {
|
||||
func (api *PluginAPI) GetChannelMembers(channelID string, page, perPage int) (model.ChannelMembers, *model.AppError) {
|
||||
return api.app.GetChannelMembersPage(channelID, page, perPage)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetChannelMembersByIds(channelID string, userIDs []string) (*model.ChannelMembers, *model.AppError) {
|
||||
func (api *PluginAPI) GetChannelMembersByIds(channelID string, userIDs []string) (model.ChannelMembers, *model.AppError) {
|
||||
return api.app.GetChannelMembersByIds(channelID, userIDs)
|
||||
}
|
||||
|
||||
|
||||
@@ -735,7 +735,7 @@ func (a *App) publishWebsocketEventForPermalinkPost(post *model.Post, message *m
|
||||
return false, err
|
||||
}
|
||||
|
||||
for _, cm := range *channelMembers {
|
||||
for _, cm := range channelMembers {
|
||||
postForUser := post.Clone()
|
||||
if !a.HasPermissionToReadChannel(cm.UserId, previewedChannel) {
|
||||
postForUser.Metadata.Embeds[0].Data = nil
|
||||
|
||||
@@ -46,7 +46,7 @@ func (a *App) UpdatePreferences(userID string, preferences model.Preferences) *m
|
||||
}
|
||||
}
|
||||
|
||||
if err := a.Srv().Store.Preference().Save(&preferences); err != nil {
|
||||
if err := a.Srv().Store.Preference().Save(preferences); err != nil {
|
||||
var appErr *model.AppError
|
||||
switch {
|
||||
case errors.As(err, &appErr):
|
||||
@@ -56,7 +56,7 @@ func (a *App) UpdatePreferences(userID string, preferences model.Preferences) *m
|
||||
}
|
||||
}
|
||||
|
||||
if err := a.Srv().Store.Channel().UpdateSidebarChannelsByPreferences(&preferences); err != nil {
|
||||
if err := a.Srv().Store.Channel().UpdateSidebarChannelsByPreferences(preferences); err != nil {
|
||||
return model.NewAppError("UpdatePreferences", "api.preference.update_preferences.update_sidebar.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ func (a *App) DeletePreferences(userID string, preferences model.Preferences) *m
|
||||
}
|
||||
}
|
||||
|
||||
if err := a.Srv().Store.Channel().DeleteSidebarChannelsByPreferences(&preferences); err != nil {
|
||||
if err := a.Srv().Store.Channel().DeleteSidebarChannelsByPreferences(preferences); err != nil {
|
||||
return model.NewAppError("DeletePreferences", "api.preference.delete_preferences.update_sidebar.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
|
||||
@@ -377,7 +377,7 @@ func (a *App) UpdateProductNotices() *model.AppError {
|
||||
return model.NewAppError("UpdateProductNotices", "api.system.update_notices.parse_failed", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if err := a.Srv().Store.ProductNotices().ClearOldNotices(&cachedNotices); err != nil {
|
||||
if err := a.Srv().Store.ProductNotices().ClearOldNotices(cachedNotices); err != nil {
|
||||
return model.NewAppError("UpdateProductNotices", "api.system.update_notices.clear_failed", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -70,7 +70,7 @@ func setCollapsePreference(a *app.App, args *model.CommandArgs, isCollapse bool)
|
||||
Value: strconv.FormatBool(isCollapse),
|
||||
}
|
||||
|
||||
if err := a.Srv().Store.Preference().Save(&model.Preferences{pref}); err != nil {
|
||||
if err := a.Srv().Store.Preference().Save(model.Preferences{pref}); err != nil {
|
||||
return &model.CommandResponse{Text: args.T("api.command_expand_collapse.fail.app_error"), ResponseType: model.CommandResponseTypeEphemeral}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,10 +66,10 @@ func (*LeaveProvider) DoCommand(a *app.App, c *request.Context, args *model.Comm
|
||||
|
||||
if user.IsGuest() {
|
||||
members, err := a.GetChannelMembersForUser(team.Id, args.UserId)
|
||||
if err != nil || len(*members) == 0 {
|
||||
if err != nil || len(members) == 0 {
|
||||
return &model.CommandResponse{Text: args.T("api.command_leave.fail.app_error"), ResponseType: model.CommandResponseTypeEphemeral}
|
||||
}
|
||||
channel, err := a.GetChannel((*members)[0].ChannelId)
|
||||
channel, err := a.GetChannel(members[0].ChannelId)
|
||||
if err != nil {
|
||||
return &model.CommandResponse{Text: args.T("api.command_leave.fail.app_error"), ResponseType: model.CommandResponseTypeEphemeral}
|
||||
}
|
||||
|
||||
@@ -437,11 +437,11 @@ func (a *App) RemoveCustomStatus(userID string) *model.AppError {
|
||||
}
|
||||
|
||||
func (a *App) addRecentCustomStatus(userID string, status *model.CustomStatus) *model.AppError {
|
||||
var newRCS *model.RecentCustomStatuses
|
||||
var newRCS model.RecentCustomStatuses
|
||||
|
||||
pref, err := a.GetPreferenceByCategoryAndNameForUser(userID, model.PreferenceCategoryCustomStatus, model.PreferenceNameRecentCustomStatuses)
|
||||
if err != nil || pref.Value == "" {
|
||||
newRCS = &model.RecentCustomStatuses{*status}
|
||||
newRCS = model.RecentCustomStatuses{*status}
|
||||
} else {
|
||||
existingRCS := model.RecentCustomStatusesFromJson(strings.NewReader(pref.Value))
|
||||
newRCS = existingRCS.Add(status)
|
||||
|
||||
@@ -440,8 +440,8 @@ func TestDeleteGroupMemberships(t *testing.T) {
|
||||
|
||||
cmembers, err := th.App.GetChannelMembersPage(channel.Id, 0, 99)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, (*cmembers), 1)
|
||||
require.Equal(t, th.SystemAdminUser.Id, (*cmembers)[0].UserId)
|
||||
require.Len(t, cmembers, 1)
|
||||
require.Equal(t, th.SystemAdminUser.Id, cmembers[0].UserId)
|
||||
}
|
||||
|
||||
func TestSyncSyncableRoles(t *testing.T) {
|
||||
|
||||
@@ -1235,19 +1235,18 @@ func (a *App) LeaveTeam(c *request.Context, team *model.Team, user *model.User,
|
||||
return model.NewAppError("LeaveTeam", "api.team.remove_user_from_team.missing.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
|
||||
var channelList *model.ChannelList
|
||||
|
||||
var channelList model.ChannelList
|
||||
var nErr error
|
||||
if channelList, nErr = a.Srv().Store.Channel().GetChannels(team.Id, user.Id, true, 0); nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
if errors.As(nErr, &nfErr) {
|
||||
channelList = &model.ChannelList{}
|
||||
channelList = model.ChannelList{}
|
||||
} else {
|
||||
return model.NewAppError("LeaveTeam", "app.channel.get_channels.get.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
for _, channel := range *channelList {
|
||||
for _, channel := range channelList {
|
||||
if !channel.IsGroupOrDirect() {
|
||||
a.invalidateCacheForChannelMembers(channel.Id)
|
||||
if nErr = a.Srv().Store.Channel().RemoveMember(channel.Id, user.Id); nErr != nil {
|
||||
@@ -1739,7 +1738,7 @@ func (a *App) PermanentDeleteTeam(team *model.Team) *model.AppError {
|
||||
return model.NewAppError("PermanentDeleteTeam", "app.channel.get_channels.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
} else {
|
||||
for _, c := range *channels {
|
||||
for _, c := range channels {
|
||||
a.PermanentDeleteChannel(c)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ func TestAddUserToTeamByToken(t *testing.T) {
|
||||
|
||||
members, err := th.App.GetChannelMembersForUser(th.BasicTeam.Id, ruser.Id)
|
||||
require.Nil(t, err)
|
||||
assert.Len(t, *members, 2)
|
||||
assert.Len(t, members, 2)
|
||||
})
|
||||
|
||||
t.Run("invalid add a guest using a regular invite", func(t *testing.T) {
|
||||
@@ -364,8 +364,8 @@ func TestAddUserToTeamByToken(t *testing.T) {
|
||||
|
||||
members, err := th.App.GetChannelMembersForUser(th.BasicTeam.Id, rguest.Id)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, *members, 1)
|
||||
assert.Equal(t, (*members)[0].ChannelId, th.BasicChannel.Id)
|
||||
require.Len(t, members, 1)
|
||||
assert.Equal(t, members[0].ChannelId, th.BasicChannel.Id)
|
||||
})
|
||||
|
||||
t.Run("group-constrained team", func(t *testing.T) {
|
||||
@@ -504,7 +504,7 @@ func TestPermanentDeleteTeam(t *testing.T) {
|
||||
channels, err := th.App.GetPublicChannelsForTeam(team.Id, 0, 1000)
|
||||
require.Nil(t, err)
|
||||
|
||||
for _, channel := range *channels {
|
||||
for _, channel := range channels {
|
||||
err2 := th.App.PermanentDeleteChannel(channel)
|
||||
require.Nil(t, err2)
|
||||
}
|
||||
@@ -1001,8 +1001,8 @@ func TestGetTeamStats(t *testing.T) {
|
||||
require.NotNil(t, teamStats)
|
||||
members, err := th.App.GetChannelMembersPage(th.BasicChannel.Id, 0, 5)
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, int64(len(*members)), teamStats.TotalMemberCount)
|
||||
assert.Equal(t, int64(len(*members)), teamStats.ActiveMemberCount)
|
||||
assert.Equal(t, int64(len(members)), teamStats.TotalMemberCount)
|
||||
assert.Equal(t, int64(len(members)), teamStats.ActiveMemberCount)
|
||||
})
|
||||
|
||||
t.Run("with view restrictions to not see anything", func(t *testing.T) {
|
||||
|
||||
@@ -261,7 +261,7 @@ func (a *App) createUserOrGuest(c *request.Context, user *model.User, guest bool
|
||||
|
||||
recommendedNextStepsPref := model.Preference{UserId: ruser.Id, Category: model.PreferenceRecommendedNextSteps, Name: "hide", Value: "false"}
|
||||
tutorialStepPref := model.Preference{UserId: ruser.Id, Category: model.PreferenceCategoryTutorialSteps, Name: ruser.Id, Value: "0"}
|
||||
if err := a.Srv().Store.Preference().Save(&model.Preferences{recommendedNextStepsPref, tutorialStepPref}); err != nil {
|
||||
if err := a.Srv().Store.Preference().Save(model.Preferences{recommendedNextStepsPref, tutorialStepPref}); err != nil {
|
||||
mlog.Warn("Encountered error saving user preferences", mlog.Err(err))
|
||||
}
|
||||
|
||||
@@ -868,7 +868,7 @@ func (a *App) invalidateUserChannelMembersCaches(userID string) *model.AppError
|
||||
return err
|
||||
}
|
||||
|
||||
for _, channel := range *channelsForUser {
|
||||
for _, channel := range channelsForUser {
|
||||
a.invalidateCacheForChannelMembers(channel.Id)
|
||||
}
|
||||
}
|
||||
@@ -2056,7 +2056,7 @@ func (a *App) PromoteGuestToUser(c *request.Context, user *model.User, requestor
|
||||
mlog.Warn("Failed to get channel members for user on promote guest to user", mlog.Err(err))
|
||||
}
|
||||
|
||||
for _, member := range *channelMembers {
|
||||
for _, member := range channelMembers {
|
||||
a.invalidateCacheForChannelMembers(member.ChannelId)
|
||||
|
||||
evt := model.NewWebSocketEvent(model.WebsocketEventChannelMemberUpdated, "", "", user.Id, nil)
|
||||
@@ -2097,7 +2097,7 @@ func (a *App) DemoteUserToGuest(user *model.User) *model.AppError {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, member := range *channelMembers {
|
||||
for _, member := range channelMembers {
|
||||
a.invalidateCacheForChannelMembers(member.ChannelId)
|
||||
|
||||
evt := model.NewWebSocketEvent(model.WebsocketEventChannelMemberUpdated, "", "", user.Id, nil)
|
||||
|
||||
@@ -782,7 +782,7 @@ func TestCreateUserWithToken(t *testing.T) {
|
||||
|
||||
members, err := th.App.GetChannelMembersForUser(th.BasicTeam.Id, newUser.Id)
|
||||
require.Nil(t, err)
|
||||
assert.Len(t, *members, 2)
|
||||
assert.Len(t, members, 2)
|
||||
})
|
||||
|
||||
t.Run("valid guest request", func(t *testing.T) {
|
||||
@@ -803,8 +803,8 @@ func TestCreateUserWithToken(t *testing.T) {
|
||||
|
||||
members, err := th.App.GetChannelMembersForUser(th.BasicTeam.Id, newGuest.Id)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, *members, 1)
|
||||
assert.Equal(t, (*members)[0].ChannelId, th.BasicChannel.Id)
|
||||
require.Len(t, members, 1)
|
||||
assert.Equal(t, members[0].ChannelId, th.BasicChannel.Id)
|
||||
})
|
||||
|
||||
t.Run("create guest having email domain restrictions", func(t *testing.T) {
|
||||
@@ -848,8 +848,8 @@ func TestCreateUserWithToken(t *testing.T) {
|
||||
|
||||
members, err := th.App.GetChannelMembersForUser(th.BasicTeam.Id, newGuest.Id)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, *members, 1)
|
||||
assert.Equal(t, (*members)[0].ChannelId, th.BasicChannel.Id)
|
||||
require.Len(t, members, 1)
|
||||
assert.Equal(t, members[0].ChannelId, th.BasicChannel.Id)
|
||||
})
|
||||
|
||||
t.Run("create guest having team and system email domain restrictions", func(t *testing.T) {
|
||||
@@ -885,8 +885,8 @@ func TestCreateUserWithToken(t *testing.T) {
|
||||
|
||||
members, err := th.App.GetChannelMembersForUser(th.BasicTeam.Id, newGuest.Id)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, *members, 1)
|
||||
assert.Equal(t, (*members)[0].ChannelId, th.BasicChannel.Id)
|
||||
require.Len(t, members, 1)
|
||||
assert.Equal(t, members[0].ChannelId, th.BasicChannel.Id)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1183,7 +1183,7 @@ func TestPromoteGuestToUser(t *testing.T) {
|
||||
|
||||
channelMembers, err := th.App.GetChannelMembersForUser(th.BasicTeam.Id, guest.Id)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, *channelMembers, 1)
|
||||
require.Len(t, channelMembers, 1)
|
||||
|
||||
err = th.App.PromoteGuestToUser(th.Context, guest, th.BasicUser.Id)
|
||||
require.Nil(t, err)
|
||||
@@ -1201,7 +1201,7 @@ func TestPromoteGuestToUser(t *testing.T) {
|
||||
|
||||
channelMembers, err = th.App.GetChannelMembersForUser(th.BasicTeam.Id, guest.Id)
|
||||
require.Nil(t, err)
|
||||
assert.Len(t, *channelMembers, 3)
|
||||
assert.Len(t, channelMembers, 3)
|
||||
})
|
||||
|
||||
t.Run("Must invalidate channel stats cache when promoting a guest", func(t *testing.T) {
|
||||
@@ -1346,7 +1346,7 @@ func TestDemoteUserToGuest(t *testing.T) {
|
||||
|
||||
channelMembers, err := th.App.GetChannelMembersForUser(th.BasicTeam.Id, user.Id)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, *channelMembers, 3)
|
||||
require.Len(t, channelMembers, 3)
|
||||
|
||||
err = th.App.DemoteUserToGuest(user)
|
||||
require.Nil(t, err)
|
||||
@@ -1364,7 +1364,7 @@ func TestDemoteUserToGuest(t *testing.T) {
|
||||
|
||||
channelMembers, err = th.App.GetChannelMembersForUser(th.BasicTeam.Id, user.Id)
|
||||
require.Nil(t, err)
|
||||
assert.Len(t, *channelMembers, 3)
|
||||
assert.Len(t, channelMembers, 3)
|
||||
})
|
||||
|
||||
t.Run("Must be removed as team and channel admin", func(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user