From 11c035aef45fbc6dfbc360123611108a199eca79 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Wed, 20 Jan 2016 10:04:17 -0600 Subject: PLT-7 adding loc db calls for oauth table --- store/sql_channel_store.go | 83 +++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 41 deletions(-) (limited to 'store/sql_channel_store.go') diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go index 4585647de..d85969b21 100644 --- a/store/sql_channel_store.go +++ b/store/sql_channel_store.go @@ -7,6 +7,7 @@ import ( "github.com/go-gorp/gorp" "github.com/mattermost/platform/model" "github.com/mattermost/platform/utils" + goi18n "github.com/nicksnyder/go-i18n/i18n" ) type SqlChannelStore struct { @@ -49,7 +50,7 @@ func (s SqlChannelStore) CreateIndexesIfNotExists() { s.CreateIndexIfNotExists("idx_channelmembers_user_id", "ChannelMembers", "UserId") } -func (s SqlChannelStore) Save(channel *model.Channel) StoreChannel { +func (s SqlChannelStore) Save(T goi18n.TranslateFunc, channel *model.Channel) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -60,7 +61,7 @@ func (s SqlChannelStore) Save(channel *model.Channel) StoreChannel { if transaction, err := s.GetMaster().Begin(); err != nil { result.Err = model.NewAppError("SqlChannelStore.Save", "Unable to open transaction", err.Error()) } else { - result = s.saveChannelT(transaction, channel) + result = s.saveChannelT(T, transaction, channel) if result.Err != nil { transaction.Rollback() } else { @@ -78,7 +79,7 @@ func (s SqlChannelStore) Save(channel *model.Channel) StoreChannel { return storeChannel } -func (s SqlChannelStore) SaveDirectChannel(directchannel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) StoreChannel { +func (s SqlChannelStore) SaveDirectChannel(T goi18n.TranslateFunc, directchannel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -90,7 +91,7 @@ func (s SqlChannelStore) SaveDirectChannel(directchannel *model.Channel, member1 if transaction, err := s.GetMaster().Begin(); err != nil { result.Err = model.NewAppError("SqlChannelStore.SaveDirectChannel", "Unable to open transaction", err.Error()) } else { - channelResult := s.saveChannelT(transaction, directchannel) + channelResult := s.saveChannelT(T, transaction, directchannel) if channelResult.Err != nil { transaction.Rollback() @@ -101,8 +102,8 @@ func (s SqlChannelStore) SaveDirectChannel(directchannel *model.Channel, member1 member1.ChannelId = newChannel.Id member2.ChannelId = newChannel.Id - member1Result := s.saveMemberT(transaction, member1, newChannel) - member2Result := s.saveMemberT(transaction, member2, newChannel) + member1Result := s.saveMemberT(T, transaction, member1, newChannel) + member2Result := s.saveMemberT(T, transaction, member2, newChannel) if member1Result.Err != nil || member2Result.Err != nil { transaction.Rollback() @@ -132,7 +133,7 @@ func (s SqlChannelStore) SaveDirectChannel(directchannel *model.Channel, member1 return storeChannel } -func (s SqlChannelStore) saveChannelT(transaction *gorp.Transaction, channel *model.Channel) StoreResult { +func (s SqlChannelStore) saveChannelT(T goi18n.TranslateFunc, transaction *gorp.Transaction, channel *model.Channel) StoreResult { result := StoreResult{} if len(channel.Id) > 0 { @@ -174,7 +175,7 @@ func (s SqlChannelStore) saveChannelT(transaction *gorp.Transaction, channel *mo return result } -func (s SqlChannelStore) Update(channel *model.Channel) StoreChannel { +func (s SqlChannelStore) Update(T goi18n.TranslateFunc, channel *model.Channel) StoreChannel { storeChannel := make(StoreChannel) @@ -214,7 +215,7 @@ func (s SqlChannelStore) Update(channel *model.Channel) StoreChannel { return storeChannel } -func (s SqlChannelStore) extraUpdated(channel *model.Channel) StoreChannel { +func (s SqlChannelStore) extraUpdated(T goi18n.TranslateFunc, channel *model.Channel) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -242,15 +243,15 @@ func (s SqlChannelStore) extraUpdated(channel *model.Channel) StoreChannel { return storeChannel } -func (s SqlChannelStore) Get(id string) StoreChannel { - return s.get(id, false) +func (s SqlChannelStore) Get(T goi18n.TranslateFunc, id string) StoreChannel { + return s.get(T, id, false) } -func (s SqlChannelStore) GetFromMaster(id string) StoreChannel { - return s.get(id, true) +func (s SqlChannelStore) GetFromMaster(T goi18n.TranslateFunc, id string) StoreChannel { + return s.get(T, id, true) } -func (s SqlChannelStore) get(id string, master bool) StoreChannel { +func (s SqlChannelStore) get(T goi18n.TranslateFunc, id string, master bool) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -278,7 +279,7 @@ func (s SqlChannelStore) get(id string, master bool) StoreChannel { return storeChannel } -func (s SqlChannelStore) Delete(channelId string, time int64) StoreChannel { +func (s SqlChannelStore) Delete(T goi18n.TranslateFunc, channelId string, time int64) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -296,7 +297,7 @@ func (s SqlChannelStore) Delete(channelId string, time int64) StoreChannel { return storeChannel } -func (s SqlChannelStore) PermanentDeleteByTeam(teamId string) StoreChannel { +func (s SqlChannelStore) PermanentDeleteByTeam(T goi18n.TranslateFunc, teamId string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -318,7 +319,7 @@ type channelWithMember struct { model.ChannelMember } -func (s SqlChannelStore) GetChannels(teamId string, userId string) StoreChannel { +func (s SqlChannelStore) GetChannels(T goi18n.TranslateFunc, teamId string, userId string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -351,7 +352,7 @@ func (s SqlChannelStore) GetChannels(teamId string, userId string) StoreChannel return storeChannel } -func (s SqlChannelStore) GetMoreChannels(teamId string, userId string) StoreChannel { +func (s SqlChannelStore) GetMoreChannels(T goi18n.TranslateFunc, teamId string, userId string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -399,7 +400,7 @@ type channelIdWithCountAndUpdateAt struct { UpdateAt int64 } -func (s SqlChannelStore) GetChannelCounts(teamId string, userId string) StoreChannel { +func (s SqlChannelStore) GetChannelCounts(T goi18n.TranslateFunc, teamId string, userId string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -428,7 +429,7 @@ func (s SqlChannelStore) GetChannelCounts(teamId string, userId string) StoreCha return storeChannel } -func (s SqlChannelStore) GetByName(teamId string, name string) StoreChannel { +func (s SqlChannelStore) GetByName(T goi18n.TranslateFunc, teamId string, name string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -449,13 +450,13 @@ func (s SqlChannelStore) GetByName(teamId string, name string) StoreChannel { return storeChannel } -func (s SqlChannelStore) SaveMember(member *model.ChannelMember) StoreChannel { +func (s SqlChannelStore) SaveMember(T goi18n.TranslateFunc, member *model.ChannelMember) StoreChannel { storeChannel := make(StoreChannel) go func() { var result StoreResult // Grab the channel we are saving this member to - if cr := <-s.GetFromMaster(member.ChannelId); cr.Err != nil { + if cr := <-s.GetFromMaster(T, member.ChannelId); cr.Err != nil { result.Err = cr.Err } else { channel := cr.Data.(*model.Channel) @@ -463,7 +464,7 @@ func (s SqlChannelStore) SaveMember(member *model.ChannelMember) StoreChannel { if transaction, err := s.GetMaster().Begin(); err != nil { result.Err = model.NewAppError("SqlChannelStore.SaveMember", "Unable to open transaction", err.Error()) } else { - result = s.saveMemberT(transaction, member, channel) + result = s.saveMemberT(T, transaction, member, channel) if result.Err != nil { transaction.Rollback() } else { @@ -471,7 +472,7 @@ func (s SqlChannelStore) SaveMember(member *model.ChannelMember) StoreChannel { result.Err = model.NewAppError("SqlChannelStore.SaveMember", "Unable to commit transaction", err.Error()) } // If sucessfull record members have changed in channel - if mu := <-s.extraUpdated(channel); mu.Err != nil { + if mu := <-s.extraUpdated(T, channel); mu.Err != nil { result.Err = mu.Err } } @@ -485,7 +486,7 @@ func (s SqlChannelStore) SaveMember(member *model.ChannelMember) StoreChannel { return storeChannel } -func (s SqlChannelStore) saveMemberT(transaction *gorp.Transaction, member *model.ChannelMember, channel *model.Channel) StoreResult { +func (s SqlChannelStore) saveMemberT(T goi18n.TranslateFunc, transaction *gorp.Transaction, member *model.ChannelMember, channel *model.Channel) StoreResult { result := StoreResult{} member.PreSave() @@ -506,7 +507,7 @@ func (s SqlChannelStore) saveMemberT(transaction *gorp.Transaction, member *mode return result } -func (s SqlChannelStore) UpdateMember(member *model.ChannelMember) StoreChannel { +func (s SqlChannelStore) UpdateMember(T goi18n.TranslateFunc, member *model.ChannelMember) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -534,7 +535,7 @@ func (s SqlChannelStore) UpdateMember(member *model.ChannelMember) StoreChannel return storeChannel } -func (s SqlChannelStore) GetMembers(channelId string) StoreChannel { +func (s SqlChannelStore) GetMembers(T goi18n.TranslateFunc, channelId string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -555,7 +556,7 @@ func (s SqlChannelStore) GetMembers(channelId string) StoreChannel { return storeChannel } -func (s SqlChannelStore) GetMember(channelId string, userId string) StoreChannel { +func (s SqlChannelStore) GetMember(T goi18n.TranslateFunc, channelId string, userId string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -576,7 +577,7 @@ func (s SqlChannelStore) GetMember(channelId string, userId string) StoreChannel return storeChannel } -func (s SqlChannelStore) GetMemberCount(channelId string) StoreChannel { +func (s SqlChannelStore) GetMemberCount(T goi18n.TranslateFunc, channelId string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -596,7 +597,7 @@ func (s SqlChannelStore) GetMemberCount(channelId string) StoreChannel { return storeChannel } -func (s SqlChannelStore) GetExtraMembers(channelId string, limit int) StoreChannel { +func (s SqlChannelStore) GetExtraMembers(T goi18n.TranslateFunc, channelId string, limit int) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -627,14 +628,14 @@ func (s SqlChannelStore) GetExtraMembers(channelId string, limit int) StoreChann return storeChannel } -func (s SqlChannelStore) RemoveMember(channelId string, userId string) StoreChannel { +func (s SqlChannelStore) RemoveMember(T goi18n.TranslateFunc, channelId string, userId string) StoreChannel { storeChannel := make(StoreChannel) go func() { result := StoreResult{} // Grab the channel we are saving this member to - if cr := <-s.Get(channelId); cr.Err != nil { + if cr := <-s.Get(T, channelId); cr.Err != nil { result.Err = cr.Err } else { channel := cr.Data.(*model.Channel) @@ -644,7 +645,7 @@ func (s SqlChannelStore) RemoveMember(channelId string, userId string) StoreChan result.Err = model.NewAppError("SqlChannelStore.RemoveMember", "We couldn't remove the channel member", "channel_id="+channelId+", user_id="+userId+", "+err.Error()) } else { // If sucessfull record members have changed in channel - if mu := <-s.extraUpdated(channel); mu.Err != nil { + if mu := <-s.extraUpdated(T, channel); mu.Err != nil { result.Err = mu.Err } } @@ -657,7 +658,7 @@ func (s SqlChannelStore) RemoveMember(channelId string, userId string) StoreChan return storeChannel } -func (s SqlChannelStore) PermanentDeleteMembersByUser(userId string) StoreChannel { +func (s SqlChannelStore) PermanentDeleteMembersByUser(T goi18n.TranslateFunc, userId string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -674,7 +675,7 @@ func (s SqlChannelStore) PermanentDeleteMembersByUser(userId string) StoreChanne return storeChannel } -func (s SqlChannelStore) CheckPermissionsTo(teamId string, channelId string, userId string) StoreChannel { +func (s SqlChannelStore) CheckPermissionsTo(T goi18n.TranslateFunc, teamId string, channelId string, userId string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -706,7 +707,7 @@ func (s SqlChannelStore) CheckPermissionsTo(teamId string, channelId string, use return storeChannel } -func (s SqlChannelStore) CheckPermissionsToByName(teamId string, channelName string, userId string) StoreChannel { +func (s SqlChannelStore) CheckPermissionsToByName(T goi18n.TranslateFunc, teamId string, channelName string, userId string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -738,7 +739,7 @@ func (s SqlChannelStore) CheckPermissionsToByName(teamId string, channelName str return storeChannel } -func (s SqlChannelStore) CheckOpenChannelPermissions(teamId string, channelId string) StoreChannel { +func (s SqlChannelStore) CheckOpenChannelPermissions(T goi18n.TranslateFunc, teamId string, channelId string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -767,7 +768,7 @@ func (s SqlChannelStore) CheckOpenChannelPermissions(teamId string, channelId st return storeChannel } -func (s SqlChannelStore) UpdateLastViewedAt(channelId string, userId string) StoreChannel { +func (s SqlChannelStore) UpdateLastViewedAt(T goi18n.TranslateFunc, channelId string, userId string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -815,7 +816,7 @@ func (s SqlChannelStore) UpdateLastViewedAt(channelId string, userId string) Sto return storeChannel } -func (s SqlChannelStore) IncrementMentionCount(channelId string, userId string) StoreChannel { +func (s SqlChannelStore) IncrementMentionCount(T goi18n.TranslateFunc, channelId string, userId string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -841,7 +842,7 @@ func (s SqlChannelStore) IncrementMentionCount(channelId string, userId string) return storeChannel } -func (s SqlChannelStore) GetForExport(teamId string) StoreChannel { +func (s SqlChannelStore) GetForExport(T goi18n.TranslateFunc, teamId string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -863,7 +864,7 @@ func (s SqlChannelStore) GetForExport(teamId string) StoreChannel { return storeChannel } -func (s SqlChannelStore) AnalyticsTypeCount(teamId string, channelType string) StoreChannel { +func (s SqlChannelStore) AnalyticsTypeCount(T goi18n.TranslateFunc, teamId string, channelType string) StoreChannel { storeChannel := make(StoreChannel) go func() { -- cgit v1.2.3-1-g7c22