diff options
author | Asaad Mahmood <Unknowngi@live.com> | 2015-09-09 10:56:48 +0500 |
---|---|---|
committer | Asaad Mahmood <Unknowngi@live.com> | 2015-09-09 10:56:48 +0500 |
commit | c7692a800ef43b63866b6f470b72eb1c3816484f (patch) | |
tree | 801314957491080f83789335f64fb979292529d9 /store | |
parent | 8c9c6de97041f8b2d646a7b4f03852c74e8e8fab (diff) | |
parent | 64d4890a4109618b383f7cfe1acc541bd72a0899 (diff) | |
download | chat-c7692a800ef43b63866b6f470b72eb1c3816484f.tar.gz chat-c7692a800ef43b63866b6f470b72eb1c3816484f.tar.bz2 chat-c7692a800ef43b63866b6f470b72eb1c3816484f.zip |
Merge branch 'master' of https://github.com/mattermost/platform into ui-changes
Diffstat (limited to 'store')
-rw-r--r-- | store/sql_channel_store.go | 22 | ||||
-rw-r--r-- | store/sql_post_store.go | 24 | ||||
-rw-r--r-- | store/sql_team_store.go | 20 | ||||
-rw-r--r-- | store/sql_user_store.go | 27 | ||||
-rw-r--r-- | store/store.go | 4 |
5 files changed, 97 insertions, 0 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go index d2e3943df..b58166fd6 100644 --- a/store/sql_channel_store.go +++ b/store/sql_channel_store.go @@ -678,3 +678,25 @@ func (s SqlChannelStore) UpdateNotifyLevel(channelId, userId, notifyLevel string return storeChannel } + +func (s SqlChannelStore) GetForExport(teamId string) StoreChannel { + storeChannel := make(StoreChannel) + + go func() { + result := StoreResult{} + + var data []*model.Channel + _, err := s.GetReplica().Select(&data, "SELECT * FROM Channels WHERE TeamId = :TeamId AND DeleteAt = 0 AND Type = 'O'", map[string]interface{}{"TeamId": teamId}) + + if err != nil { + result.Err = model.NewAppError("SqlChannelStore.GetAllChannels", "We couldn't get all the channels", "teamId="+teamId+", err="+err.Error()) + } else { + result.Data = data + } + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} diff --git a/store/sql_post_store.go b/store/sql_post_store.go index 297d60397..20de23eb7 100644 --- a/store/sql_post_store.go +++ b/store/sql_post_store.go @@ -506,3 +506,27 @@ func (s SqlPostStore) Search(teamId string, userId string, terms string, isHasht return storeChannel } + +func (s SqlPostStore) GetForExport(channelId string) StoreChannel { + storeChannel := make(StoreChannel) + + go func() { + result := StoreResult{} + + var posts []*model.Post + _, err := s.GetReplica().Select( + &posts, + "SELECT * FROM Posts WHERE ChannelId = :ChannelId AND DeleteAt = 0", + map[string]interface{}{"ChannelId": channelId}) + if err != nil { + result.Err = model.NewAppError("SqlPostStore.GetForExport", "We couldn't get the posts for the channel", "channelId="+channelId+err.Error()) + } else { + result.Data = posts + } + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} diff --git a/store/sql_team_store.go b/store/sql_team_store.go index 2784f8630..fcbcaab9f 100644 --- a/store/sql_team_store.go +++ b/store/sql_team_store.go @@ -193,3 +193,23 @@ func (s SqlTeamStore) GetTeamsForEmail(email string) StoreChannel { return storeChannel } + +func (s SqlTeamStore) GetForExport() StoreChannel { + storeChannel := make(StoreChannel) + + go func() { + result := StoreResult{} + + var data []*model.Team + if _, err := s.GetReplica().Select(&data, "SELECT * FROM Teams"); err != nil { + result.Err = model.NewAppError("SqlTeamStore.GetForExport", "We could not get all teams", err.Error()) + } + + result.Data = data + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} diff --git a/store/sql_user_store.go b/store/sql_user_store.go index 64a18545a..be1d29df0 100644 --- a/store/sql_user_store.go +++ b/store/sql_user_store.go @@ -452,3 +452,30 @@ func (us SqlUserStore) VerifyEmail(userId string) StoreChannel { return storeChannel } + +func (us SqlUserStore) GetForExport(teamId string) StoreChannel { + + storeChannel := make(StoreChannel) + + go func() { + result := StoreResult{} + + var users []*model.User + + if _, err := us.GetReplica().Select(&users, "SELECT * FROM Users WHERE TeamId = :TeamId", map[string]interface{}{"TeamId": teamId}); err != nil { + result.Err = model.NewAppError("SqlUserStore.GetProfiles", "We encounted an error while finding user profiles", err.Error()) + } else { + for _, u := range users { + u.Password = "" + u.AuthData = "" + } + + result.Data = users + } + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} diff --git a/store/store.go b/store/store.go index 271caa366..959e93fa4 100644 --- a/store/store.go +++ b/store/store.go @@ -44,6 +44,7 @@ type TeamStore interface { Get(id string) StoreChannel GetByName(name string) StoreChannel GetTeamsForEmail(domain string) StoreChannel + GetForExport() StoreChannel } type ChannelStore interface { @@ -55,6 +56,7 @@ type ChannelStore interface { GetChannels(teamId string, userId string) StoreChannel GetMoreChannels(teamId string, userId string) StoreChannel GetChannelCounts(teamId string, userId string) StoreChannel + GetForExport(teamId string) StoreChannel SaveMember(member *model.ChannelMember) StoreChannel GetMembers(channelId string) StoreChannel @@ -78,6 +80,7 @@ type PostStore interface { GetPostsSince(channelId string, time int64) StoreChannel GetEtag(channelId string) StoreChannel Search(teamId string, userId string, terms string, isHashtagSearch bool) StoreChannel + GetForExport(channelId string) StoreChannel } type UserStore interface { @@ -96,6 +99,7 @@ type UserStore interface { VerifyEmail(userId string) StoreChannel GetEtagForProfiles(teamId string) StoreChannel UpdateFailedPasswordAttempts(userId string, attempts int) StoreChannel + GetForExport(teamId string) StoreChannel } type SessionStore interface { |