store.go 22 KB
Newer Older
1
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
=Corey Hulen's avatar
=Corey Hulen committed
2 3 4 5 6
// See License.txt for license information.

package store

import (
7 8
	"time"

Christopher Speller's avatar
Christopher Speller committed
9
	"github.com/mattermost/mattermost-server/model"
=Corey Hulen's avatar
=Corey Hulen committed
10 11 12 13 14 15 16 17 18
)

type StoreResult struct {
	Data interface{}
	Err  *model.AppError
}

type StoreChannel chan StoreResult

19 20 21 22 23 24 25 26 27 28 29
func Do(f func(result *StoreResult)) StoreChannel {
	storeChannel := make(StoreChannel, 1)
	go func() {
		result := StoreResult{}
		f(&result)
		storeChannel <- result
		close(storeChannel)
	}()
	return storeChannel
}

=Corey Hulen's avatar
=Corey Hulen committed
30 31 32
func Must(sc StoreChannel) interface{} {
	r := <-sc
	if r.Err != nil {
33

=Corey Hulen's avatar
=Corey Hulen committed
34
		time.Sleep(time.Second)
=Corey Hulen's avatar
=Corey Hulen committed
35 36 37 38 39 40
		panic(r.Err)
	}

	return r.Data
}

=Corey Hulen's avatar
=Corey Hulen committed
41 42 43 44 45 46
type Store interface {
	Team() TeamStore
	Channel() ChannelStore
	Post() PostStore
	User() UserStore
	Audit() AuditStore
47
	ClusterDiscovery() ClusterDiscoveryStore
=Corey Hulen's avatar
=Corey Hulen committed
48
	Compliance() ComplianceStore
=Corey Hulen's avatar
=Corey Hulen committed
49
	Session() SessionStore
50
	OAuth() OAuthStore
=Corey Hulen's avatar
=Corey Hulen committed
51
	System() SystemStore
JoramWilander's avatar
JoramWilander committed
52
	Webhook() WebhookStore
53
	Command() CommandStore
54
	CommandWebhook() CommandWebhookStore
55
	Preference() PreferenceStore
56
	License() LicenseStore
57
	Token() TokenStore
58
	Emoji() EmojiStore
59
	Status() StatusStore
60
	FileInfo() FileInfoStore
61
	Reaction() ReactionStore
62
	Role() RoleStore
63
	Scheme() SchemeStore
64
	Job() JobStore
65
	UserAccessToken() UserAccessTokenStore
66
	ChannelMemberHistory() ChannelMemberHistoryStore
67
	Plugin() PluginStore
68
	TermsOfService() TermsOfServiceStore
69
	UserTermsOfService() UserTermsOfServiceStore
70
	MarkSystemRanUnitTests()
=Corey Hulen's avatar
=Corey Hulen committed
71
	Close()
72 73
	LockToMaster()
	UnlockFromMaster()
74
	DropAllTables()
75 76
	TotalMasterDbConnections() int
	TotalReadDbConnections() int
77
	TotalSearchDbConnections() int
=Corey Hulen's avatar
=Corey Hulen committed
78 79 80
}

