summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorCarlos Tadeu Panato Junior <ctadeu@gmail.com>2018-10-13 12:35:57 +0200
committerGitHub <noreply@github.com>2018-10-13 12:35:57 +0200
commit908ed5555f8a3d37cd057035b2792d66c8b7838a (patch)
tree7ad4248a72a7c3b6e6c3981840c5951c6108fe1d /store
parente87965f39d2ce6dbd0e7883c387956413c663f6a (diff)
downloadchat-908ed5555f8a3d37cd057035b2792d66c8b7838a.tar.gz
chat-908ed5555f8a3d37cd057035b2792d66c8b7838a.tar.bz2
chat-908ed5555f8a3d37cd057035b2792d66c8b7838a.zip
[APIv4] add getChannelMembersTimezone (#9286)
* add getChannelMembersTimezone * update per feedback review * add delimeter to error
Diffstat (limited to 'store')
-rw-r--r--store/sqlstore/channel_store.go23
-rw-r--r--store/store.go1
-rw-r--r--store/storetest/mocks/ChannelStore.go15
3 files changed, 38 insertions, 1 deletions
diff --git a/store/sqlstore/channel_store.go b/store/sqlstore/channel_store.go
index b1886c428..17ef6d4c9 100644
--- a/store/sqlstore/channel_store.go
+++ b/store/sqlstore/channel_store.go
@@ -1197,7 +1197,7 @@ func (s SqlChannelStore) GetMembers(channelId string, offset, limit int) store.S
var dbMembers channelMemberWithSchemeRolesList
_, err := s.GetReplica().Select(&dbMembers, CHANNEL_MEMBERS_WITH_SCHEME_SELECT_QUERY+"WHERE ChannelId = :ChannelId LIMIT :Limit OFFSET :Offset", map[string]interface{}{"ChannelId": channelId, "Limit": limit, "Offset": offset})
if err != nil {
- result.Err = model.NewAppError("SqlChannelStore.GetMembers", "store.sql_channel.get_members.app_error", nil, "channel_id="+channelId+err.Error(), http.StatusInternalServerError)
+ result.Err = model.NewAppError("SqlChannelStore.GetMembers", "store.sql_channel.get_members.app_error", nil, "channel_id="+channelId+","+err.Error(), http.StatusInternalServerError)
return
}
@@ -1205,6 +1205,27 @@ func (s SqlChannelStore) GetMembers(channelId string, offset, limit int) store.S
})
}
+func (s SqlChannelStore) GetChannelMembersTimezones(channelId string) store.StoreChannel {
+ return store.Do(func(result *store.StoreResult) {
+ var dbMembersTimezone []map[string]string
+ _, err := s.GetReplica().Select(&dbMembersTimezone, `
+ SELECT
+ Users.Timezone
+ FROM
+ ChannelMembers
+ LEFT JOIN
+ Users ON ChannelMembers.UserId = Id
+ WHERE ChannelId = :ChannelId
+ `, map[string]interface{}{
+ "ChannelId": channelId})
+ if err != nil {
+ result.Err = model.NewAppError("SqlChannelStore.GetChannelMembersTimezones", "store.sql_channel.get_members.app_error", nil, "channel_id="+channelId+","+err.Error(), http.StatusInternalServerError)
+ return
+ }
+ result.Data = dbMembersTimezone
+ })
+}
+
func (s SqlChannelStore) GetMember(channelId string, userId string) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
var dbMember channelMemberWithSchemeRoles
diff --git a/store/store.go b/store/store.go
index e21917345..1e153b422 100644
--- a/store/store.go
+++ b/store/store.go
@@ -147,6 +147,7 @@ type ChannelStore interface {
UpdateMember(member *model.ChannelMember) StoreChannel
GetMembers(channelId string, offset, limit int) StoreChannel
GetMember(channelId string, userId string) StoreChannel
+ GetChannelMembersTimezones(channelId string) StoreChannel
GetAllChannelMembersForUser(userId string, allowFromCache bool, includeDeleted bool) StoreChannel
InvalidateAllChannelMembersForUser(userId string)
IsUserInChannelUseCache(userId string, channelId string) bool
diff --git a/store/storetest/mocks/ChannelStore.go b/store/storetest/mocks/ChannelStore.go
index 1c3a2a8f2..9d42d0b65 100644
--- a/store/storetest/mocks/ChannelStore.go
+++ b/store/storetest/mocks/ChannelStore.go
@@ -442,6 +442,21 @@ func (_m *ChannelStore) GetMember(channelId string, userId string) store.StoreCh
return r0
}
+func (_m *ChannelStore) GetChannelMembersTimezones(channelId string) store.StoreChannel {
+ ret := _m.Called(channelId)
+
+ var r0 store.StoreChannel
+ if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok {
+ r0 = rf(channelId)
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).(store.StoreChannel)
+ }
+ }
+
+ return r0
+}
+
// GetMemberCount provides a mock function with given fields: channelId, allowFromCache
func (_m *ChannelStore) GetMemberCount(channelId string, allowFromCache bool) store.StoreChannel {
ret := _m.Called(channelId, allowFromCache)