summaryrefslogtreecommitdiffstats
path: root/store/sql_channel_store.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-02-07 14:58:27 -0800
committerGitHub <noreply@github.com>2017-02-07 14:58:27 -0800
commit5462f0119edb788428f90fc61c8651e4a8cd9ad1 (patch)
tree5c5ee0c3bcbe766e133a95141b7118179e8739d6 /store/sql_channel_store.go
parent487bb56a9b8f5c7a9efaabfc631f2f6c689ef74b (diff)
downloadchat-5462f0119edb788428f90fc61c8651e4a8cd9ad1.tar.gz
chat-5462f0119edb788428f90fc61c8651e4a8cd9ad1.tar.bz2
chat-5462f0119edb788428f90fc61c8651e4a8cd9ad1.zip
Implement a few channel member endpoints for APIv4 (#5304)
* Implement GET /channels/{channel_id}/members * Implement GET /channels/{channel_id}/members/{user_id} endpoint for APIv4 * Implement /users/{user_id}/teams/{team_id}/channels/members endpoint for APIv4 * Fix unit test
Diffstat (limited to 'store/sql_channel_store.go')
-rw-r--r--store/sql_channel_store.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go
index 7c4e97bc0..dfc77bd8a 100644
--- a/store/sql_channel_store.go
+++ b/store/sql_channel_store.go
@@ -751,18 +751,18 @@ func (s SqlChannelStore) UpdateMember(member *model.ChannelMember) StoreChannel
return storeChannel
}
-func (s SqlChannelStore) GetMembers(channelId string) StoreChannel {
+func (s SqlChannelStore) GetMembers(channelId string, offset, limit int) StoreChannel {
storeChannel := make(StoreChannel, 1)
go func() {
result := StoreResult{}
- var members []model.ChannelMember
- _, err := s.GetReplica().Select(&members, "SELECT * FROM ChannelMembers WHERE ChannelId = :ChannelId", map[string]interface{}{"ChannelId": channelId})
+ var members model.ChannelMembers
+ _, err := s.GetReplica().Select(&members, "SELECT * FROM ChannelMembers WHERE ChannelId = :ChannelId LIMIT :Limit OFFSET :Offset", map[string]interface{}{"ChannelId": channelId, "Limit": limit, "Offset": offset})
if err != nil {
result.Err = model.NewLocAppError("SqlChannelStore.GetMembers", "store.sql_channel.get_members.app_error", nil, "channel_id="+channelId+err.Error())
} else {
- result.Data = members
+ result.Data = &members
}
storeChannel <- result
@@ -782,7 +782,7 @@ func (s SqlChannelStore) GetMember(channelId string, userId string) StoreChannel
if err := s.GetReplica().SelectOne(&member, "SELECT * FROM ChannelMembers WHERE ChannelId = :ChannelId AND UserId = :UserId", map[string]interface{}{"ChannelId": channelId, "UserId": userId}); err != nil {
if err == sql.ErrNoRows {
- result.Err = model.NewLocAppError("SqlChannelStore.GetMember", MISSING_CHANNEL_MEMBER_ERROR, nil, "channel_id="+channelId+"user_id="+userId+","+err.Error())
+ result.Err = model.NewAppError("SqlChannelStore.GetMember", MISSING_CHANNEL_MEMBER_ERROR, nil, "channel_id="+channelId+"user_id="+userId+","+err.Error(), http.StatusNotFound)
} else {
result.Err = model.NewLocAppError("SqlChannelStore.GetMember", "store.sql_channel.get_member.app_error", nil, "channel_id="+channelId+"user_id="+userId+","+err.Error())
}