type TeamStore interface {
81 82 83 84 85
	Save(team *model.Team) StoreChannel
	Update(team *model.Team) StoreChannel
	UpdateDisplayName(name string, teamId string) StoreChannel
	Get(id string) StoreChannel
	GetByName(name string) StoreChannel
86
	SearchByName(name string) StoreChannel
87 88
	SearchAll(term string) StoreChannel
	SearchOpen(term string) StoreChannel
89
	GetAll() StoreChannel
Andrei Stanciu's avatar
Andrei Stanciu committed
90
	GetAllPage(offset int, limit int) StoreChannel
91
	GetAllTeamListing() StoreChannel
Andrei Stanciu's avatar
Andrei Stanciu committed
92
	GetAllTeamPageListing(offset int, limit int) StoreChannel
93
	GetTeamsByUserId(userId string) StoreChannel
94 95
	GetByInviteId(inviteId string) StoreChannel
	PermanentDelete(teamId string) StoreChannel
96
	AnalyticsTeamCount() StoreChannel
Chris's avatar
Chris committed
97
	SaveMember(member *model.TeamMember, maxUsersPerTeam int) StoreChannel
98
	UpdateMember(member *model.TeamMember) StoreChannel
99
	GetMember(teamId string, userId string) StoreChannel
100 101
	GetMembers(teamId string, offset int, limit int) StoreChannel
	GetMembersByIds(teamId string, userIds []string) StoreChannel
102 103
	GetTotalMemberCount(teamId string) StoreChannel
	GetActiveMemberCount(teamId string) StoreChannel
104
	GetTeamsForUser(userId string) StoreChannel
105 106
	GetChannelUnreadsForAllTeams(excludeTeamId, userId string) StoreChannel
	GetChannelUnreadsForTeam(teamId, userId string) StoreChannel
107 108 109
	RemoveMember(teamId string, userId string) StoreChannel
	RemoveAllMembersByTeam(teamId string) StoreChannel
	RemoveAllMembersByUser(userId string) StoreChannel
110
	UpdateLastTeamIconUpdate(teamId string, curTime int64) StoreChannel
111
	GetTeamsByScheme(schemeId string, offset int, limit int) StoreChannel
112
	MigrateTeamMembers(fromTeamId string, fromUserId string) StoreChannel
113
	ResetAllTeamSchemes() StoreChannel
114
	ClearAllCustomRoleAssignments() StoreChannel
115
	AnalyticsGetTeamCountForScheme(schemeId string) StoreChannel
116 117
	GetAllForExportAfter(limit int, afterId string) StoreChannel
	GetTeamMembersForExport(userId string) StoreChannel
=Corey Hulen's avatar
=Corey Hulen committed
118 119 120
}

type ChannelStore interface {
121
	Save(channel *model.Channel, maxChannelsPerTeam int64) StoreChannel
122
	CreateDirectChannel(userId string, otherUserId string) StoreChannel
123 124
	SaveDirectChannel(channel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) StoreChannel
	Update(channel *model.Channel) StoreChannel
125 126
	Get(id string, allowFromCache bool) StoreChannel
	InvalidateChannel(id string)
127
	InvalidateChannelByName(teamId, name string)
128 129
	GetFromMaster(id string) StoreChannel
	Delete(channelId string, time int64) StoreChannel
130
	Restore(channelId string, time int64) StoreChannel
131
	SetDeleteAt(channelId string, deleteAt int64, updateAt int64) StoreChannel
132
	PermanentDeleteByTeam(teamId string) StoreChannel
133
	PermanentDelete(channelId string) StoreChannel
134
	GetByName(team_id string, name string, allowFromCache bool) StoreChannel
135
	GetByNames(team_id string, names []string, allowFromCache bool) StoreChannel
136
	GetByNameIncludeDeleted(team_id string, name string, allowFromCache bool) StoreChannel
137
	GetDeletedByName(team_id string, name string) StoreChannel
138
	GetDeleted(team_id string, offset int, limit int) StoreChannel
Martin Kraft's avatar
Martin Kraft committed
139
	GetChannels(teamId string, userId string, includeDeleted bool) StoreChannel
140
	GetMoreChannels(teamId string, userId string, offset int, limit int) StoreChannel
141
	GetPublicChannelsForTeam(teamId string, offset int, limit int) StoreChannel
142
	GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) StoreChannel
143
	GetChannelCounts(teamId string, userId string) StoreChannel
144
	GetTeamChannels(teamId string) StoreChannel
145
	GetAll(teamId string) StoreChannel
146
	GetForPost(postId string) StoreChannel
147 148
	SaveMember(member *model.ChannelMember) StoreChannel
	UpdateMember(member *model.ChannelMember) StoreChannel
149
	GetMembers(channelId string, offset, limit int) StoreChannel
150
	GetMember(channelId string, userId string) StoreChannel
151
	GetChannelMembersTimezones(channelId string) StoreChannel
Martin Kraft's avatar
Martin Kraft committed
152
	GetAllChannelMembersForUser(userId string, allowFromCache bool, includeDeleted bool) StoreChannel
153 154
	InvalidateAllChannelMembersForUser(userId string)
	IsUserInChannelUseCache(userId string, channelId string) bool
155 156
	GetAllChannelMembersNotifyPropsForChannel(channelId string, allowFromCache bool) StoreChannel
	InvalidateCacheForChannelMembersNotifyProps(channelId string)
157
	GetMemberForPost(postId string, userId string) StoreChannel
158
	InvalidateMemberCount(channelId string)
159
	GetMemberCountFromCache(channelId string) int64
160
	GetMemberCount(channelId string, allowFromCache bool) StoreChannel
Gabin Aureche's avatar
Gabin Aureche committed
161
	GetPinnedPosts(channelId string) StoreChannel
