summaryrefslogtreecommitdiffstats
path: root/api/channel.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-04-28 10:56:19 -0400
committerChristopher Speller <crspeller@gmail.com>2016-04-28 10:56:19 -0400
commit383cddd3d14107fabea28e09f5f9401623cd19d5 (patch)
treef0aedc438756bf41aa29aa5f3518e83f40e95da1 /api/channel.go
parent3dbb5ab4cca74de7d7a00909927e1f034949052d (diff)
downloadchat-383cddd3d14107fabea28e09f5f9401623cd19d5.tar.gz
chat-383cddd3d14107fabea28e09f5f9401623cd19d5.tar.bz2
chat-383cddd3d14107fabea28e09f5f9401623cd19d5.zip
Don't return error if already part of channel being joined (#2814)
Diffstat (limited to 'api/channel.go')
-rw-r--r--api/channel.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/api/channel.go b/api/channel.go
index 4b0e99b20..5f0d03246 100644
--- a/api/channel.go
+++ b/api/channel.go
@@ -513,9 +513,18 @@ func AddUserToChannel(user *model.User, channel *model.Channel) (*model.ChannelM
return nil, model.NewLocAppError("AddUserToChannel", "api.channel.add_user_to_channel.type.app_error", nil, "")
}
+ if result := <-Srv.Store.Channel().GetMember(channel.Id, user.Id); result.Err != nil {
+ if result.Err.Id != store.MISSING_MEMBER_ERROR {
+ return nil, result.Err
+ }
+ } else {
+ channelMember := result.Data.(model.ChannelMember)
+ return &channelMember, nil
+ }
+
newMember := &model.ChannelMember{ChannelId: channel.Id, UserId: user.Id, NotifyProps: model.GetDefaultChannelNotifyProps()}
- if cmresult := <-Srv.Store.Channel().SaveMember(newMember); cmresult.Err != nil {
- l4g.Error("Failed to add member user_id=%v channel_id=%v err=%v", user.Id, channel.Id, cmresult.Err)
+ if result := <-Srv.Store.Channel().SaveMember(newMember); result.Err != nil {
+ l4g.Error("Failed to add member user_id=%v channel_id=%v err=%v", user.Id, channel.Id, result.Err)
return nil, model.NewLocAppError("AddUserToChannel", "api.channel.add_user.to.channel.failed.app_error", nil, "")
}