From d75cb0294896e0e45f280cbccde8581376d501ce Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Fri, 6 May 2016 08:06:34 -0400 Subject: Multiple cross-team functionality fixes (#2902) --- api/channel.go | 6 +++++- api/channel_test.go | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'api') diff --git a/api/channel.go b/api/channel.go index b034e94ba..7cfc22833 100644 --- a/api/channel.go +++ b/api/channel.go @@ -146,7 +146,11 @@ func CreateDirectChannel(userId string, otherUserId string) (*model.Channel, *mo } if result := <-Srv.Store.Channel().SaveDirectChannel(channel, cm1, cm2); result.Err != nil { - return nil, result.Err + if result.Err.Id == store.CHANNEL_EXISTS_ERROR { + return result.Data.(*model.Channel), nil + } else { + return nil, result.Err + } } else { return result.Data.(*model.Channel), nil } diff --git a/api/channel_test.go b/api/channel_test.go index 31b201346..69902c3ad 100644 --- a/api/channel_test.go +++ b/api/channel_test.go @@ -113,8 +113,9 @@ func TestCreateDirectChannel(t *testing.T) { t.Fatal("channel type was not direct") } - if _, err := Client.CreateDirectChannel(th.BasicUser2.Id); err == nil { - t.Fatal("channel already exists and should have failed") + // don't fail on direct channels already existing + if _, err := Client.CreateDirectChannel(th.BasicUser2.Id); err != nil { + t.Fatal(err) } if _, err := Client.CreateDirectChannel("junk"); err == nil { -- cgit v1.2.3-1-g7c22