162 163
	RemoveMember(channelId string, userId string) StoreChannel
	PermanentDeleteMembersByUser(userId string) StoreChannel
164
	PermanentDeleteMembersByChannel(channelId string) StoreChannel
165
	UpdateLastViewedAt(channelIds []string, userId string) StoreChannel
166 167
	IncrementMentionCount(channelId string, userId string) StoreChannel
	AnalyticsTypeCount(teamId string, channelType string) StoreChannel
168
	GetMembersForUser(teamId string, userId string) StoreChannel
Martin Kraft's avatar
Martin Kraft committed
169
	AutocompleteInTeam(teamId string, term string, includeDeleted bool) StoreChannel
170
	AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) StoreChannel
Martin Kraft's avatar
Martin Kraft committed
171
	SearchInTeam(teamId string, term string, includeDeleted bool) StoreChannel
172
	SearchMore(userId string, teamId string, term string) StoreChannel
173
	GetMembersByIds(channelId string, userIds []string) StoreChannel
174
	AnalyticsDeletedTypeCount(teamId string, channelType string) StoreChannel
175
	GetChannelUnread(channelId, userId string) StoreChannel
176
	ClearCaches()
177
	GetChannelsByScheme(schemeId string, offset int, limit int) StoreChannel
178
	MigrateChannelMembers(fromChannelId string, fromUserId string) StoreChannel
179
	ResetAllChannelSchemes() StoreChannel
180
	ClearAllCustomRoleAssignments() StoreChannel
181
	ResetLastPostAt() StoreChannel
182
	MigratePublicChannels() error
183 184
	GetAllChannelsForExportAfter(limit int, afterId string) StoreChannel
	GetChannelMembersForExport(userId string, teamId string) StoreChannel
185
	RemoveAllDeactivatedMembers(channelId string) StoreChannel
=Corey Hulen's avatar
=Corey Hulen committed
186 187
}

188 189 190 191
type ChannelMemberHistoryStore interface {
	LogJoinEvent(userId string, channelId string, joinTime int64) StoreChannel
	LogLeaveEvent(userId string, channelId string, leaveTime int64) StoreChannel
	GetUsersInChannelDuring(startTime int64, endTime int64, channelId string) StoreChannel
192
	PermanentDeleteBatch(endTime int64, limit int64) StoreChannel
193 194
}

=Corey Hulen's avatar
=Corey Hulen committed
195
type PostStore interface {
196
	Save(post *model.Post) StoreChannel
197
	Update(newPost *model.Post, oldPost *model.Post) StoreChannel
198
	Get(id string) StoreChannel
199
	GetSingle(id string) StoreChannel
200
	Delete(postId string, time int64, deleteByID string) StoreChannel
201
	PermanentDeleteByUser(userId string) StoreChannel
202
	PermanentDeleteByChannel(channelId string) StoreChannel
203
	GetPosts(channelId string, offset int, limit int, allowFromCache bool) StoreChannel
204
	GetFlaggedPosts(userId string, offset int, limit int) StoreChannel
205
	GetFlaggedPostsForTeam(userId, teamId string, offset int, limit int) StoreChannel
206
	GetFlaggedPostsForChannel(userId, channelId string, offset int, limit int) StoreChannel
207 208
	GetPostsBefore(channelId string, postId string, numPosts int, offset int) StoreChannel
	GetPostsAfter(channelId string, postId string, numPosts int, offset int) StoreChannel
209
	GetPostsSince(channelId string, time int64, allowFromCache bool) StoreChannel
210
	GetEtag(channelId string, allowFromCache bool) StoreChannel
211 212 213
	Search(teamId string, userId string, params *model.SearchParams) StoreChannel
	AnalyticsUserCountsWithPostsByDay(teamId string) StoreChannel
	AnalyticsPostCountsByDay(teamId string) StoreChannel
214
	AnalyticsPostCount(teamId string, mustHaveFile bool, mustHaveHashtag bool) StoreChannel
215
	ClearCaches()
216
	InvalidateLastPostTimeCache(channelId string)
217 218
	GetPostsCreatedAt(channelId string, time int64) StoreChannel
	Overwrite(post *model.Post) StoreChannel
219
	GetPostsByIds(postIds []string) StoreChannel
220
	GetPostsBatchForIndexing(startTime int64, endTime int64, limit int) StoreChannel
221
	PermanentDeleteBatch(endTime int64, limit int64) StoreChannel
222
	GetOldest() StoreChannel
223
	GetMaxPostSize() StoreChannel
224 225
	GetParentsForExportAfter(limit int, afterId string) StoreChannel
	GetRepliesForExport(parentId string) StoreChannel
=Corey Hulen's avatar
=Corey Hulen committed
226 227 228
}

