Files
mattermost/store/store.go

159 lines
5.2 KiB
Go
Raw Normal View History

// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
2015-06-14 23:53:32 -08:00
// See License.txt for license information.
package store
import (
2015-08-20 14:20:39 -07:00
l4g "code.google.com/p/log4go"
2015-06-14 23:53:32 -08:00
"github.com/mattermost/platform/model"
2015-08-20 14:20:39 -07:00
"time"
2015-06-14 23:53:32 -08:00
)
type StoreResult struct {
Data interface{}
Err *model.AppError
}
type StoreChannel chan StoreResult
2015-07-06 00:50:42 -08:00
func Must(sc StoreChannel) interface{} {
r := <-sc
if r.Err != nil {
2015-08-20 14:20:39 -07:00
l4g.Close()
time.Sleep(time.Second)
2015-07-06 00:50:42 -08:00
panic(r.Err)
}
return r.Data
}
2015-06-14 23:53:32 -08:00
type Store interface {
Team() TeamStore
Channel() ChannelStore
Post() PostStore
User() UserStore
Audit() AuditStore
Session() SessionStore
OAuth() OAuthStore
2015-09-16 19:59:57 -07:00
System() SystemStore
2015-09-21 14:22:23 -04:00
Webhook() WebhookStore
Preference() PreferenceStore
2015-06-14 23:53:32 -08:00
Close()
}
type TeamStore interface {
Save(team *model.Team) StoreChannel
Update(team *model.Team) StoreChannel
UpdateDisplayName(name string, teamId string) StoreChannel
2015-06-14 23:53:32 -08:00
Get(id string) StoreChannel
GetByName(name string) StoreChannel
2015-06-14 23:53:32 -08:00
GetTeamsForEmail(domain string) StoreChannel
GetAll() StoreChannel
2015-06-14 23:53:32 -08:00
}
type ChannelStore interface {
Save(channel *model.Channel) StoreChannel
Update(channel *model.Channel) StoreChannel
Get(id string) StoreChannel
Delete(channelId string, time int64) StoreChannel
GetByName(team_id string, domain string) StoreChannel
GetChannels(teamId string, userId string) StoreChannel
GetMoreChannels(teamId string, userId string) StoreChannel
GetChannelCounts(teamId string, userId string) StoreChannel
GetForExport(teamId string) StoreChannel
2015-06-14 23:53:32 -08:00
SaveMember(member *model.ChannelMember) StoreChannel
UpdateMember(member *model.ChannelMember) StoreChannel
2015-06-14 23:53:32 -08:00
GetMembers(channelId string) StoreChannel
GetMember(channelId string, userId string) StoreChannel
RemoveMember(channelId string, userId string) StoreChannel
GetExtraMembers(channelId string, limit int) StoreChannel
CheckPermissionsTo(teamId string, channelId string, userId string) StoreChannel
CheckOpenChannelPermissions(teamId string, channelId string) StoreChannel
CheckPermissionsToByName(teamId string, channelName string, userId string) StoreChannel
UpdateLastViewedAt(channelId string, userId string) StoreChannel
IncrementMentionCount(channelId string, userId string) StoreChannel
}
type PostStore interface {
Save(post *model.Post) StoreChannel
Update(post *model.Post, newMessage string, newHashtags string) StoreChannel
Get(id string) StoreChannel
Delete(postId string, time int64) StoreChannel
GetPosts(channelId string, offset int, limit int) StoreChannel
GetPostsSince(channelId string, time int64) StoreChannel
2015-06-14 23:53:32 -08:00
GetEtag(channelId string) StoreChannel
Search(teamId string, userId string, terms string, isHashtagSearch bool) StoreChannel
GetForExport(channelId string) StoreChannel
2015-06-14 23:53:32 -08:00
}
type UserStore interface {
Save(user *model.User) StoreChannel
Update(user *model.User, allowRoleUpdate bool) StoreChannel
2015-07-16 08:55:37 -07:00
UpdateLastPictureUpdate(userId string) StoreChannel
2015-06-14 23:53:32 -08:00
UpdateLastPingAt(userId string, time int64) StoreChannel
UpdateLastActivityAt(userId string, time int64) StoreChannel
UpdateUserAndSessionActivity(userId string, sessionId string, time int64) StoreChannel
UpdatePassword(userId, newPassword string) StoreChannel
Get(id string) StoreChannel
GetProfiles(teamId string) StoreChannel
GetByEmail(teamId string, email string) StoreChannel
GetByAuth(teamId string, authData string, authService string) StoreChannel
2015-06-14 23:53:32 -08:00
GetByUsername(teamId string, username string) StoreChannel
VerifyEmail(userId string) StoreChannel
GetEtagForProfiles(teamId string) StoreChannel
2015-07-29 01:26:10 -08:00
UpdateFailedPasswordAttempts(userId string, attempts int) StoreChannel
GetForExport(teamId string) StoreChannel
2015-09-23 15:52:59 -07:00
GetTotalUsersCount() StoreChannel
GetTotalActiveUsersCount() StoreChannel
2015-10-05 17:33:45 -07:00
GetSystemAdminProfiles() StoreChannel
2015-06-14 23:53:32 -08:00
}
type SessionStore interface {
Save(session *model.Session) StoreChannel
Get(sessionIdOrToken string) StoreChannel
2015-06-14 23:53:32 -08:00
GetSessions(userId string) StoreChannel
Remove(sessionIdOrToken string) StoreChannel
RemoveAllSessionsForTeam(teamId string) StoreChannel
2015-06-14 23:53:32 -08:00
UpdateLastActivityAt(sessionId string, time int64) StoreChannel
UpdateRoles(userId string, roles string) StoreChannel
2015-06-14 23:53:32 -08:00
}
type AuditStore interface {
Save(audit *model.Audit) StoreChannel
Get(user_id string, limit int) StoreChannel
}
type OAuthStore interface {
SaveApp(app *model.OAuthApp) StoreChannel
UpdateApp(app *model.OAuthApp) StoreChannel
GetApp(id string) StoreChannel
GetAppByUser(userId string) StoreChannel
SaveAuthData(authData *model.AuthData) StoreChannel
GetAuthData(code string) StoreChannel
RemoveAuthData(code string) StoreChannel
SaveAccessData(accessData *model.AccessData) StoreChannel
GetAccessData(token string) StoreChannel
GetAccessDataByAuthCode(authCode string) StoreChannel
RemoveAccessData(token string) StoreChannel
}
2015-09-16 19:59:57 -07:00
type SystemStore interface {
Save(system *model.System) StoreChannel
Update(system *model.System) StoreChannel
Get() StoreChannel
}
2015-09-21 14:22:23 -04:00
type WebhookStore interface {
SaveIncoming(webhook *model.IncomingWebhook) StoreChannel
GetIncoming(id string) StoreChannel
GetIncomingByUser(userId string) StoreChannel
DeleteIncoming(webhookId string, time int64) StoreChannel
}
type PreferenceStore interface {
Save(preferences *model.Preferences) StoreChannel
2015-10-13 11:52:17 -04:00
Get(userId string, category string, name string) StoreChannel
GetCategory(userId string, category string) StoreChannel
}