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