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