fix: a push notification is not chat

This commit is contained in:
Maël Gangloff
2024-08-27 21:44:42 +02:00
parent 4b0148fe49
commit 83a97b429b
7 changed files with 94 additions and 8 deletions

View File

@@ -177,8 +177,18 @@ class WatchListController extends AbstractController
/** @var AbstractTransportFactory $transportFactory */
$transportFactory = new $transportFactoryClass();
$push = (new TestChatNotification())->asPushMessage();
$chat = (new TestChatNotification())->asChatMessage();
try {
$transportFactory->create($dsn)->send((new TestChatNotification())->asChatMessage());
$factory = $transportFactory->create($dsn);
if ($factory->supports($push)) {
$factory->send($push);
} elseif ($factory->supports($chat)) {
$factory->send($chat);
} else {
throw new BadRequestHttpException('Unsupported message type');
}
} catch (\Throwable $exception) {
throw new BadRequestHttpException($exception->getMessage());
}