diff options
author | Joas Schilling <coding@schilljs.com> | 2020-06-18 13:15:40 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-06-29 16:50:20 +0300 |
commit | 4655784a713bbd2eb3eb910a35e03af636a5f999 (patch) | |
tree | ceb3a2d1a0338cd70ecfea71045839093defb46c /lib | |
parent | 8e900c3ef820b1665a51b7a1e4d9a985413e3f3c (diff) |
Fix returned status code
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Controller/RoomController.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 2cd2b4b38..7965d8d3f 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -601,8 +601,17 @@ class RoomController extends AEnvironmentAwareController { } try { + // We are only doing this manually here to be able to return different status codes + // Actually createOneToOneConversation also checks it. + $room = $this->manager->getOne2OneRoom($currentUser->getUID(), $targetUser->getUID()); + $room->ensureOneToOneRoomIsFilled(); + return new DataResponse([], Http::STATUS_OK); + } catch (RoomNotFoundException $e) { + } + + try { $room = $this->roomService->createOneToOneConversation($currentUser, $targetUser); - return new DataResponse($this->formatRoom($room, $room->getParticipant($currentUser->getUID())), Http::STATUS_OK); + return new DataResponse($this->formatRoom($room, $room->getParticipant($currentUser->getUID())), Http::STATUS_CREATED); } catch (\InvalidArgumentException $e) { // Same current and target user return new DataResponse([], Http::STATUS_FORBIDDEN); |