type UserStore interface {
229 230 231
	Save(user *model.User) StoreChannel
	Update(user *model.User, allowRoleUpdate bool) StoreChannel
	UpdateLastPictureUpdate(userId string) StoreChannel
232
	ResetLastPictureUpdate(userId string) StoreChannel
233
	UpdateUpdateAt(userId string) StoreChannel
234
	UpdatePassword(userId, newPassword string) StoreChannel
235
	UpdateAuthData(userId string, service string, authData *string, email string, resetMfa bool) StoreChannel
JoramWilander's avatar
JoramWilander committed
236 237
	UpdateMfaSecret(userId, secret string) StoreChannel
	UpdateMfaActive(userId string, active bool) StoreChannel
238
	Get(id string) StoreChannel
239
	GetAll() StoreChannel
240
	ClearCaches()
241
	InvalidateProfilesInChannelCacheByUser(userId string)
242
	InvalidateProfilesInChannelCache(channelId string)
243
	GetProfilesInChannel(channelId string, offset int, limit int) StoreChannel
244
	GetProfilesInChannelByStatus(channelId string, offset int, limit int) StoreChannel
245
	GetAllProfilesInChannel(channelId string, allowFromCache bool) StoreChannel
246
	GetProfilesNotInChannel(teamId string, channelId string, offset int, limit int) StoreChannel
247
	GetProfilesWithoutTeam(offset int, limit int) StoreChannel
248 249 250
	GetProfilesByUsernames(usernames []string, teamId string) StoreChannel
	GetAllProfiles(offset int, limit int) StoreChannel
	GetProfiles(teamId string, offset int, limit int) StoreChannel
251 252
	GetProfileByIds(userId []string, allowFromCache bool) StoreChannel
	InvalidatProfileCacheForUser(userId string)
253
	GetByEmail(email string) StoreChannel
254
	GetByAuth(authData *string, authService string) StoreChannel
255
	GetAllUsingAuthService(authService string) StoreChannel
256
	GetByUsername(username string) StoreChannel
257
	GetForLogin(loginId string, allowSignInWithUsername, allowSignInWithEmail bool) StoreChannel
258
	VerifyEmail(userId string) StoreChannel
259
	GetEtagForAllProfiles() StoreChannel
260 261 262 263 264
	GetEtagForProfiles(teamId string) StoreChannel
	UpdateFailedPasswordAttempts(userId string, attempts int) StoreChannel
	GetTotalUsersCount() StoreChannel
	GetSystemAdminProfiles() StoreChannel
	PermanentDelete(userId string) StoreChannel
265
	AnalyticsUniqueUserCount(teamId string) StoreChannel
266
	AnalyticsActiveCount(time int64) StoreChannel
267
	GetUnreadCount(userId string) StoreChannel
268
	GetUnreadCountForChannel(userId string, channelId string) StoreChannel
269
	GetAnyUnreadPostCountForChannel(userId string, channelId string) StoreChannel
270 271
	GetRecentlyActiveUsersForTeam(teamId string, offset, limit int) StoreChannel
	GetNewUsersForTeam(teamId string, offset, limit int) StoreChannel
272 273 274 275 276
	Search(teamId string, term string, options *model.UserSearchOptions) StoreChannel
	SearchNotInTeam(notInTeamId string, term string, options *model.UserSearchOptions) StoreChannel
	SearchInChannel(channelId string, term string, options *model.UserSearchOptions) StoreChannel
	SearchNotInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) StoreChannel
	SearchWithoutTeam(term string, options *model.UserSearchOptions) StoreChannel
277 278
	AnalyticsGetInactiveUsersCount() StoreChannel
	AnalyticsGetSystemAdminCount() StoreChannel
279 280
	GetProfilesNotInTeam(teamId string, offset int, limit int) StoreChannel
	GetEtagForProfilesNotInTeam(teamId string) StoreChannel
281
	ClearAllCustomRoleAssignments() StoreChannel
282
	InferSystemInstallDate() StoreChannel
283
	GetAllAfter(limit int, afterId string) StoreChannel
