From 709ef99eca0353585eb00c795cc36f39bac29a1f Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Wed, 1 Nov 2017 03:48:58 +0800 Subject: [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 --- model/client4.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'model') 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 { -- cgit v1.2.3-1-g7c22