diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-02-03 10:27:12 -0500 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-02-03 10:27:12 -0500 |
commit | 9312469ad54cf2ff268a44e478b584549f62e2c4 (patch) | |
tree | 6b29783b9341b54a16aca581c4878f3cdd7474d7 /app/channel.go | |
parent | ccb034382850b7e8ea924a4559e47ef44203155c (diff) | |
download | chat-9312469ad54cf2ff268a44e478b584549f62e2c4.tar.gz chat-9312469ad54cf2ff268a44e478b584549f62e2c4.tar.bz2 chat-9312469ad54cf2ff268a44e478b584549f62e2c4.zip |
Implement POST /channels/direct endpoint for APIv4 (#5283)
Diffstat (limited to 'app/channel.go')
-rw-r--r-- | app/channel.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/app/channel.go b/app/channel.go index 025eccfcd..02124f3c8 100644 --- a/app/channel.go +++ b/app/channel.go @@ -188,10 +188,15 @@ func CreateChannel(channel *model.Channel, addMember bool) (*model.Channel, *mod } func CreateDirectChannel(userId string, otherUserId string) (*model.Channel, *model.AppError) { - uc := Srv.Store.User().Get(otherUserId) + uc1 := Srv.Store.User().Get(userId) + uc2 := Srv.Store.User().Get(otherUserId) - if uresult := <-uc; uresult.Err != nil { - return nil, model.NewLocAppError("CreateDirectChannel", "api.channel.create_direct_channel.invalid_user.app_error", nil, otherUserId) + if result := <-uc1; result.Err != nil { + return nil, model.NewAppError("CreateDirectChannel", "api.channel.create_direct_channel.invalid_user.app_error", nil, userId, http.StatusBadRequest) + } + + if result := <-uc2; result.Err != nil { + return nil, model.NewAppError("CreateDirectChannel", "api.channel.create_direct_channel.invalid_user.app_error", nil, otherUserId, http.StatusBadRequest) } if result := <-Srv.Store.Channel().CreateDirectChannel(userId, otherUserId); result.Err != nil { |