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