summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2015-10-22 21:37:41 -0700
committerCorey Hulen <corey@hulen.com>2015-10-22 21:37:41 -0700
commit640176bd4c9fd13878a3faca12d5ad41512547ba (patch)
treef906e8bd679b6e0cf33b62ede4b6468cf56b7823 /api
parent0ed40545d0057eca34ff1852b29616e9bf4520ee (diff)
parent6cc3bfe7a96e66d27a5b7f08bc1dc15a742b36ab (diff)
downloadchat-640176bd4c9fd13878a3faca12d5ad41512547ba.tar.gz
chat-640176bd4c9fd13878a3faca12d5ad41512547ba.tar.bz2
chat-640176bd4c9fd13878a3faca12d5ad41512547ba.zip
Merge pull request #1142 from mattermost/plt-414
PLT-414 Fix direct channel creation.
Diffstat (limited to 'api')
-rw-r--r--api/channel.go23
1 files changed, 14 insertions, 9 deletions
diff --git a/api/channel.go b/api/channel.go
index 70f7eba4b..9c7ac053b 100644
--- a/api/channel.go
+++ b/api/channel.go
@@ -131,16 +131,21 @@ func CreateDirectChannel(c *Context, otherUserId string) (*model.Channel, *model
return nil, model.NewAppError("CreateDirectChannel", "Invalid other user id ", otherUserId)
}
- if sc, err := CreateChannel(c, channel, true); err != nil {
- return nil, err
- } else {
- cm := &model.ChannelMember{ChannelId: sc.Id, UserId: otherUserId, Roles: "", NotifyProps: model.GetDefaultChannelNotifyProps()}
-
- if cmresult := <-Srv.Store.Channel().SaveMember(cm); cmresult.Err != nil {
- return nil, cmresult.Err
- }
+ cm1 := &model.ChannelMember{
+ UserId: c.Session.UserId,
+ Roles: model.CHANNEL_ROLE_ADMIN,
+ NotifyProps: model.GetDefaultChannelNotifyProps(),
+ }
+ cm2 := &model.ChannelMember{
+ UserId: otherUserId,
+ Roles: "",
+ NotifyProps: model.GetDefaultChannelNotifyProps(),
+ }
- return sc, nil
+ if result := <-Srv.Store.Channel().SaveDirectChannel(channel, cm1, cm2); result.Err != nil {
+ return nil, result.Err
+ } else {
+ return result.Data.(*model.Channel), nil
}
}