From 4219d39e97bfe646e28696f9871fc8c1b8310154 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Wed, 5 Jul 2017 09:06:55 -0400 Subject: Return channel member immediately if user is already in channel (#6847) --- app/channel.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app/channel.go') diff --git a/app/channel.go b/app/channel.go index 2a710a3c0..9f8d20419 100644 --- a/app/channel.go +++ b/app/channel.go @@ -543,6 +543,14 @@ func AddUserToChannel(user *model.User, channel *model.Channel) (*model.ChannelM } func AddChannelMember(userId string, channel *model.Channel, userRequestorId string) (*model.ChannelMember, *model.AppError) { + if result := <-Srv.Store.Channel().GetMember(channel.Id, userId); result.Err != nil { + if result.Err.Id != store.MISSING_CHANNEL_MEMBER_ERROR { + return nil, result.Err + } + } else { + return result.Data.(*model.ChannelMember), nil + } + var user *model.User var err *model.AppError -- cgit v1.2.3-1-g7c22