summaryrefslogtreecommitdiffstats
path: root/app
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 /app
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 'app')
-rw-r--r--app/channel.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/app/channel.go b/app/channel.go
index 3609a36b7..ccacc2ca6 100644
--- a/app/channel.go
+++ b/app/channel.go
@@ -15,11 +15,11 @@ import (
)
func MakeDirectChannelVisible(channelId string) *model.AppError {
- var members []model.ChannelMember
- if result := <-Srv.Store.Channel().GetMembers(channelId); result.Err != nil {
+ var members model.ChannelMembers
+ if result := <-Srv.Store.Channel().GetMembers(channelId, 0, 100); result.Err != nil {
return result.Err
} else {
- members = result.Data.([]model.ChannelMember)
+ members = *(result.Data.(*model.ChannelMembers))
}
if len(members) != 2 {
@@ -582,6 +582,14 @@ func GetChannelMember(channelId string, userId string) (*model.ChannelMember, *m
}
}
+func GetChannelMembersPage(channelId string, page, perPage int) (*model.ChannelMembers, *model.AppError) {
+ if result := <-Srv.Store.Channel().GetMembers(channelId, page*perPage, perPage); result.Err != nil {
+ return nil, result.Err
+ } else {
+ return result.Data.(*model.ChannelMembers), nil
+ }
+}
+
func GetChannelMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, *model.AppError) {
if result := <-Srv.Store.Channel().GetMembersByIds(channelId, userIds); result.Err != nil {
return nil, result.Err