Skip to content

Commit

Permalink
fix(federation): Improve logging
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Feb 26, 2024
1 parent 771e89e commit a277767
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Federation/Proxy/TalkV1/Controller/ChatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
8 changes: 4 additions & 4 deletions lib/Federation/Proxy/TalkV1/ProxyRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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'] ?? [];
Expand Down

0 comments on commit a277767

Please sign in to comment.