Skip to content

Commit

Permalink
Exclude InvalidApPostException from rolling back the transaction (#1180)
Browse files Browse the repository at this point in the history
  • Loading branch information
BentiGorlich authored Oct 10, 2024
1 parent b16fa3f commit 077d369
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/MessageHandler/ActivityPub/Outbox/DeliverHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,28 @@ public function __invoke(DeliverMessage $message): void
$this->workWrapper($message);
}

public function workWrapper(MessageInterface $message): void
{
$conn = $this->entityManager->getConnection();
if (!$conn->isConnected()) {
$conn->connect();
}
$conn->beginTransaction();
try {
$this->doWork($message);
$conn->commit();
} catch (InvalidApPostException $e) {
$conn->commit();
// we don't roll back on an InvalidApPostException, so the failed delivery attempt gets written to the DB
throw $e;
} catch (\Exception $e) {
$conn->rollBack();
throw $e;
}

$conn->close();
}

public function doWork(MessageInterface $message): void
{
if (!($message instanceof DeliverMessage)) {
Expand Down

0 comments on commit 077d369

Please sign in to comment.