=Corey Hulen's avatar
=Corey Hulen committed
284 285 286
}

type SessionStore interface {
287 288 289
	Save(session *model.Session) StoreChannel
	Get(sessionIdOrToken string) StoreChannel
	GetSessions(userId string) StoreChannel
290
	GetSessionsWithActiveDeviceIds(userId string) StoreChannel
291
	Remove(sessionIdOrToken string) StoreChannel
292
	RemoveAllSessions() StoreChannel
293 294 295
	PermanentDeleteSessionsByUser(teamId string) StoreChannel
	UpdateLastActivityAt(sessionId string, time int64) StoreChannel
	UpdateRoles(userId string, roles string) StoreChannel
296
	UpdateDeviceId(id string, deviceId string, expiresAt int64) StoreChannel
297
	AnalyticsSessionCount() StoreChannel
298
	Cleanup(expiryTime int64, batchSize int64)
=Corey Hulen's avatar
=Corey Hulen committed
299 300 301
}

type AuditStore interface {
302
	Save(audit *model.Audit) StoreChannel
303
	Get(user_id string, offset int, limit int) StoreChannel
304
	PermanentDeleteByUser(userId string) StoreChannel
305
	PermanentDeleteBatch(endTime int64, limit int64) StoreChannel
=Corey Hulen's avatar
=Corey Hulen committed
306
}
307

308 309 310 311 312 313 314 315 316
type ClusterDiscoveryStore interface {
	Save(discovery *model.ClusterDiscovery) StoreChannel
	Delete(discovery *model.ClusterDiscovery) StoreChannel
	Exists(discovery *model.ClusterDiscovery) StoreChannel
	GetAll(discoveryType, clusterName string) StoreChannel
	SetLastPingAt(discovery *model.ClusterDiscovery) StoreChannel
	Cleanup() StoreChannel
}

=Corey Hulen's avatar
=Corey Hulen committed
317 318 319 320
type ComplianceStore interface {
	Save(compliance *model.Compliance) StoreChannel
	Update(compliance *model.Compliance) StoreChannel
	Get(id string) StoreChannel
321
	GetAll(offset, limit int) StoreChannel
=Corey Hulen's avatar
=Corey Hulen committed
322
	ComplianceExport(compliance *model.Compliance) StoreChannel
323
	MessageExport(after int64, limit int) StoreChannel
=Corey Hulen's avatar
=Corey Hulen committed
324 325
}

326
type OAuthStore interface {
327 328 329
	SaveApp(app *model.OAuthApp) StoreChannel
	UpdateApp(app *model.OAuthApp) StoreChannel
	GetApp(id string) StoreChannel
330 331 332
	GetAppByUser(userId string, offset, limit int) StoreChannel
	GetApps(offset, limit int) StoreChannel
	GetAuthorizedApps(userId string, offset, limit int) StoreChannel
333
	DeleteApp(id string) StoreChannel
334 335 336 337 338
	SaveAuthData(authData *model.AuthData) StoreChannel
	GetAuthData(code string) StoreChannel
	RemoveAuthData(code string) StoreChannel
	PermanentDeleteAuthDataByUser(userId string) StoreChannel
	SaveAccessData(accessData *model.AccessData) StoreChannel
339
	UpdateAccessData(accessData *model.AccessData) StoreChannel
340
	GetAccessData(token string) StoreChannel
341
	GetAccessDataByUserForApp(userId, clientId string) StoreChannel
342 343
	GetAccessDataByRefreshToken(token string) StoreChannel
	GetPreviousAccessData(userId, clientId string) StoreChannel
344
	RemoveAccessData(token string) StoreChannel
345
}
=Corey Hulen's avatar
=Corey Hulen committed
346 347

type SystemStore interface {
348
	Save(system *model.System) StoreChannel
349
	SaveOrUpdate(system *model.System) StoreChannel
350 351
	Update(system *model.System) StoreChannel
	Get() StoreChannel
352
	GetByName(name string) StoreChannel
353
	PermanentDeleteByName(name string) StoreChannel
=Corey Hulen's avatar
=Corey Hulen committed
354
}
JoramWilander's avatar
JoramWilander committed
355 356

