Merge pull request #1142 from mattermost/plt-414

PLT-414 Fix direct channel creation.
Этот коммит содержится в:
Corey Hulen
2015-10-22 21:37:41 -07:00
родитель 0ed40545d0 6cc3bfe7a9
Коммит 640176bd4c
4 изменённых файлов: 261 добавлений и 69 удалений

Просмотреть файл

@@ -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
cm1 := &model.ChannelMember{
UserId: c.Session.UserId,
Roles: model.CHANNEL_ROLE_ADMIN,
NotifyProps: model.GetDefaultChannelNotifyProps(),
}
cm2 := &model.ChannelMember{
UserId: otherUserId,
Roles: "",
NotifyProps: model.GetDefaultChannelNotifyProps(),
}
if result := <-Srv.Store.Channel().SaveDirectChannel(channel, cm1, cm2); result.Err != nil {
return nil, result.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
}
return sc, nil
return result.Data.(*model.Channel), nil
}
}