Skip to content

Commit

Permalink
handle stale apps (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
joedixon authored Apr 11, 2024
1 parent 0fb2e03 commit 47e6a7d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/Protocols/Pusher/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,8 @@ public function verify(RequestInterface $request, Connection $connection, $appId
$this->body = $request->getBody()->getContents();
$this->query = $query;

try {
$this->setApplication($appId);
$this->setChannels();
} catch (HttpException $e) {
$this->close($connection, $e->getStatusCode(), $e->getMessage());
}
$this->setApplication($appId);
$this->setChannels();
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/Servers/Reverb/Http/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use React\EventLoop\LoopInterface;
use React\Socket\ConnectionInterface;
use React\Socket\ServerInterface;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Throwable;

class Server
Expand Down Expand Up @@ -57,6 +58,8 @@ protected function handleRequest(string $message, Connection $connection): void

try {
$this->router->dispatch($request, $connection);
} catch (HttpException $e) {
$this->close($connection, $e->getStatusCode(), $e->getMessage());
} catch (Throwable $e) {
Log::error($e->getMessage());
$this->close($connection, 500, 'Internal server error.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,7 @@

expect($response->getStatusCode())->toBe(500);
})->throws(ResponseException::class, exceptionCode: 500);

it('fails when app cannot be found', function () {
await($this->signedPostRequest('events', appId: 'invalid-app-id'));
})->throws(ResponseException::class, exceptionCode: 404);

0 comments on commit 47e6a7d

Please sign in to comment.