github.com/haalcala/mattermost-server-change-repo/v5@v5.33.2/store/store.go (about)

     1  //go:generate go run layer_generators/main.go
     2  
     3  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
     4  // See LICENSE.txt for license information.
     5  
     6  package store
     7  
     8  import (
     9  	"context"
    10  	"time"
    11  
    12  	"github.com/mattermost/mattermost-server/v5/model"
    13  )
    14  
    15  type StoreResult struct {
    16  	Data interface{}
    17  
    18  	// NErr a temporary field used by the new code for the AppError migration. This will later become Err when the entire store is migrated.
    19  	NErr error
    20  }
    21  
    22  type Store interface {
    23  	Team() TeamStore
    24  	Channel() ChannelStore
    25  	Post() PostStore
    26  	Thread() ThreadStore
    27  	User() UserStore
    28  	Bot() BotStore
    29  	Audit() AuditStore
    30  	ClusterDiscovery() ClusterDiscoveryStore
    31  	Compliance() ComplianceStore
    32  	Session() SessionStore
    33  	OAuth() OAuthStore
    34  	System() SystemStore
    35  	Webhook() WebhookStore
    36  	Command() CommandStore
    37  	CommandWebhook() CommandWebhookStore
    38  	Preference() PreferenceStore
    39  	License() LicenseStore
    40  	Token() TokenStore
    41  	Emoji() EmojiStore
    42  	Status() StatusStore
    43  	FileInfo() FileInfoStore
    44  	UploadSession() UploadSessionStore
    45  	Reaction() ReactionStore
    46  	Role() RoleStore
    47  	Scheme() SchemeStore
    48  	Job() JobStore
    49  	UserAccessToken() UserAccessTokenStore
    50  	ChannelMemberHistory() ChannelMemberHistoryStore
    51  	Plugin() PluginStore
    52  	TermsOfService() TermsOfServiceStore
    53  	ProductNotices() ProductNoticesStore
    54  	Group() GroupStore
    55  	UserTermsOfService() UserTermsOfServiceStore
    56  	LinkMetadata() LinkMetadataStore
    57  	MarkSystemRanUnitTests()
    58  	Close()
    59  	LockToMaster()
    60  	UnlockFromMaster()
    61  	DropAllTables()
    62  	RecycleDBConnections(d time.Duration)
    63  	GetCurrentSchemaVersion() string
    64  	GetDbVersion(numerical bool) (string, error)
    65  	TotalMasterDbConnections() int
    66  	TotalReadDbConnections() int
    67  	TotalSearchDbConnections() int
    68  	CheckIntegrity() <-chan model.IntegrityCheckResult
    69  	SetContext(context context.Context)
    70  	Context() context.Context
    71  }
    72  
    73  type TeamStore interface {
    74  	Save(team *model.Team) (*model.Team, error)
    75  	Update(team *model.Team) (*model.Team, error)
    76  	Get(id string) (*model.Team, error)
    77  	GetByName(name string) (*model.Team, error)
    78  	GetByNames(name []string) ([]*model.Team, error)
    79  	SearchAll(term string, opts *model.TeamSearch) ([]*model.Team, error)
    80  	SearchAllPaged(term string, opts *model.TeamSearch) ([]*model.Team, int64, error)
    81  	SearchOpen(term string) ([]*model.Team, error)
    82  	SearchPrivate(term string) ([]*model.Team, error)
    83  	GetAll() ([]*model.Team, error)
    84  	GetAllPage(offset int, limit int) ([]*model.Team, error)
    85  	GetAllPrivateTeamListing() ([]*model.Team, error)
    86  	GetAllPrivateTeamPageListing(offset int, limit int) ([]*model.Team, error)
    87  	GetAllPublicTeamPageListing(offset int, limit int) ([]*model.Team, error)
    88  	GetAllTeamListing() ([]*model.Team, error)
    89  	GetAllTeamPageListing(offset int, limit int) ([]*model.Team, error)
    90  	GetTeamsByUserId(userId string) ([]*model.Team, error)
    91  	GetByInviteId(inviteId string) (*model.Team, error)
    92  	PermanentDelete(teamId string) error
    93  	AnalyticsTeamCount(includeDeleted bool) (int64, error)
    94  	AnalyticsPublicTeamCount() (int64, error)
    95  	AnalyticsPrivateTeamCount() (int64, error)
    96  	SaveMultipleMembers(members []*model.TeamMember, maxUsersPerTeam int) ([]*model.TeamMember, error)
    97  	SaveMember(member *model.TeamMember, maxUsersPerTeam int) (*model.TeamMember, error)
    98  	UpdateMember(member *model.TeamMember) (*model.TeamMember, error)
    99  	UpdateMultipleMembers(members []*model.TeamMember) ([]*model.TeamMember, error)
   100  	GetMember(teamId string, userId string) (*model.TeamMember, error)
   101  	GetMembers(teamId string, offset int, limit int, teamMembersGetOptions *model.TeamMembersGetOptions) ([]*model.TeamMember, error)
   102  	GetMembersByIds(teamId string, userIds []string, restrictions *model.ViewUsersRestrictions) ([]*model.TeamMember, error)
   103  	GetTotalMemberCount(teamId string, restrictions *model.ViewUsersRestrictions) (int64, error)
   104  	GetActiveMemberCount(teamId string, restrictions *model.ViewUsersRestrictions) (int64, error)
   105  	GetTeamsForUser(ctx context.Context, userId string) ([]*model.TeamMember, error)
   106  	GetTeamsForUserWithPagination(userId string, page, perPage int) ([]*model.TeamMember, error)
   107  	GetChannelUnreadsForAllTeams(excludeTeamId, userId string) ([]*model.ChannelUnread, error)
   108  	GetChannelUnreadsForTeam(teamId, userId string) ([]*model.ChannelUnread, error)
   109  	RemoveMember(teamId string, userId string) error
   110  	RemoveMembers(teamId string, userIds []string) error
   111  	RemoveAllMembersByTeam(teamId string) error
   112  	RemoveAllMembersByUser(userId string) error
   113  	UpdateLastTeamIconUpdate(teamId string, curTime int64) error
   114  	GetTeamsByScheme(schemeId string, offset int, limit int) ([]*model.Team, error)
   115  	MigrateTeamMembers(fromTeamId string, fromUserId string) (map[string]string, error)
   116  	ResetAllTeamSchemes() error
   117  	ClearAllCustomRoleAssignments() error
   118  	AnalyticsGetTeamCountForScheme(schemeId string) (int64, error)
   119  	GetAllForExportAfter(limit int, afterId string) ([]*model.TeamForExport, error)
   120  	GetTeamMembersForExport(userId string) ([]*model.TeamMemberForExport, error)
   121  	UserBelongsToTeams(userId string, teamIds []string) (bool, error)
   122  	GetUserTeamIds(userId string, allowFromCache bool) ([]string, error)
   123  	InvalidateAllTeamIdsForUser(userId string)
   124  	ClearCaches()
   125  
   126  	// UpdateMembersRole sets all of the given team members to admins and all of the other members of the team to
   127  	// non-admin members.
   128  	UpdateMembersRole(teamID string, userIDs []string) error
   129  
   130  	// GroupSyncedTeamCount returns the count of non-deleted group-constrained teams.
   131  	GroupSyncedTeamCount() (int64, error)
   132  }
   133  
   134  type ChannelStore interface {
   135  	Save(channel *model.Channel, maxChannelsPerTeam int64) (*model.Channel, error)
   136  	CreateDirectChannel(userId *model.User, otherUserId *model.User) (*model.Channel, error)
   137  	SaveDirectChannel(channel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) (*model.Channel, error)
   138  	Update(channel *model.Channel) (*model.Channel, error)
   139  	UpdateSidebarChannelCategoryOnMove(channel *model.Channel, newTeamId string) error
   140  	ClearSidebarOnTeamLeave(userId, teamId string) error
   141  	Get(id string, allowFromCache bool) (*model.Channel, error)
   142  	InvalidateChannel(id string)
   143  	InvalidateChannelByName(teamId, name string)
   144  	GetFromMaster(id string) (*model.Channel, error)
   145  	Delete(channelId string, time int64) error
   146  	Restore(channelId string, time int64) error
   147  	SetDeleteAt(channelId string, deleteAt int64, updateAt int64) error
   148  	PermanentDelete(channelId string) error
   149  	PermanentDeleteByTeam(teamId string) error
   150  	GetByName(team_id string, name string, allowFromCache bool) (*model.Channel, error)
   151  	GetByNames(team_id string, names []string, allowFromCache bool) ([]*model.Channel, error)
   152  	GetByNameIncludeDeleted(team_id string, name string, allowFromCache bool) (*model.Channel, error)
   153  	GetDeletedByName(team_id string, name string) (*model.Channel, error)
   154  	GetDeleted(team_id string, offset int, limit int, userId string) (*model.ChannelList, error)
   155  	GetChannels(teamId string, userId string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, error)
   156  	GetAllChannels(page, perPage int, opts ChannelSearchOpts) (*model.ChannelListWithTeamData, error)
   157  	GetAllChannelsCount(opts ChannelSearchOpts) (int64, error)
   158  	GetMoreChannels(teamId string, userId string, offset int, limit int) (*model.ChannelList, error)
   159  	GetPrivateChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, error)
   160  	GetPublicChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, error)
   161  	GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) (*model.ChannelList, error)
   162  	GetChannelCounts(teamId string, userId string) (*model.ChannelCounts, error)
   163  	GetTeamChannels(teamId string) (*model.ChannelList, error)
   164  	GetAll(teamId string) ([]*model.Channel, error)
   165  	GetChannelsByIds(channelIds []string, includeDeleted bool) ([]*model.Channel, error)
   166  	GetForPost(postId string) (*model.Channel, error)
   167  	SaveMultipleMembers(members []*model.ChannelMember) ([]*model.ChannelMember, error)
   168  	SaveMember(member *model.ChannelMember) (*model.ChannelMember, error)
   169  	UpdateMember(member *model.ChannelMember) (*model.ChannelMember, error)
   170  	UpdateMultipleMembers(members []*model.ChannelMember) ([]*model.ChannelMember, error)
   171  	GetMembers(channelId string, offset, limit int) (*model.ChannelMembers, error)
   172  	GetMember(channelId string, userId string) (*model.ChannelMember, error)
   173  	GetChannelMembersTimezones(channelId string) ([]model.StringMap, error)
   174  	GetAllChannelMembersForUser(userId string, allowFromCache bool, includeDeleted bool) (map[string]string, error)
   175  	InvalidateAllChannelMembersForUser(userId string)
   176  	IsUserInChannelUseCache(userId string, channelId string) bool
   177  	GetAllChannelMembersNotifyPropsForChannel(channelId string, allowFromCache bool) (map[string]model.StringMap, error)
   178  	InvalidateCacheForChannelMembersNotifyProps(channelId string)
   179  	GetMemberForPost(postId string, userId string) (*model.ChannelMember, error)
   180  	InvalidateMemberCount(channelId string)
   181  	GetMemberCountFromCache(channelId string) int64
   182  	GetMemberCount(channelId string, allowFromCache bool) (int64, error)
   183  	GetMemberCountsByGroup(channelID string, includeTimezones bool) ([]*model.ChannelMemberCountByGroup, error)
   184  	InvalidatePinnedPostCount(channelId string)
   185  	GetPinnedPostCount(channelId string, allowFromCache bool) (int64, error)
   186  	InvalidateGuestCount(channelId string)
   187  	GetGuestCount(channelId string, allowFromCache bool) (int64, error)
   188  	GetPinnedPosts(channelId string) (*model.PostList, error)
   189  	RemoveMember(channelId string, userId string) error
   190  	RemoveMembers(channelId string, userIds []string) error
   191  	PermanentDeleteMembersByUser(userId string) error
   192  	PermanentDeleteMembersByChannel(channelId string) error
   193  	UpdateLastViewedAt(channelIds []string, userId string, updateThreads bool) (map[string]int64, error)
   194  	UpdateLastViewedAtPost(unreadPost *model.Post, userID string, mentionCount int, updateThreads bool) (*model.ChannelUnreadAt, error)
   195  	CountPostsAfter(channelId string, timestamp int64, userId string) (int, error)
   196  	IncrementMentionCount(channelId string, userId string, updateThreads bool) error
   197  	AnalyticsTypeCount(teamId string, channelType string) (int64, error)
   198  	GetMembersForUser(teamId string, userId string) (*model.ChannelMembers, error)
   199  	GetMembersForUserWithPagination(teamId, userId string, page, perPage int) (*model.ChannelMembers, error)
   200  	AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, error)
   201  	AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) (*model.ChannelList, error)
   202  	SearchAllChannels(term string, opts ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, error)
   203  	SearchInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, error)
   204  	SearchArchivedInTeam(teamId string, term string, userId string) (*model.ChannelList, error)
   205  	SearchForUserInTeam(userId string, teamId string, term string, includeDeleted bool) (*model.ChannelList, error)
   206  	SearchMore(userId string, teamId string, term string) (*model.ChannelList, error)
   207  	SearchGroupChannels(userId, term string) (*model.ChannelList, error)
   208  	GetMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, error)
   209  	GetMembersByChannelIds(channelIds []string, userId string) (*model.ChannelMembers, error)
   210  	AnalyticsDeletedTypeCount(teamId string, channelType string) (int64, error)
   211  	GetChannelUnread(channelId, userId string) (*model.ChannelUnread, error)
   212  	ClearCaches()
   213  	GetChannelsByScheme(schemeId string, offset int, limit int) (model.ChannelList, error)
   214  	MigrateChannelMembers(fromChannelId string, fromUserId string) (map[string]string, error)
   215  	ResetAllChannelSchemes() error
   216  	ClearAllCustomRoleAssignments() error
   217  	MigratePublicChannels() error
   218  	CreateInitialSidebarCategories(userId, teamId string) error
   219  	GetSidebarCategories(userId, teamId string) (*model.OrderedSidebarCategories, error)
   220  	GetSidebarCategory(categoryId string) (*model.SidebarCategoryWithChannels, error)
   221  	GetSidebarCategoryOrder(userId, teamId string) ([]string, error)
   222  	CreateSidebarCategory(userId, teamId string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, error)
   223  	UpdateSidebarCategoryOrder(userId, teamId string, categoryOrder []string) error
   224  	UpdateSidebarCategories(userId, teamId string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, []*model.SidebarCategoryWithChannels, error)
   225  	UpdateSidebarChannelsByPreferences(preferences *model.Preferences) error
   226  	DeleteSidebarChannelsByPreferences(preferences *model.Preferences) error
   227  	DeleteSidebarCategory(categoryId string) error
   228  	GetAllChannelsForExportAfter(limit int, afterId string) ([]*model.ChannelForExport, error)
   229  	GetAllDirectChannelsForExportAfter(limit int, afterId string) ([]*model.DirectChannelForExport, error)
   230  	GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, error)
   231  	RemoveAllDeactivatedMembers(channelId string) error
   232  	GetChannelsBatchForIndexing(startTime, endTime int64, limit int) ([]*model.Channel, error)
   233  	UserBelongsToChannels(userId string, channelIds []string) (bool, error)
   234  
   235  	// UpdateMembersRole sets all of the given team members to admins and all of the other members of the team to
   236  	// non-admin members.
   237  	UpdateMembersRole(channelID string, userIDs []string) error
   238  
   239  	// GroupSyncedChannelCount returns the count of non-deleted group-constrained channels.
   240  	GroupSyncedChannelCount() (int64, error)
   241  }
   242  
   243  type ChannelMemberHistoryStore interface {
   244  	LogJoinEvent(userId string, channelId string, joinTime int64) error
   245  	LogLeaveEvent(userId string, channelId string, leaveTime int64) error
   246  	GetUsersInChannelDuring(startTime int64, endTime int64, channelId string) ([]*model.ChannelMemberHistoryResult, error)
   247  	PermanentDeleteBatch(endTime int64, limit int64) (int64, error)
   248  }
   249  type ThreadStore interface {
   250  	SaveMultiple(thread []*model.Thread) ([]*model.Thread, int, error)
   251  	Save(thread *model.Thread) (*model.Thread, error)
   252  	Update(thread *model.Thread) (*model.Thread, error)
   253  	Get(id string) (*model.Thread, error)
   254  	GetThreadsForUser(userId, teamId string, opts model.GetUserThreadsOpts) (*model.Threads, error)
   255  	GetThreadForUser(userId, teamId, threadId string, extended bool) (*model.ThreadResponse, error)
   256  	Delete(postId string) error
   257  	GetPosts(threadId string, since int64) ([]*model.Post, error)
   258  	GetThreadMentionsForUserPerChannel(userId, teamId string) (map[string]int64, error)
   259  
   260  	MarkAllAsRead(userId, teamId string) error
   261  	MarkAsRead(userId, threadId string, timestamp int64) error
   262  
   263  	SaveMembership(membership *model.ThreadMembership) (*model.ThreadMembership, error)
   264  	UpdateMembership(membership *model.ThreadMembership) (*model.ThreadMembership, error)
   265  	GetMembershipsForUser(userId, teamId string) ([]*model.ThreadMembership, error)
   266  	GetMembershipForUser(userId, postId string) (*model.ThreadMembership, error)
   267  	DeleteMembershipForUser(userId, postId string) error
   268  	CreateMembershipIfNeeded(userId, postId string, following, incrementMentions, updateFollowing bool) error
   269  	CollectThreadsWithNewerReplies(userId string, channelIds []string, timestamp int64) ([]string, error)
   270  	UpdateUnreadsByChannel(userId string, changedThreads []string, timestamp int64, updateViewedTimestamp bool) error
   271  }
   272  
   273  type PostStore interface {
   274  	SaveMultiple(posts []*model.Post) ([]*model.Post, int, error)
   275  	Save(post *model.Post) (*model.Post, error)
   276  	Update(newPost *model.Post, oldPost *model.Post) (*model.Post, error)
   277  	Get(id string, skipFetchThreads, collapsedThreads, collapsedThreadsExtended bool) (*model.PostList, error)
   278  	GetSingle(id string) (*model.Post, error)
   279  	Delete(postId string, time int64, deleteByID string) error
   280  	PermanentDeleteByUser(userId string) error
   281  	PermanentDeleteByChannel(channelId string) error
   282  	GetPosts(options model.GetPostsOptions, allowFromCache bool) (*model.PostList, error)
   283  	GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, error)
   284  	// @openTracingParams userId, teamId, offset, limit
   285  	GetFlaggedPostsForTeam(userId, teamId string, offset int, limit int) (*model.PostList, error)
   286  	GetFlaggedPostsForChannel(userId, channelId string, offset int, limit int) (*model.PostList, error)
   287  	GetPostsBefore(options model.GetPostsOptions) (*model.PostList, error)
   288  	GetPostsAfter(options model.GetPostsOptions) (*model.PostList, error)
   289  	GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, error)
   290  	GetPostAfterTime(channelId string, time int64) (*model.Post, error)
   291  	GetPostIdAfterTime(channelId string, time int64) (string, error)
   292  	GetPostIdBeforeTime(channelId string, time int64) (string, error)
   293  	GetEtag(channelId string, allowFromCache bool, collapsedThreads bool) string
   294  	Search(teamId string, userId string, params *model.SearchParams) (*model.PostList, error)
   295  	AnalyticsUserCountsWithPostsByDay(teamId string) (model.AnalyticsRows, error)
   296  	AnalyticsPostCountsByDay(options *model.AnalyticsPostCountsOptions) (model.AnalyticsRows, error)
   297  	AnalyticsPostCount(teamId string, mustHaveFile bool, mustHaveHashtag bool) (int64, error)
   298  	ClearCaches()
   299  	InvalidateLastPostTimeCache(channelId string)
   300  	GetPostsCreatedAt(channelId string, time int64) ([]*model.Post, error)
   301  	Overwrite(post *model.Post) (*model.Post, error)
   302  	OverwriteMultiple(posts []*model.Post) ([]*model.Post, int, error)
   303  	GetPostsByIds(postIds []string) ([]*model.Post, error)
   304  	GetPostsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.PostForIndexing, error)
   305  	PermanentDeleteBatch(endTime int64, limit int64) (int64, error)
   306  	GetOldest() (*model.Post, error)
   307  	GetMaxPostSize() int
   308  	GetParentsForExportAfter(limit int, afterId string) ([]*model.PostForExport, error)
   309  	GetRepliesForExport(parentId string) ([]*model.ReplyForExport, error)
   310  	GetDirectPostParentsForExportAfter(limit int, afterId string) ([]*model.DirectPostForExport, error)
   311  	SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId, teamId string, page, perPage int) (*model.PostSearchResults, error)
   312  	GetOldestEntityCreationTime() (int64, error)
   313  }
   314  
   315  type UserStore interface {
   316  	Save(user *model.User) (*model.User, error)
   317  	Update(user *model.User, allowRoleUpdate bool) (*model.UserUpdate, error)
   318  	UpdateLastPictureUpdate(userId string) error
   319  	ResetLastPictureUpdate(userId string) error
   320  	UpdatePassword(userId, newPassword string) error
   321  	UpdateUpdateAt(userId string) (int64, error)
   322  	UpdateAuthData(userId string, service string, authData *string, email string, resetMfa bool) (string, error)
   323  	UpdateMfaSecret(userId, secret string) error
   324  	UpdateMfaActive(userId string, active bool) error
   325  	Get(ctx context.Context, id string) (*model.User, error)
   326  	GetMany(ctx context.Context, ids []string) ([]*model.User, error)
   327  	GetAll() ([]*model.User, error)
   328  	ClearCaches()
   329  	InvalidateProfilesInChannelCacheByUser(userId string)
   330  	InvalidateProfilesInChannelCache(channelId string)
   331  	GetProfilesInChannel(options *model.UserGetOptions) ([]*model.User, error)
   332  	GetProfilesInChannelByStatus(options *model.UserGetOptions) ([]*model.User, error)
   333  	GetAllProfilesInChannel(ctx context.Context, channelId string, allowFromCache bool) (map[string]*model.User, error)
   334  	GetProfilesNotInChannel(teamId string, channelId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error)
   335  	GetProfilesWithoutTeam(options *model.UserGetOptions) ([]*model.User, error)
   336  	GetProfilesByUsernames(usernames []string, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error)
   337  	GetAllProfiles(options *model.UserGetOptions) ([]*model.User, error)
   338  	GetProfiles(options *model.UserGetOptions) ([]*model.User, error)
   339  	GetProfileByIds(ctx context.Context, userIds []string, options *UserGetByIdsOpts, allowFromCache bool) ([]*model.User, error)
   340  	GetProfileByGroupChannelIdsForUser(userId string, channelIds []string) (map[string][]*model.User, error)
   341  	InvalidateProfileCacheForUser(userId string)
   342  	GetByEmail(email string) (*model.User, error)
   343  	GetByAuth(authData *string, authService string) (*model.User, error)
   344  	GetAllUsingAuthService(authService string) ([]*model.User, error)
   345  	GetAllNotInAuthService(authServices []string) ([]*model.User, error)
   346  	GetByUsername(username string) (*model.User, error)
   347  	GetForLogin(loginId string, allowSignInWithUsername, allowSignInWithEmail bool) (*model.User, error)
   348  	VerifyEmail(userId, email string) (string, error)
   349  	GetEtagForAllProfiles() string
   350  	GetEtagForProfiles(teamId string) string
   351  	UpdateFailedPasswordAttempts(userId string, attempts int) error
   352  	GetSystemAdminProfiles() (map[string]*model.User, error)
   353  	PermanentDelete(userId string) error
   354  	AnalyticsActiveCount(time int64, options model.UserCountOptions) (int64, error)
   355  	AnalyticsActiveCountForPeriod(startTime int64, endTime int64, options model.UserCountOptions) (int64, error)
   356  	GetUnreadCount(userId string) (int64, error)
   357  	GetUnreadCountForChannel(userId string, channelId string) (int64, error)
   358  	GetAnyUnreadPostCountForChannel(userId string, channelId string) (int64, error)
   359  	GetRecentlyActiveUsersForTeam(teamId string, offset, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error)
   360  	GetNewUsersForTeam(teamId string, offset, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error)
   361  	Search(teamId string, term string, options *model.UserSearchOptions) ([]*model.User, error)
   362  	SearchNotInTeam(notInTeamId string, term string, options *model.UserSearchOptions) ([]*model.User, error)
   363  	SearchInChannel(channelId string, term string, options *model.UserSearchOptions) ([]*model.User, error)
   364  	SearchNotInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) ([]*model.User, error)
   365  	SearchWithoutTeam(term string, options *model.UserSearchOptions) ([]*model.User, error)
   366  	SearchInGroup(groupID string, term string, options *model.UserSearchOptions) ([]*model.User, error)
   367  	AnalyticsGetInactiveUsersCount() (int64, error)
   368  	AnalyticsGetExternalUsers(hostDomain string) (bool, error)
   369  	AnalyticsGetSystemAdminCount() (int64, error)
   370  	AnalyticsGetGuestCount() (int64, error)
   371  	GetProfilesNotInTeam(teamId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error)
   372  	GetEtagForProfilesNotInTeam(teamId string) string
   373  	ClearAllCustomRoleAssignments() error
   374  	InferSystemInstallDate() (int64, error)
   375  	GetAllAfter(limit int, afterId string) ([]*model.User, error)
   376  	GetUsersBatchForIndexing(startTime, endTime int64, limit int) ([]*model.UserForIndexing, error)
   377  	Count(options model.UserCountOptions) (int64, error)
   378  	GetTeamGroupUsers(teamID string) ([]*model.User, error)
   379  	GetChannelGroupUsers(channelID string) ([]*model.User, error)
   380  	PromoteGuestToUser(userID string) error
   381  	DemoteUserToGuest(userID string) (*model.User, error)
   382  	DeactivateGuests() ([]string, error)
   383  	AutocompleteUsersInChannel(teamId, channelId, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, error)
   384  	GetKnownUsers(userID string) ([]string, error)
   385  }
   386  
   387  type BotStore interface {
   388  	Get(userId string, includeDeleted bool) (*model.Bot, error)
   389  	GetAll(options *model.BotGetOptions) ([]*model.Bot, error)
   390  	Save(bot *model.Bot) (*model.Bot, error)
   391  	Update(bot *model.Bot) (*model.Bot, error)
   392  	PermanentDelete(userId string) error
   393  }
   394  
   395  type SessionStore interface {
   396  	Get(sessionIdOrToken string) (*model.Session, error)
   397  	Save(session *model.Session) (*model.Session, error)
   398  	GetSessions(userId string) ([]*model.Session, error)
   399  	GetSessionsWithActiveDeviceIds(userId string) ([]*model.Session, error)
   400  	GetSessionsExpired(thresholdMillis int64, mobileOnly bool, unnotifiedOnly bool) ([]*model.Session, error)
   401  	UpdateExpiredNotify(sessionid string, notified bool) error
   402  	Remove(sessionIdOrToken string) error
   403  	RemoveAllSessions() error
   404  	PermanentDeleteSessionsByUser(teamId string) error
   405  	UpdateExpiresAt(sessionId string, time int64) error
   406  	UpdateLastActivityAt(sessionId string, time int64) error
   407  	UpdateRoles(userId string, roles string) (string, error)
   408  	UpdateDeviceId(id string, deviceId string, expiresAt int64) (string, error)
   409  	UpdateProps(session *model.Session) error
   410  	AnalyticsSessionCount() (int64, error)
   411  	Cleanup(expiryTime int64, batchSize int64)
   412  }
   413  
   414  type AuditStore interface {
   415  	Save(audit *model.Audit) error
   416  	Get(user_id string, offset int, limit int) (model.Audits, error)
   417  	PermanentDeleteByUser(userId string) error
   418  }
   419  
   420  type ClusterDiscoveryStore interface {
   421  	Save(discovery *model.ClusterDiscovery) error
   422  	Delete(discovery *model.ClusterDiscovery) (bool, error)
   423  	Exists(discovery *model.ClusterDiscovery) (bool, error)
   424  	GetAll(discoveryType, clusterName string) ([]*model.ClusterDiscovery, error)
   425  	SetLastPingAt(discovery *model.ClusterDiscovery) error
   426  	Cleanup() error
   427  }
   428  
   429  type ComplianceStore interface {
   430  	Save(compliance *model.Compliance) (*model.Compliance, error)
   431  	Update(compliance *model.Compliance) (*model.Compliance, error)
   432  	Get(id string) (*model.Compliance, error)
   433  	GetAll(offset, limit int) (model.Compliances, error)
   434  	ComplianceExport(compliance *model.Compliance) ([]*model.CompliancePost, error)
   435  	MessageExport(after int64, limit int) ([]*model.MessageExport, error)
   436  }
   437  
   438  type OAuthStore interface {
   439  	SaveApp(app *model.OAuthApp) (*model.OAuthApp, error)
   440  	UpdateApp(app *model.OAuthApp) (*model.OAuthApp, error)
   441  	GetApp(id string) (*model.OAuthApp, error)
   442  	GetAppByUser(userId string, offset, limit int) ([]*model.OAuthApp, error)
   443  	GetApps(offset, limit int) ([]*model.OAuthApp, error)
   444  	GetAuthorizedApps(userId string, offset, limit int) ([]*model.OAuthApp, error)
   445  	DeleteApp(id string) error
   446  	SaveAuthData(authData *model.AuthData) (*model.AuthData, error)
   447  	GetAuthData(code string) (*model.AuthData, error)
   448  	RemoveAuthData(code string) error
   449  	PermanentDeleteAuthDataByUser(userId string) error
   450  	SaveAccessData(accessData *model.AccessData) (*model.AccessData, error)
   451  	UpdateAccessData(accessData *model.AccessData) (*model.AccessData, error)
   452  	GetAccessData(token string) (*model.AccessData, error)
   453  	GetAccessDataByUserForApp(userId, clientId string) ([]*model.AccessData, error)
   454  	GetAccessDataByRefreshToken(token string) (*model.AccessData, error)
   455  	GetPreviousAccessData(userId, clientId string) (*model.AccessData, error)
   456  	RemoveAccessData(token string) error
   457  	RemoveAllAccessData() error
   458  }
   459  
   460  type SystemStore interface {
   461  	Save(system *model.System) error
   462  	SaveOrUpdate(system *model.System) error
   463  	Update(system *model.System) error
   464  	Get() (model.StringMap, error)
   465  	GetByName(name string) (*model.System, error)
   466  	PermanentDeleteByName(name string) (*model.System, error)
   467  	InsertIfExists(system *model.System) (*model.System, error)
   468  	SaveOrUpdateWithWarnMetricHandling(system *model.System) error
   469  }
   470  
   471  type WebhookStore interface {
   472  	SaveIncoming(webhook *model.IncomingWebhook) (*model.IncomingWebhook, error)
   473  	GetIncoming(id string, allowFromCache bool) (*model.IncomingWebhook, error)
   474  	GetIncomingList(offset, limit int) ([]*model.IncomingWebhook, error)
   475  	GetIncomingListByUser(userId string, offset, limit int) ([]*model.IncomingWebhook, error)
   476  	GetIncomingByTeam(teamId string, offset, limit int) ([]*model.IncomingWebhook, error)
   477  	GetIncomingByTeamByUser(teamId string, userId string, offset, limit int) ([]*model.IncomingWebhook, error)
   478  	UpdateIncoming(webhook *model.IncomingWebhook) (*model.IncomingWebhook, error)
   479  	GetIncomingByChannel(channelId string) ([]*model.IncomingWebhook, error)
   480  	DeleteIncoming(webhookId string, time int64) error
   481  	PermanentDeleteIncomingByChannel(channelId string) error
   482  	PermanentDeleteIncomingByUser(userId string) error
   483  
   484  	SaveOutgoing(webhook *model.OutgoingWebhook) (*model.OutgoingWebhook, error)
   485  	GetOutgoing(id string) (*model.OutgoingWebhook, error)
   486  	GetOutgoingByChannel(channelId string, offset, limit int) ([]*model.OutgoingWebhook, error)
   487  	GetOutgoingByChannelByUser(channelId string, userId string, offset, limit int) ([]*model.OutgoingWebhook, error)
   488  	GetOutgoingList(offset, limit int) ([]*model.OutgoingWebhook, error)
   489  	GetOutgoingListByUser(userId string, offset, limit int) ([]*model.OutgoingWebhook, error)
   490  	GetOutgoingByTeam(teamId string, offset, limit int) ([]*model.OutgoingWebhook, error)
   491  	GetOutgoingByTeamByUser(teamId string, userId string, offset, limit int) ([]*model.OutgoingWebhook, error)
   492  	DeleteOutgoing(webhookId string, time int64) error
   493  	PermanentDeleteOutgoingByChannel(channelId string) error
   494  	PermanentDeleteOutgoingByUser(userId string) error
   495  	UpdateOutgoing(hook *model.OutgoingWebhook) (*model.OutgoingWebhook, error)
   496  
   497  	AnalyticsIncomingCount(teamId string) (int64, error)
   498  	AnalyticsOutgoingCount(teamId string) (int64, error)
   499  	InvalidateWebhookCache(webhook string)
   500  	ClearCaches()
   501  }
   502  
   503  type CommandStore interface {
   504  	Save(webhook *model.Command) (*model.Command, error)
   505  	GetByTrigger(teamId string, trigger string) (*model.Command, error)
   506  	Get(id string) (*model.Command, error)
   507  	GetByTeam(teamId string) ([]*model.Command, error)
   508  	Delete(commandId string, time int64) error
   509  	PermanentDeleteByTeam(teamId string) error
   510  	PermanentDeleteByUser(userId string) error
   511  	Update(hook *model.Command) (*model.Command, error)
   512  	AnalyticsCommandCount(teamId string) (int64, error)
   513  }
   514  
   515  type CommandWebhookStore interface {
   516  	Save(webhook *model.CommandWebhook) (*model.CommandWebhook, error)
   517  	Get(id string) (*model.CommandWebhook, error)
   518  	TryUse(id string, limit int) error
   519  	Cleanup()
   520  }
   521  
   522  type PreferenceStore interface {
   523  	Save(preferences *model.Preferences) error
   524  	GetCategory(userId string, category string) (model.Preferences, error)
   525  	Get(userId string, category string, name string) (*model.Preference, error)
   526  	GetAll(userId string) (model.Preferences, error)
   527  	Delete(userId, category, name string) error
   528  	DeleteCategory(userId string, category string) error
   529  	DeleteCategoryAndName(category string, name string) error
   530  	PermanentDeleteByUser(userId string) error
   531  	CleanupFlagsBatch(limit int64) (int64, error)
   532  }
   533  
   534  type LicenseStore interface {
   535  	Save(license *model.LicenseRecord) (*model.LicenseRecord, error)
   536  	Get(id string) (*model.LicenseRecord, error)
   537  }
   538  
   539  type TokenStore interface {
   540  	Save(recovery *model.Token) error
   541  	Delete(token string) error
   542  	GetByToken(token string) (*model.Token, error)
   543  	Cleanup()
   544  	RemoveAllTokensByType(tokenType string) error
   545  }
   546  
   547  type EmojiStore interface {
   548  	Save(emoji *model.Emoji) (*model.Emoji, error)
   549  	Get(id string, allowFromCache bool) (*model.Emoji, error)
   550  	GetByName(name string, allowFromCache bool) (*model.Emoji, error)
   551  	GetMultipleByName(names []string) ([]*model.Emoji, error)
   552  	GetList(offset, limit int, sort string) ([]*model.Emoji, error)
   553  	Delete(emoji *model.Emoji, time int64) error
   554  	Search(name string, prefixOnly bool, limit int) ([]*model.Emoji, error)
   555  }
   556  
   557  type StatusStore interface {
   558  	SaveOrUpdate(status *model.Status) error
   559  	Get(userId string) (*model.Status, error)
   560  	GetByIds(userIds []string) ([]*model.Status, error)
   561  	ResetAll() error
   562  	GetTotalActiveUsersCount() (int64, error)
   563  	UpdateLastActivityAt(userId string, lastActivityAt int64) error
   564  }
   565  
   566  type FileInfoStore interface {
   567  	Save(info *model.FileInfo) (*model.FileInfo, error)
   568  	Upsert(info *model.FileInfo) (*model.FileInfo, error)
   569  	Get(id string) (*model.FileInfo, error)
   570  	GetByIds(ids []string) ([]*model.FileInfo, error)
   571  	GetByPath(path string) (*model.FileInfo, error)
   572  	GetForPost(postId string, readFromMaster, includeDeleted, allowFromCache bool) ([]*model.FileInfo, error)
   573  	GetForUser(userId string) ([]*model.FileInfo, error)
   574  	GetWithOptions(page, perPage int, opt *model.GetFileInfosOptions) ([]*model.FileInfo, error)
   575  	InvalidateFileInfosForPostCache(postId string, deleted bool)
   576  	AttachToPost(fileId string, postId string, creatorId string) error
   577  	DeleteForPost(postId string) (string, error)
   578  	PermanentDelete(fileId string) error
   579  	PermanentDeleteBatch(endTime int64, limit int64) (int64, error)
   580  	PermanentDeleteByUser(userId string) (int64, error)
   581  	SetContent(fileId, content string) error
   582  	Search(paramsList []*model.SearchParams, userId, teamId string, page, perPage int) (*model.FileInfoList, error)
   583  	ClearCaches()
   584  }
   585  
   586  type UploadSessionStore interface {
   587  	Save(session *model.UploadSession) (*model.UploadSession, error)
   588  	Update(session *model.UploadSession) error
   589  	Get(id string) (*model.UploadSession, error)
   590  	GetForUser(userId string) ([]*model.UploadSession, error)
   591  	Delete(id string) error
   592  }
   593  
   594  type ReactionStore interface {
   595  	Save(reaction *model.Reaction) (*model.Reaction, error)
   596  	Delete(reaction *model.Reaction) (*model.Reaction, error)
   597  	GetForPost(postId string, allowFromCache bool) ([]*model.Reaction, error)
   598  	DeleteAllWithEmojiName(emojiName string) error
   599  	PermanentDeleteBatch(endTime int64, limit int64) (int64, error)
   600  	BulkGetForPosts(postIds []string) ([]*model.Reaction, error)
   601  }
   602  
   603  type JobStore interface {
   604  	Save(job *model.Job) (*model.Job, error)
   605  	UpdateOptimistically(job *model.Job, currentStatus string) (bool, error)
   606  	UpdateStatus(id string, status string) (*model.Job, error)
   607  	UpdateStatusOptimistically(id string, currentStatus string, newStatus string) (bool, error)
   608  	Get(id string) (*model.Job, error)
   609  	GetAllPage(offset int, limit int) ([]*model.Job, error)
   610  	GetAllByType(jobType string) ([]*model.Job, error)
   611  	GetAllByTypePage(jobType string, offset int, limit int) ([]*model.Job, error)
   612  	GetAllByStatus(status string) ([]*model.Job, error)
   613  	GetNewestJobByStatusAndType(status string, jobType string) (*model.Job, error)
   614  	GetNewestJobByStatusesAndType(statuses []string, jobType string) (*model.Job, error)
   615  	GetCountByStatusAndType(status string, jobType string) (int64, error)
   616  	Delete(id string) (string, error)
   617  }
   618  
   619  type UserAccessTokenStore interface {
   620  	Save(token *model.UserAccessToken) (*model.UserAccessToken, error)
   621  	DeleteAllForUser(userId string) error
   622  	Delete(tokenId string) error
   623  	Get(tokenId string) (*model.UserAccessToken, error)
   624  	GetAll(offset int, limit int) ([]*model.UserAccessToken, error)
   625  	GetByToken(tokenString string) (*model.UserAccessToken, error)
   626  	GetByUser(userId string, page, perPage int) ([]*model.UserAccessToken, error)
   627  	Search(term string) ([]*model.UserAccessToken, error)
   628  	UpdateTokenEnable(tokenId string) error
   629  	UpdateTokenDisable(tokenId string) error
   630  }
   631  
   632  type PluginStore interface {
   633  	SaveOrUpdate(keyVal *model.PluginKeyValue) (*model.PluginKeyValue, error)
   634  	CompareAndSet(keyVal *model.PluginKeyValue, oldValue []byte) (bool, error)
   635  	CompareAndDelete(keyVal *model.PluginKeyValue, oldValue []byte) (bool, error)
   636  	SetWithOptions(pluginId string, key string, value []byte, options model.PluginKVSetOptions) (bool, error)
   637  	Get(pluginId, key string) (*model.PluginKeyValue, error)
   638  	Delete(pluginId, key string) error
   639  	DeleteAllForPlugin(PluginId string) error
   640  	DeleteAllExpired() error
   641  	List(pluginId string, page, perPage int) ([]string, error)
   642  }
   643  
   644  type RoleStore interface {
   645  	Save(role *model.Role) (*model.Role, error)
   646  	Get(roleId string) (*model.Role, error)
   647  	GetAll() ([]*model.Role, error)
   648  	GetByName(name string) (*model.Role, error)
   649  	GetByNames(names []string) ([]*model.Role, error)
   650  	Delete(roleId string) (*model.Role, error)
   651  	PermanentDeleteAll() error
   652  
   653  	// HigherScopedPermissions retrieves the higher-scoped permissions of a list of role names. The higher-scope
   654  	// (either team scheme or system scheme) is determined based on whether the team has a scheme or not.
   655  	ChannelHigherScopedPermissions(roleNames []string) (map[string]*model.RolePermissions, error)
   656  
   657  	// AllChannelSchemeRoles returns all of the roles associated to channel schemes.
   658  	AllChannelSchemeRoles() ([]*model.Role, error)
   659  
   660  	// ChannelRolesUnderTeamRole returns all of the non-deleted roles that are affected by updates to the
   661  	// given role.
   662  	ChannelRolesUnderTeamRole(roleName string) ([]*model.Role, error)
   663  }
   664  
   665  type SchemeStore interface {
   666  	Save(scheme *model.Scheme) (*model.Scheme, error)
   667  	Get(schemeId string) (*model.Scheme, error)
   668  	GetByName(schemeName string) (*model.Scheme, error)
   669  	GetAllPage(scope string, offset int, limit int) ([]*model.Scheme, error)
   670  	Delete(schemeId string) (*model.Scheme, error)
   671  	PermanentDeleteAll() error
   672  	CountByScope(scope string) (int64, error)
   673  	CountWithoutPermission(scope, permissionID string, roleScope model.RoleScope, roleType model.RoleType) (int64, error)
   674  }
   675  
   676  type TermsOfServiceStore interface {
   677  	Save(termsOfService *model.TermsOfService) (*model.TermsOfService, error)
   678  	GetLatest(allowFromCache bool) (*model.TermsOfService, error)
   679  	Get(id string, allowFromCache bool) (*model.TermsOfService, error)
   680  }
   681  
   682  type ProductNoticesStore interface {
   683  	View(userId string, notices []string) error
   684  	Clear(notices []string) error
   685  	ClearOldNotices(currentNotices *model.ProductNotices) error
   686  	GetViews(userId string) ([]model.ProductNoticeViewState, error)
   687  }
   688  
   689  type UserTermsOfServiceStore interface {
   690  	GetByUser(userId string) (*model.UserTermsOfService, error)
   691  	Save(userTermsOfService *model.UserTermsOfService) (*model.UserTermsOfService, error)
   692  	Delete(userId, termsOfServiceId string) error
   693  }
   694  
   695  type GroupStore interface {
   696  	Create(group *model.Group) (*model.Group, error)
   697  	Get(groupID string) (*model.Group, error)
   698  	GetByName(name string, opts model.GroupSearchOpts) (*model.Group, error)
   699  	GetByIDs(groupIDs []string) ([]*model.Group, error)
   700  	GetByRemoteID(remoteID string, groupSource model.GroupSource) (*model.Group, error)
   701  	GetAllBySource(groupSource model.GroupSource) ([]*model.Group, error)
   702  	GetByUser(userId string) ([]*model.Group, error)
   703  	Update(group *model.Group) (*model.Group, error)
   704  	Delete(groupID string) (*model.Group, error)
   705  
   706  	GetMemberUsers(groupID string) ([]*model.User, error)
   707  	GetMemberUsersPage(groupID string, page int, perPage int) ([]*model.User, error)
   708  	GetMemberCount(groupID string) (int64, error)
   709  
   710  	GetMemberUsersInTeam(groupID string, teamID string) ([]*model.User, error)
   711  	GetMemberUsersNotInChannel(groupID string, channelID string) ([]*model.User, error)
   712  
   713  	UpsertMember(groupID string, userID string) (*model.GroupMember, error)
   714  	DeleteMember(groupID string, userID string) (*model.GroupMember, error)
   715  	PermanentDeleteMembersByUser(userId string) error
   716  
   717  	CreateGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, error)
   718  	GetGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, error)
   719  	GetAllGroupSyncablesByGroupId(groupID string, syncableType model.GroupSyncableType) ([]*model.GroupSyncable, error)
   720  	UpdateGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, error)
   721  	DeleteGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, error)
   722  
   723  	// TeamMembersToAdd returns a slice of UserTeamIDPair that need newly created memberships
   724  	// based on the groups configurations. The returned list can be optionally scoped to a single given team.
   725  	//
   726  	// Typically since will be the last successful group sync time.
   727  	TeamMembersToAdd(since int64, teamID *string) ([]*model.UserTeamIDPair, error)
   728  
   729  	// ChannelMembersToAdd returns a slice of UserChannelIDPair that need newly created memberships
   730  	// based on the groups configurations. The returned list can be optionally scoped to a single given channel.
   731  	//
   732  	// Typically since will be the last successful group sync time.
   733  	ChannelMembersToAdd(since int64, channelID *string) ([]*model.UserChannelIDPair, error)
   734  
   735  	// TeamMembersToRemove returns all team members that should be removed based on group constraints.
   736  	TeamMembersToRemove(teamID *string) ([]*model.TeamMember, error)
   737  
   738  	// ChannelMembersToRemove returns all channel members that should be removed based on group constraints.
   739  	ChannelMembersToRemove(channelID *string) ([]*model.ChannelMember, error)
   740  
   741  	GetGroupsByChannel(channelId string, opts model.GroupSearchOpts) ([]*model.GroupWithSchemeAdmin, error)
   742  	CountGroupsByChannel(channelId string, opts model.GroupSearchOpts) (int64, error)
   743  
   744  	GetGroupsByTeam(teamId string, opts model.GroupSearchOpts) ([]*model.GroupWithSchemeAdmin, error)
   745  	GetGroupsAssociatedToChannelsByTeam(teamId string, opts model.GroupSearchOpts) (map[string][]*model.GroupWithSchemeAdmin, error)
   746  	CountGroupsByTeam(teamId string, opts model.GroupSearchOpts) (int64, error)
   747  
   748  	GetGroups(page, perPage int, opts model.GroupSearchOpts) ([]*model.Group, error)
   749  
   750  	TeamMembersMinusGroupMembers(teamID string, groupIDs []string, page, perPage int) ([]*model.UserWithGroups, error)
   751  	CountTeamMembersMinusGroupMembers(teamID string, groupIDs []string) (int64, error)
   752  	ChannelMembersMinusGroupMembers(channelID string, groupIDs []string, page, perPage int) ([]*model.UserWithGroups, error)
   753  	CountChannelMembersMinusGroupMembers(channelID string, groupIDs []string) (int64, error)
   754  
   755  	// AdminRoleGroupsForSyncableMember returns the IDs of all of the groups that the user is a member of that are
   756  	// configured as SchemeAdmin: true for the given syncable.
   757  	AdminRoleGroupsForSyncableMember(userID, syncableID string, syncableType model.GroupSyncableType) ([]string, error)
   758  
   759  	// PermittedSyncableAdmins returns the IDs of all of the user who are permitted by the group syncable to have
   760  	// the admin role for the given syncable.
   761  	PermittedSyncableAdmins(syncableID string, syncableType model.GroupSyncableType) ([]string, error)
   762  
   763  	// GroupCount returns the total count of records in the UserGroups table.
   764  	GroupCount() (int64, error)
   765  
   766  	// GroupTeamCount returns the total count of records in the GroupTeams table.
   767  	GroupTeamCount() (int64, error)
   768  
   769  	// GroupChannelCount returns the total count of records in the GroupChannels table.
   770  	GroupChannelCount() (int64, error)
   771  
   772  	// GroupMemberCount returns the total count of records in the GroupMembers table.
   773  	GroupMemberCount() (int64, error)
   774  
   775  	// DistinctGroupMemberCount returns the count of records in the GroupMembers table with distinct UserId values.
   776  	DistinctGroupMemberCount() (int64, error)
   777  
   778  	// GroupCountWithAllowReference returns the count of records in the Groups table with AllowReference set to true.
   779  	GroupCountWithAllowReference() (int64, error)
   780  }
   781  
   782  type LinkMetadataStore interface {
   783  	Save(linkMetadata *model.LinkMetadata) (*model.LinkMetadata, error)
   784  	Get(url string, timestamp int64) (*model.LinkMetadata, error)
   785  }
   786  
   787  // ChannelSearchOpts contains options for searching channels.
   788  //
   789  // NotAssociatedToGroup will exclude channels that have associated, active GroupChannels records.
   790  // IncludeDeleted will include channel records where DeleteAt != 0.
   791  // ExcludeChannelNames will exclude channels from the results by name.
   792  // Paginate whether to paginate the results.
   793  // Page page requested, if results are paginated.
   794  // PerPage number of results per page, if paginated.
   795  //
   796  type ChannelSearchOpts struct {
   797  	NotAssociatedToGroup    string
   798  	IncludeDeleted          bool
   799  	Deleted                 bool
   800  	ExcludeChannelNames     []string
   801  	TeamIds                 []string
   802  	GroupConstrained        bool
   803  	ExcludeGroupConstrained bool
   804  	Public                  bool
   805  	Private                 bool
   806  	Page                    *int
   807  	PerPage                 *int
   808  }
   809  
   810  func (c *ChannelSearchOpts) IsPaginated() bool {
   811  	return c.Page != nil && c.PerPage != nil
   812  }
   813  
   814  type UserGetByIdsOpts struct {
   815  	// IsAdmin tracks whether or not the request is being made by an administrator. Does nothing when provided by a client.
   816  	IsAdmin bool
   817  
   818  	// Restrict to search in a list of teams and channels. Does nothing when provided by a client.
   819  	ViewRestrictions *model.ViewUsersRestrictions
   820  
   821  	// Since filters the users based on their UpdateAt timestamp.
   822  	Since int64
   823  }