type WebhookStore interface {
357
	SaveIncoming(webhook *model.IncomingWebhook) StoreChannel
358
	GetIncoming(id string, allowFromCache bool) StoreChannel
359 360
	GetIncomingList(offset, limit int) StoreChannel
	GetIncomingByTeam(teamId string, offset, limit int) StoreChannel
361
	UpdateIncoming(webhook *model.IncomingWebhook) StoreChannel
362 363
	GetIncomingByChannel(channelId string) StoreChannel
	DeleteIncoming(webhookId string, time int64) StoreChannel
364
	PermanentDeleteIncomingByChannel(channelId string) StoreChannel
365
	PermanentDeleteIncomingByUser(userId string) StoreChannel
366

367 368
	SaveOutgoing(webhook *model.OutgoingWebhook) StoreChannel
	GetOutgoing(id string) StoreChannel
369 370 371
	GetOutgoingList(offset, limit int) StoreChannel
	GetOutgoingByChannel(channelId string, offset, limit int) StoreChannel
	GetOutgoingByTeam(teamId string, offset, limit int) StoreChannel
372
	DeleteOutgoing(webhookId string, time int64) StoreChannel
373
	PermanentDeleteOutgoingByChannel(channelId string) StoreChannel
374 375
	PermanentDeleteOutgoingByUser(userId string) StoreChannel
	UpdateOutgoing(hook *model.OutgoingWebhook) StoreChannel
376

377 378
	AnalyticsIncomingCount(teamId string) StoreChannel
	AnalyticsOutgoingCount(teamId string) StoreChannel
379
	InvalidateWebhookCache(webhook string)
380
	ClearCaches()
JoramWilander's avatar
JoramWilander committed
381
}
382

383 384 385 386
type CommandStore interface {
	Save(webhook *model.Command) StoreChannel
	Get(id string) StoreChannel
	GetByTeam(teamId string) StoreChannel
387
	GetByTrigger(teamId string, trigger string) StoreChannel
388
	Delete(commandId string, time int64) StoreChannel
389
	PermanentDeleteByTeam(teamId string) StoreChannel
390 391
	PermanentDeleteByUser(userId string) StoreChannel
	Update(hook *model.Command) StoreChannel
392
	AnalyticsCommandCount(teamId string) StoreChannel
393 394
}

395 396 397 398 399 400 401
type CommandWebhookStore interface {
	Save(webhook *model.CommandWebhook) StoreChannel
	Get(id string) StoreChannel
	TryUse(id string, limit int) StoreChannel
	Cleanup()
}

402
type PreferenceStore interface {
403 404 405 406
	Save(preferences *model.Preferences) StoreChannel
	Get(userId string, category string, name string) StoreChannel
	GetCategory(userId string, category string) StoreChannel
	GetAll(userId string) StoreChannel
407
	Delete(userId, category, name string) StoreChannel
enahum's avatar
enahum committed
408
	DeleteCategory(userId string, category string) StoreChannel
409
	DeleteCategoryAndName(category string, name string) StoreChannel
410 411
	PermanentDeleteByUser(userId string) StoreChannel
	IsFeatureEnabled(feature, userId string) StoreChannel
412
	CleanupFlagsBatch(limit int64) StoreChannel
Florian Orben's avatar
go fmt  
Florian Orben committed
413
}
414 415 416 417 418

type LicenseStore interface {
	Save(license *model.LicenseRecord) StoreChannel
	Get(id string) StoreChannel
}
419

420 421 422 423 424
type TokenStore interface {
	Save(recovery *model.Token) StoreChannel
	Delete(token string) StoreChannel
	GetByToken(token string) StoreChannel
	Cleanup()
425
}
426 427 428

type EmojiStore interface {
	Save(emoji *model.Emoji) StoreChannel
Corey Hulen's avatar
Corey Hulen committed
429
	Get(id string, allowFromCache bool) StoreChannel
430
	GetByName(name string) StoreChannel
431
	GetMultipleByName(names []string) StoreChannel
432
	GetList(offset, limit int, sort string) StoreChannel
433
	Delete(id string, time int64) StoreChannel
434
	Search(name string, prefixOnly bool, limit int) StoreChannel
435
}
436 437 438 439

type StatusStore interface {
	SaveOrUpdate(status *model.Status) StoreChannel
	Get(userId string) StoreChannel
440
	GetByIds(userIds []string) StoreChannel
441
	GetOnlineAway() StoreChannel
442
	GetOnline() StoreChannel
443
	GetAllFromTeam(teamId string) StoreChannel
444 445 446 447
	ResetAll() StoreChannel
	GetTotalActiveUsersCount() StoreChannel
	UpdateLastActivityAt(userId string, lastActivityAt int64) StoreChannel
}
448 449 450 451 452

