github.com/spreadshirt/mattermost-server@v5.3.2-0.20180927191755-a257d501df3d+incompatible/store/store.go (about)

     1  // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
     2  // See License.txt for license information.
     3  
     4  package store
     5  
     6  import (
     7  	"time"
     8  
     9  	"github.com/mattermost/mattermost-server/model"
    10  )
    11  
    12  type StoreResult struct {
    13  	Data interface{}
    14  	Err  *model.AppError
    15  }
    16  
    17  type StoreChannel chan StoreResult
    18  
    19  func Do(f func(result *StoreResult)) StoreChannel {
    20  	storeChannel := make(StoreChannel, 1)
    21  	go func() {
    22  		result := StoreResult{}
    23  		f(&result)
    24  		storeChannel <- result
    25  		close(storeChannel)
    26  	}()
    27  	return storeChannel
    28  }
    29  
    30  func Must(sc StoreChannel) interface{} {
    31  	r := <-sc
    32  	if r.Err != nil {
    33  
    34  		time.Sleep(time.Second)
    35  		panic(r.Err)
    36  	}
    37  
    38  	return r.Data
    39  }
    40  
    41  type Store interface {
    42  	Team() TeamStore
    43  	Channel() ChannelStore
    44  	Post() PostStore
    45  	User() UserStore
    46  	Audit() AuditStore
    47  	ClusterDiscovery() ClusterDiscoveryStore
    48  	Compliance() ComplianceStore
    49  	Session() SessionStore
    50  	OAuth() OAuthStore
    51  	System() SystemStore
    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  	ServiceTerms() ServiceTermsStore
    69  	MarkSystemRanUnitTests()
    70  	Close()
    71  	LockToMaster()
    72  	UnlockFromMaster()
    73  	DropAllTables()
    74  	TotalMasterDbConnections() int
    75  	TotalReadDbConnections() int
    76  	TotalSearchDbConnections() int
    77  }
    78  
    79  type TeamStore interface {
    80  	Save(team *model.Team) StoreChannel
    81  	Update(team *model.Team) StoreChannel
    82  	UpdateDisplayName(name string, teamId string) StoreChannel
    83  	Get(id string) StoreChannel
    84  	GetByName(name string) StoreChannel
    85  	SearchByName(name string) StoreChannel
    86  	SearchAll(term string) StoreChannel
    87  	SearchOpen(term string) StoreChannel
    88  	GetAll() StoreChannel
    89  	GetAllPage(offset int, limit int) StoreChannel
    90  	GetAllTeamListing() StoreChannel
    91  	GetAllTeamPageListing(offset int, limit int) StoreChannel
    92  	GetTeamsByUserId(userId string) StoreChannel
    93  	GetByInviteId(inviteId string) StoreChannel
    94  	PermanentDelete(teamId string) StoreChannel
    95  	AnalyticsTeamCount() StoreChannel
    96  	SaveMember(member *model.TeamMember, maxUsersPerTeam int) StoreChannel
    97  	UpdateMember(member *model.TeamMember) StoreChannel
    98  	GetMember(teamId string, userId string) StoreChannel
    99  	GetMembers(teamId string, offset int, limit int) StoreChannel
   100  	GetMembersByIds(teamId string, userIds []string) StoreChannel
   101  	GetTotalMemberCount(teamId string) StoreChannel
   102  	GetActiveMemberCount(teamId string) StoreChannel
   103  	GetTeamsForUser(userId string) StoreChannel
   104  	GetChannelUnreadsForAllTeams(excludeTeamId, userId string) StoreChannel
   105  	GetChannelUnreadsForTeam(teamId, userId string) StoreChannel
   106  	RemoveMember(teamId string, userId string) StoreChannel
   107  	RemoveAllMembersByTeam(teamId string) StoreChannel
   108  	RemoveAllMembersByUser(userId string) StoreChannel
   109  	UpdateLastTeamIconUpdate(teamId string, curTime int64) StoreChannel
   110  	GetTeamsByScheme(schemeId string, offset int, limit int) StoreChannel
   111  	MigrateTeamMembers(fromTeamId string, fromUserId string) StoreChannel
   112  	ResetAllTeamSchemes() StoreChannel
   113  	ClearAllCustomRoleAssignments() StoreChannel
   114  	AnalyticsGetTeamCountForScheme(schemeId string) StoreChannel
   115  	GetAllForExportAfter(limit int, afterId string) StoreChannel
   116  	GetTeamMembersForExport(userId string) StoreChannel
   117  }
   118  
   119  type ChannelStore interface {
   120  	Save(channel *model.Channel, maxChannelsPerTeam int64) StoreChannel
   121  	CreateDirectChannel(userId string, otherUserId string) StoreChannel
   122  	SaveDirectChannel(channel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) StoreChannel
   123  	Update(channel *model.Channel) StoreChannel
   124  	Get(id string, allowFromCache bool) StoreChannel
   125  	InvalidateChannel(id string)
   126  	InvalidateChannelByName(teamId, name string)
   127  	GetFromMaster(id string) StoreChannel
   128  	Delete(channelId string, time int64) StoreChannel
   129  	Restore(channelId string, time int64) StoreChannel
   130  	SetDeleteAt(channelId string, deleteAt int64, updateAt int64) StoreChannel
   131  	PermanentDeleteByTeam(teamId string) StoreChannel
   132  	PermanentDelete(channelId string) StoreChannel
   133  	GetByName(team_id string, name string, allowFromCache bool) StoreChannel
   134  	GetByNames(team_id string, names []string, allowFromCache bool) StoreChannel
   135  	GetByNameIncludeDeleted(team_id string, name string, allowFromCache bool) StoreChannel
   136  	GetDeletedByName(team_id string, name string) StoreChannel
   137  	GetDeleted(team_id string, offset int, limit int) StoreChannel
   138  	GetChannels(teamId string, userId string, includeDeleted bool) StoreChannel
   139  	GetMoreChannels(teamId string, userId string, offset int, limit int) StoreChannel
   140  	GetPublicChannelsForTeam(teamId string, offset int, limit int) StoreChannel
   141  	GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) StoreChannel
   142  	GetChannelCounts(teamId string, userId string) StoreChannel
   143  	GetTeamChannels(teamId string) StoreChannel
   144  	GetAll(teamId string) StoreChannel
   145  	GetForPost(postId string) StoreChannel
   146  	SaveMember(member *model.ChannelMember) StoreChannel
   147  	UpdateMember(member *model.ChannelMember) StoreChannel
   148  	GetMembers(channelId string, offset, limit int) StoreChannel
   149  	GetMember(channelId string, userId string) StoreChannel
   150  	GetAllChannelMembersForUser(userId string, allowFromCache bool, includeDeleted bool) StoreChannel
   151  	InvalidateAllChannelMembersForUser(userId string)
   152  	IsUserInChannelUseCache(userId string, channelId string) bool
   153  	GetAllChannelMembersNotifyPropsForChannel(channelId string, allowFromCache bool) StoreChannel
   154  	InvalidateCacheForChannelMembersNotifyProps(channelId string)
   155  	GetMemberForPost(postId string, userId string) StoreChannel
   156  	InvalidateMemberCount(channelId string)
   157  	GetMemberCountFromCache(channelId string) int64
   158  	GetMemberCount(channelId string, allowFromCache bool) StoreChannel
   159  	GetPinnedPosts(channelId string) StoreChannel
   160  	RemoveMember(channelId string, userId string) StoreChannel
   161  	PermanentDeleteMembersByUser(userId string) StoreChannel
   162  	PermanentDeleteMembersByChannel(channelId string) StoreChannel
   163  	UpdateLastViewedAt(channelIds []string, userId string) StoreChannel
   164  	IncrementMentionCount(channelId string, userId string) StoreChannel
   165  	AnalyticsTypeCount(teamId string, channelType string) StoreChannel
   166  	GetMembersForUser(teamId string, userId string) StoreChannel
   167  	AutocompleteInTeam(teamId string, term string, includeDeleted bool) StoreChannel
   168  	AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) StoreChannel
   169  	SearchInTeam(teamId string, term string, includeDeleted bool) StoreChannel
   170  	SearchMore(userId string, teamId string, term string) StoreChannel
   171  	GetMembersByIds(channelId string, userIds []string) StoreChannel
   172  	AnalyticsDeletedTypeCount(teamId string, channelType string) StoreChannel
   173  	GetChannelUnread(channelId, userId string) StoreChannel
   174  	ClearCaches()
   175  	GetChannelsByScheme(schemeId string, offset int, limit int) StoreChannel
   176  	MigrateChannelMembers(fromChannelId string, fromUserId string) StoreChannel
   177  	ResetAllChannelSchemes() StoreChannel
   178  	ClearAllCustomRoleAssignments() StoreChannel
   179  	ResetLastPostAt() StoreChannel
   180  	MigratePublicChannels() error
   181  	DropPublicChannels() error
   182  	EnableExperimentalPublicChannelsMaterialization()
   183  	DisableExperimentalPublicChannelsMaterialization()
   184  	IsExperimentalPublicChannelsMaterializationEnabled() bool
   185  	GetAllChannelsForExportAfter(limit int, afterId string) StoreChannel
   186  	GetChannelMembersForExport(userId string, teamId string) StoreChannel
   187  }
   188  
   189  type ChannelMemberHistoryStore interface {
   190  	LogJoinEvent(userId string, channelId string, joinTime int64) StoreChannel
   191  	LogLeaveEvent(userId string, channelId string, leaveTime int64) StoreChannel
   192  	GetUsersInChannelDuring(startTime int64, endTime int64, channelId string) StoreChannel
   193  	PermanentDeleteBatch(endTime int64, limit int64) StoreChannel
   194  }
   195  
   196  type PostStore interface {
   197  	Save(post *model.Post) StoreChannel
   198  	Update(newPost *model.Post, oldPost *model.Post) StoreChannel
   199  	Get(id string) StoreChannel
   200  	GetSingle(id string) StoreChannel
   201  	Delete(postId string, time int64, deleteByID string) StoreChannel
   202  	PermanentDeleteByUser(userId string) StoreChannel
   203  	PermanentDeleteByChannel(channelId string) StoreChannel
   204  	GetPosts(channelId string, offset int, limit int, allowFromCache bool) StoreChannel
   205  	GetFlaggedPosts(userId string, offset int, limit int) StoreChannel
   206  	GetFlaggedPostsForTeam(userId, teamId string, offset int, limit int) StoreChannel
   207  	GetFlaggedPostsForChannel(userId, channelId string, offset int, limit int) StoreChannel
   208  	GetPostsBefore(channelId string, postId string, numPosts int, offset int) StoreChannel
   209  	GetPostsAfter(channelId string, postId string, numPosts int, offset int) StoreChannel
   210  	GetPostsSince(channelId string, time int64, allowFromCache bool) StoreChannel
   211  	GetEtag(channelId string, allowFromCache bool) StoreChannel
   212  	Search(teamId string, userId string, params *model.SearchParams) StoreChannel
   213  	AnalyticsUserCountsWithPostsByDay(teamId string) StoreChannel
   214  	AnalyticsPostCountsByDay(teamId string) StoreChannel
   215  	AnalyticsPostCount(teamId string, mustHaveFile bool, mustHaveHashtag bool) StoreChannel
   216  	ClearCaches()
   217  	InvalidateLastPostTimeCache(channelId string)
   218  	GetPostsCreatedAt(channelId string, time int64) StoreChannel
   219  	Overwrite(post *model.Post) StoreChannel
   220  	GetPostsByIds(postIds []string) StoreChannel
   221  	GetPostsBatchForIndexing(startTime int64, endTime int64, limit int) StoreChannel
   222  	PermanentDeleteBatch(endTime int64, limit int64) StoreChannel
   223  	GetOldest() StoreChannel
   224  	GetMaxPostSize() StoreChannel
   225  	GetParentsForExportAfter(limit int, afterId string) StoreChannel
   226  	GetRepliesForExport(parentId string) StoreChannel
   227  }
   228  
   229  type UserStore interface {
   230  	Save(user *model.User) StoreChannel
   231  	Update(user *model.User, allowRoleUpdate bool) StoreChannel
   232  	UpdateLastPictureUpdate(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
   236  	UpdateMfaSecret(userId, secret string) StoreChannel
   237  	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  	GetProfilesByUsernames(usernames []string, teamId string) StoreChannel
   249  	GetAllProfiles(offset int, limit int) StoreChannel
   250  	GetProfiles(teamId string, offset int, limit int) StoreChannel
   251  	GetProfileByIds(userId []string, allowFromCache bool) StoreChannel
   252  	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  	GetEtagForProfiles(teamId string) StoreChannel
   261  	UpdateFailedPasswordAttempts(userId string, attempts int) StoreChannel
   262  	GetTotalUsersCount() StoreChannel
   263  	GetSystemAdminProfiles() StoreChannel
   264  	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  	GetRecentlyActiveUsersForTeam(teamId string, offset, limit int) StoreChannel
   271  	GetNewUsersForTeam(teamId string, offset, limit int) StoreChannel
   272  	Search(teamId string, term string, options map[string]bool) StoreChannel
   273  	SearchNotInTeam(notInTeamId string, term string, options map[string]bool) StoreChannel
   274  	SearchInChannel(channelId string, term string, options map[string]bool) StoreChannel
   275  	SearchNotInChannel(teamId string, channelId string, term string, options map[string]bool) StoreChannel
   276  	SearchWithoutTeam(term string, options map[string]bool) StoreChannel
   277  	AnalyticsGetInactiveUsersCount() StoreChannel
   278  	AnalyticsGetSystemAdminCount() StoreChannel
   279  	GetProfilesNotInTeam(teamId string, offset int, limit int) StoreChannel
   280  	GetEtagForProfilesNotInTeam(teamId string) StoreChannel
   281  	ClearAllCustomRoleAssignments() StoreChannel
   282  	InferSystemInstallDate() StoreChannel
   283  	GetAllAfter(limit int, afterId string) StoreChannel
   284  }
   285  
   286  type SessionStore interface {
   287  	Save(session *model.Session) StoreChannel
   288  	Get(sessionIdOrToken string) StoreChannel
   289  	GetSessions(userId string) StoreChannel
   290  	GetSessionsWithActiveDeviceIds(userId string) StoreChannel
   291  	Remove(sessionIdOrToken string) StoreChannel
   292  	RemoveAllSessions() StoreChannel
   293  	PermanentDeleteSessionsByUser(teamId string) StoreChannel
   294  	UpdateLastActivityAt(sessionId string, time int64) StoreChannel
   295  	UpdateRoles(userId string, roles string) StoreChannel
   296  	UpdateDeviceId(id string, deviceId string, expiresAt int64) StoreChannel
   297  	AnalyticsSessionCount() StoreChannel
   298  	Cleanup(expiryTime int64, batchSize int64)
   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
   306  }
   307  
   308  type ClusterDiscoveryStore interface {
   309  	Save(discovery *model.ClusterDiscovery) StoreChannel
   310  	Delete(discovery *model.ClusterDiscovery) StoreChannel
   311  	Exists(discovery *model.ClusterDiscovery) StoreChannel
   312  	GetAll(discoveryType, clusterName string) StoreChannel
   313  	SetLastPingAt(discovery *model.ClusterDiscovery) StoreChannel
   314  	Cleanup() StoreChannel
   315  }
   316  
   317  type ComplianceStore interface {
   318  	Save(compliance *model.Compliance) StoreChannel
   319  	Update(compliance *model.Compliance) StoreChannel
   320  	Get(id string) StoreChannel
   321  	GetAll(offset, limit int) StoreChannel
   322  	ComplianceExport(compliance *model.Compliance) StoreChannel
   323  	MessageExport(after int64, limit int) StoreChannel
   324  }
   325  
   326  type OAuthStore interface {
   327  	SaveApp(app *model.OAuthApp) StoreChannel
   328  	UpdateApp(app *model.OAuthApp) StoreChannel
   329  	GetApp(id string) StoreChannel
   330  	GetAppByUser(userId string, offset, limit int) StoreChannel
   331  	GetApps(offset, limit int) StoreChannel
   332  	GetAuthorizedApps(userId string, offset, limit int) StoreChannel
   333  	DeleteApp(id string) StoreChannel
   334  	SaveAuthData(authData *model.AuthData) StoreChannel
   335  	GetAuthData(code string) StoreChannel
   336  	RemoveAuthData(code string) StoreChannel
   337  	PermanentDeleteAuthDataByUser(userId string) StoreChannel
   338  	SaveAccessData(accessData *model.AccessData) StoreChannel
   339  	UpdateAccessData(accessData *model.AccessData) StoreChannel
   340  	GetAccessData(token string) StoreChannel
   341  	GetAccessDataByUserForApp(userId, clientId string) StoreChannel
   342  	GetAccessDataByRefreshToken(token string) StoreChannel
   343  	GetPreviousAccessData(userId, clientId string) StoreChannel
   344  	RemoveAccessData(token string) StoreChannel
   345  }
   346  
   347  type SystemStore interface {
   348  	Save(system *model.System) StoreChannel
   349  	SaveOrUpdate(system *model.System) StoreChannel
   350  	Update(system *model.System) StoreChannel
   351  	Get() StoreChannel
   352  	GetByName(name string) StoreChannel
   353  	PermanentDeleteByName(name string) StoreChannel
   354  }
   355  
   356  type WebhookStore interface {
   357  	SaveIncoming(webhook *model.IncomingWebhook) StoreChannel
   358  	GetIncoming(id string, allowFromCache bool) StoreChannel
   359  	GetIncomingList(offset, limit int) StoreChannel
   360  	GetIncomingByTeam(teamId string, offset, limit int) StoreChannel
   361  	UpdateIncoming(webhook *model.IncomingWebhook) StoreChannel
   362  	GetIncomingByChannel(channelId string) StoreChannel
   363  	DeleteIncoming(webhookId string, time int64) StoreChannel
   364  	PermanentDeleteIncomingByChannel(channelId string) StoreChannel
   365  	PermanentDeleteIncomingByUser(userId string) StoreChannel
   366  
   367  	SaveOutgoing(webhook *model.OutgoingWebhook) StoreChannel
   368  	GetOutgoing(id string) StoreChannel
   369  	GetOutgoingList(offset, limit int) StoreChannel
   370  	GetOutgoingByChannel(channelId string, offset, limit int) StoreChannel
   371  	GetOutgoingByTeam(teamId string, offset, limit int) StoreChannel
   372  	DeleteOutgoing(webhookId string, time int64) StoreChannel
   373  	PermanentDeleteOutgoingByChannel(channelId string) StoreChannel
   374  	PermanentDeleteOutgoingByUser(userId string) StoreChannel
   375  	UpdateOutgoing(hook *model.OutgoingWebhook) StoreChannel
   376  
   377  	AnalyticsIncomingCount(teamId string) StoreChannel
   378  	AnalyticsOutgoingCount(teamId string) StoreChannel
   379  	InvalidateWebhookCache(webhook string)
   380  	ClearCaches()
   381  }
   382  
   383  type CommandStore interface {
   384  	Save(webhook *model.Command) StoreChannel
   385  	Get(id string) StoreChannel
   386  	GetByTeam(teamId string) StoreChannel
   387  	GetByTrigger(teamId string, trigger string) StoreChannel
   388  	Delete(commandId string, time int64) StoreChannel
   389  	PermanentDeleteByTeam(teamId string) StoreChannel
   390  	PermanentDeleteByUser(userId string) StoreChannel
   391  	Update(hook *model.Command) StoreChannel
   392  	AnalyticsCommandCount(teamId string) StoreChannel
   393  }
   394  
   395  type CommandWebhookStore interface {
   396  	Save(webhook *model.CommandWebhook) StoreChannel
   397  	Get(id string) StoreChannel
   398  	TryUse(id string, limit int) StoreChannel
   399  	Cleanup()
   400  }
   401  
   402  type PreferenceStore interface {
   403  	Save(preferences *model.Preferences) StoreChannel
   404  	Get(userId string, category string, name string) StoreChannel
   405  	GetCategory(userId string, category string) StoreChannel
   406  	GetAll(userId string) StoreChannel
   407  	Delete(userId, category, name string) StoreChannel
   408  	DeleteCategory(userId string, category string) StoreChannel
   409  	DeleteCategoryAndName(category string, name string) StoreChannel
   410  	PermanentDeleteByUser(userId string) StoreChannel
   411  	IsFeatureEnabled(feature, userId string) StoreChannel
   412  	CleanupFlagsBatch(limit int64) StoreChannel
   413  }
   414  
   415  type LicenseStore interface {
   416  	Save(license *model.LicenseRecord) StoreChannel
   417  	Get(id string) StoreChannel
   418  }
   419  
   420  type TokenStore interface {
   421  	Save(recovery *model.Token) StoreChannel
   422  	Delete(token string) StoreChannel
   423  	GetByToken(token string) StoreChannel
   424  	Cleanup()
   425  }
   426  
   427  type EmojiStore interface {
   428  	Save(emoji *model.Emoji) StoreChannel
   429  	Get(id string, allowFromCache bool) StoreChannel
   430  	GetByName(name string) StoreChannel
   431  	GetList(offset, limit int, sort string) StoreChannel
   432  	Delete(id string, time int64) StoreChannel
   433  	Search(name string, prefixOnly bool, limit int) StoreChannel
   434  }
   435  
   436  type StatusStore interface {
   437  	SaveOrUpdate(status *model.Status) StoreChannel
   438  	Get(userId string) StoreChannel
   439  	GetByIds(userIds []string) StoreChannel
   440  	GetOnlineAway() StoreChannel
   441  	GetOnline() StoreChannel
   442  	GetAllFromTeam(teamId string) StoreChannel
   443  	ResetAll() StoreChannel
   444  	GetTotalActiveUsersCount() StoreChannel
   445  	UpdateLastActivityAt(userId string, lastActivityAt int64) StoreChannel
   446  }
   447  
   448  type FileInfoStore interface {
   449  	Save(info *model.FileInfo) StoreChannel
   450  	Get(id string) StoreChannel
   451  	GetByPath(path string) StoreChannel
   452  	GetForPost(postId string, readFromMaster bool, allowFromCache bool) StoreChannel
   453  	GetForUser(userId string) StoreChannel
   454  	InvalidateFileInfosForPostCache(postId string)
   455  	AttachToPost(fileId string, postId string) StoreChannel
   456  	DeleteForPost(postId string) StoreChannel
   457  	PermanentDelete(fileId string) StoreChannel
   458  	PermanentDeleteBatch(endTime int64, limit int64) StoreChannel
   459  	PermanentDeleteByUser(userId string) StoreChannel
   460  	ClearCaches()
   461  }
   462  
   463  type ReactionStore interface {
   464  	Save(reaction *model.Reaction) StoreChannel
   465  	Delete(reaction *model.Reaction) StoreChannel
   466  	GetForPost(postId string, allowFromCache bool) StoreChannel
   467  	DeleteAllWithEmojiName(emojiName string) StoreChannel
   468  	PermanentDeleteBatch(endTime int64, limit int64) StoreChannel
   469  }
   470  
   471  type JobStore interface {
   472  	Save(job *model.Job) StoreChannel
   473  	UpdateOptimistically(job *model.Job, currentStatus string) StoreChannel
   474  	UpdateStatus(id string, status string) StoreChannel
   475  	UpdateStatusOptimistically(id string, currentStatus string, newStatus string) StoreChannel
   476  	Get(id string) StoreChannel
   477  	GetAllPage(offset int, limit int) StoreChannel
   478  	GetAllByType(jobType string) StoreChannel
   479  	GetAllByTypePage(jobType string, offset int, limit int) StoreChannel
   480  	GetAllByStatus(status string) StoreChannel
   481  	GetNewestJobByStatusAndType(status string, jobType string) StoreChannel
   482  	GetCountByStatusAndType(status string, jobType string) StoreChannel
   483  	Delete(id string) StoreChannel
   484  }
   485  
   486  type UserAccessTokenStore interface {
   487  	Save(token *model.UserAccessToken) StoreChannel
   488  	Delete(tokenId string) StoreChannel
   489  	DeleteAllForUser(userId string) StoreChannel
   490  	Get(tokenId string) StoreChannel
   491  	GetAll(offset int, limit int) StoreChannel
   492  	GetByToken(tokenString string) StoreChannel
   493  	GetByUser(userId string, page, perPage int) StoreChannel
   494  	Search(term string) StoreChannel
   495  	UpdateTokenEnable(tokenId string) StoreChannel
   496  	UpdateTokenDisable(tokenId string) StoreChannel
   497  }
   498  
   499  type PluginStore interface {
   500  	SaveOrUpdate(keyVal *model.PluginKeyValue) StoreChannel
   501  	Get(pluginId, key string) StoreChannel
   502  	Delete(pluginId, key string) StoreChannel
   503  }
   504  
   505  type RoleStore interface {
   506  	Save(role *model.Role) StoreChannel
   507  	Get(roleId string) StoreChannel
   508  	GetByName(name string) StoreChannel
   509  	GetByNames(names []string) StoreChannel
   510  	Delete(roldId string) StoreChannel
   511  	PermanentDeleteAll() StoreChannel
   512  }
   513  
   514  type SchemeStore interface {
   515  	Save(scheme *model.Scheme) StoreChannel
   516  	Get(schemeId string) StoreChannel
   517  	GetByName(schemeName string) StoreChannel
   518  	GetAllPage(scope string, offset int, limit int) StoreChannel
   519  	Delete(schemeId string) StoreChannel
   520  	PermanentDeleteAll() StoreChannel
   521  }
   522  
   523  type ServiceTermsStore interface {
   524  	Save(serviceTerms *model.ServiceTerms) StoreChannel
   525  	GetLatest(allowFromCache bool) StoreChannel
   526  	Get(id string, allowFromCache bool) StoreChannel
   527  }