From a2777677c5a1daf254ac81cab23f73e744d60ccc Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 26 Feb 2024 16:54:02 +0100 Subject: [PATCH] fix(federation): Improve logging Signed-off-by: Joas Schilling --- .../Proxy/TalkV1/Controller/AvatarController.php | 2 +- lib/Federation/Proxy/TalkV1/Controller/ChatController.php | 2 +- lib/Federation/Proxy/TalkV1/ProxyRequest.php | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Federation/Proxy/TalkV1/Controller/AvatarController.php b/lib/Federation/Proxy/TalkV1/Controller/AvatarController.php index 6310f1e9e0bd..d9996463763c 100644 --- a/lib/Federation/Proxy/TalkV1/Controller/AvatarController.php +++ b/lib/Federation/Proxy/TalkV1/Controller/AvatarController.php @@ -61,7 +61,7 @@ public function getAvatar(Room $room, Participant $participant, bool $darkTheme) ); if ($proxy->getStatusCode() !== Http::STATUS_OK) { - $this->proxy->logUnexpectedStatusCode(__METHOD__, $proxy->getStatusCode()); + $this->proxy->logUnexpectedStatusCode(__METHOD__, $proxy->getStatusCode(), (string) $proxy->getBody()); throw new CannotReachRemoteException('Avatar request had unexpected status code'); } diff --git a/lib/Federation/Proxy/TalkV1/Controller/ChatController.php b/lib/Federation/Proxy/TalkV1/Controller/ChatController.php index 435fb0e06980..bc713fcca600 100644 --- a/lib/Federation/Proxy/TalkV1/Controller/ChatController.php +++ b/lib/Federation/Proxy/TalkV1/Controller/ChatController.php @@ -130,7 +130,7 @@ public function receiveMessages( // FIXME // Poor-mans timeout, should later on cancel/trigger earlier, // when we received a OCM message notifying us about a chat message - sleep($timeout); + sleep(min(0, $timeout - 5)); $proxy = $this->proxy->get( $participant->getAttendee()->getInvitedCloudId(), diff --git a/lib/Federation/Proxy/TalkV1/ProxyRequest.php b/lib/Federation/Proxy/TalkV1/ProxyRequest.php index 070c8b0110e2..139a16b3db38 100644 --- a/lib/Federation/Proxy/TalkV1/ProxyRequest.php +++ b/lib/Federation/Proxy/TalkV1/ProxyRequest.php @@ -49,11 +49,11 @@ public function __construct( /** * @return Http::STATUS_BAD_REQUEST */ - public function logUnexpectedStatusCode(string $method, int $statusCode): int { + public function logUnexpectedStatusCode(string $method, int $statusCode, string $logDetails = ''): int { if ($this->config->getSystemValueBool('debug')) { - $this->logger->error('Unexpected status code ' . $statusCode . ' returned for ' . $method); + $this->logger->error('Unexpected status code ' . $statusCode . ' returned for ' . $method . "\n" . $logDetails); } else { - $this->logger->debug('Unexpected status code ' . $statusCode . ' returned for ' . $method); + $this->logger->debug('Unexpected status code ' . $statusCode . ' returned for ' . $method . "\n" . $logDetails); } return Http::STATUS_BAD_REQUEST; } @@ -213,7 +213,7 @@ public function getOCSData(IResponse $response, array $allowedStatusCodes = [Htt } } catch (\Throwable $e) { $this->logger->error('Error parsing JSON response', ['exception' => $e]); - throw new CannotReachRemoteException('Error parsing JSON response', $e->getCode(), $e); + throw new CannotReachRemoteException('Error parsing JSON response'throw new CannotReachRemoteException('Error parsing JSON response: ' . ($responseData ?? 'no-data'), $e->getCode(), $e); } return $responseData['ocs']['data'] ?? [];