diff --git a/lib/Federation/Proxy/TalkV1/Controller/ChatController.php b/lib/Federation/Proxy/TalkV1/Controller/ChatController.php index 90c195a3318..e14c6dce082 100644 --- a/lib/Federation/Proxy/TalkV1/Controller/ChatController.php +++ b/lib/Federation/Proxy/TalkV1/Controller/ChatController.php @@ -209,7 +209,7 @@ public function getMessageContext(Room $room, Participant $participant, int $mes } /** - * @return DataResponse|DataResponse|DataResponse, array{}> + * @return DataResponse|DataResponse|DataResponse, array{}> * @throws CannotReachRemoteException * * 200: Message edited successfully @@ -231,28 +231,29 @@ public function editMessage(Room $room, Participant $participant, int $messageId ], ); - /** @var Http::STATUS_OK|Http::STATUS_ACCEPTED|Http::STATUS_BAD_REQUEST|Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND|Http::STATUS_REQUEST_ENTITY_TOO_LARGE $statusCode */ $statusCode = $proxy->getStatusCode(); - if ($statusCode !== Http::STATUS_OK && $statusCode !== Http::STATUS_ACCEPTED) { - if (in_array($statusCode, [ + if (!in_array($statusCode, [ Http::STATUS_BAD_REQUEST, Http::STATUS_FORBIDDEN, Http::STATUS_NOT_FOUND, + Http::STATUS_METHOD_NOT_ALLOWED, Http::STATUS_REQUEST_ENTITY_TOO_LARGE, ], true)) { $statusCode = $this->proxy->logUnexpectedStatusCode(__METHOD__, $statusCode); + $data = ['error' => 'status']; + } elseif ($statusCode === Http::STATUS_BAD_REQUEST) { + /** @var array{error: string} $data */ + $data = $this->proxy->getOCSData($proxy, [Http::STATUS_BAD_REQUEST]); + } else { + $data = []; } - return new DataResponse([], $statusCode); + return new DataResponse($data, $statusCode); } - /** @var ?TalkChatMessageWithParent $data */ + /** @var TalkChatMessageWithParent $data */ $data = $this->proxy->getOCSData($proxy, [Http::STATUS_OK, Http::STATUS_ACCEPTED]); - if (!empty($data)) { - $data = $this->userConverter->convertMessage($room, $data); - } else { - $data = null; - } + $data = $this->userConverter->convertMessage($room, $data); $headers = []; if ($proxy->getHeader('X-Chat-Last-Common-Read')) {