type FileInfoStore interface {
	Save(info *model.FileInfo) StoreChannel
	Get(id string) StoreChannel
	GetByPath(path string) StoreChannel
453
	GetForPost(postId string, readFromMaster bool, allowFromCache bool) StoreChannel
454
	GetForUser(userId string) StoreChannel
455
	InvalidateFileInfosForPostCache(postId string)
456 457
	AttachToPost(fileId string, postId string) StoreChannel
	DeleteForPost(postId string) StoreChannel
458
	PermanentDelete(fileId string) StoreChannel
459
	PermanentDeleteBatch(endTime int64, limit int64) StoreChannel
460
	PermanentDeleteByUser(userId string) StoreChannel
461
	ClearCaches()
462
}
463 464 465 466

type ReactionStore interface {
	Save(reaction *model.Reaction) StoreChannel
	Delete(reaction *model.Reaction) StoreChannel
467
	GetForPost(postId string, allowFromCache bool) StoreChannel
468
	DeleteAllWithEmojiName(emojiName string) StoreChannel
469
	PermanentDeleteBatch(endTime int64, limit int64) StoreChannel
470
}
471

472 473 474 475 476
type JobStore interface {
	Save(job *model.Job) StoreChannel
	UpdateOptimistically(job *model.Job, currentStatus string) StoreChannel
	UpdateStatus(id string, status string) StoreChannel
	UpdateStatusOptimistically(id string, currentStatus string, newStatus string) StoreChannel
477
	Get(id string) StoreChannel
478
	GetAllPage(offset int, limit int) StoreChannel
479 480
	GetAllByType(jobType string) StoreChannel
	GetAllByTypePage(jobType string, offset int, limit int) StoreChannel
481
	GetAllByStatus(status string) StoreChannel
482 483
	GetNewestJobByStatusAndType(status string, jobType string) StoreChannel
	GetCountByStatusAndType(status string, jobType string) StoreChannel
484 485
	Delete(id string) StoreChannel
}
486 487 488 489 490 491

type UserAccessTokenStore interface {
	Save(token *model.UserAccessToken) StoreChannel
	Delete(tokenId string) StoreChannel
	DeleteAllForUser(userId string) StoreChannel
	Get(tokenId string) StoreChannel
492
	GetAll(offset int, limit int) StoreChannel
493 494
	GetByToken(tokenString string) StoreChannel
	GetByUser(userId string, page, perPage int) StoreChannel
495
	Search(term string) StoreChannel
496 497
	UpdateTokenEnable(tokenId string) StoreChannel
	UpdateTokenDisable(tokenId string) StoreChannel
498
}
499 500 501 502 503

type PluginStore interface {
	SaveOrUpdate(keyVal *model.PluginKeyValue) StoreChannel
	Get(pluginId, key string) StoreChannel
	Delete(pluginId, key string) StoreChannel
Daniel Schalla's avatar
Daniel Schalla committed
504 505
	DeleteAllForPlugin(PluginId string) StoreChannel
	DeleteAllExpired() StoreChannel
506
	List(pluginId string, page, perPage int) StoreChannel
507
}
508 509 510 511 512 513

type RoleStore interface {
	Save(role *model.Role) StoreChannel
	Get(roleId string) StoreChannel
	GetByName(name string) StoreChannel
	GetByNames(names []string) StoreChannel
514
	Delete(roldId string) StoreChannel
515
	PermanentDeleteAll() StoreChannel
516
}
517 518 519 520

type SchemeStore interface {
	Save(scheme *model.Scheme) StoreChannel
	Get(schemeId string) StoreChannel
521
	GetByName(schemeName string) StoreChannel
522
	GetAllPage(scope string, offset int, limit int) StoreChannel
523
	Delete(schemeId string) StoreChannel
524
	PermanentDeleteAll() StoreChannel
525
}
526

527 528
type TermsOfServiceStore interface {
	Save(termsOfService *model.TermsOfService) StoreChannel
529 530 531
	GetLatest(allowFromCache bool) StoreChannel
	Get(id string, allowFromCache bool) StoreChannel
}
532 533 534 535 536 537

type UserTermsOfServiceStore interface {
	GetByUser(userId string) StoreChannel
	Save(userTermsOfService *model.UserTermsOfService) StoreChannel
	Delete(userId, termsOfServiceId string) StoreChannel
}