diff options
author | Saturnino Abril <saturnino.abril@gmail.com> | 2017-11-01 03:48:58 +0800 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2017-10-31 15:48:58 -0400 |
commit | 709ef99eca0353585eb00c795cc36f39bac29a1f (patch) | |
tree | ea4304506cbbe6825007d75d1c5975b661d394ab /model/client4.go | |
parent | 3024525c3b2ba8fb0f3f83223dd15fa721cca638 (diff) | |
download | chat-709ef99eca0353585eb00c795cc36f39bac29a1f.tar.gz chat-709ef99eca0353585eb00c795cc36f39bac29a1f.tar.bz2 chat-709ef99eca0353585eb00c795cc36f39bac29a1f.zip |
[PLT-7362] Add post' root ID to APIv4 addChannelMember to render added user (as system post) at RHS (#7730)
* add post' root ID to apiv4 addChannelMember to render added user (as system post) at RHS
* add check to post_root_id parameter
* add AddChannelMemberWithRootId function for backward compatibility
Diffstat (limited to 'model/client4.go')
-rw-r--r-- | model/client4.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/model/client4.go b/model/client4.go index bcd41638b..916e9d6de 100644 --- a/model/client4.go +++ b/model/client4.go @@ -1663,6 +1663,17 @@ func (c *Client4) AddChannelMember(channelId, userId string) (*ChannelMember, *R } } +// AddChannelMemberWithRootId adds user to channel and return a channel member. Post add to channel message has the postRootId. +func (c *Client4) AddChannelMemberWithRootId(channelId, userId, postRootId string) (*ChannelMember, *Response) { + requestBody := map[string]string{"user_id": userId, "post_root_id": postRootId} + if r, err := c.DoApiPost(c.GetChannelMembersRoute(channelId)+"", MapToJson(requestBody)); err != nil { + return nil, BuildErrorResponse(r, err) + } else { + defer closeBody(r) + return ChannelMemberFromJson(r.Body), BuildResponse(r) + } +} + // RemoveUserFromChannel will delete the channel member object for a user, effectively removing the user from a channel. func (c *Client4) RemoveUserFromChannel(channelId, userId string) (bool, *Response) { if r, err := c.DoApiDelete(c.GetChannelMemberRoute(channelId, userId)); err != nil { |