From 59fc261bcf5833ad295dca59b904b4b7a4ca81bc Mon Sep 17 00:00:00 2001 From: Emrecan Muslu Date: Thu, 31 Dec 2020 16:59:19 +0300 Subject: [PATCH] new options added --- src/NotificationTransport/Connection.php | 18 ++++++++++++------ .../DoctrineReceivedStamp.php | 1 - src/NotificationTransport/DoctrineReceiver.php | 1 - src/NotificationTransport/DoctrineSender.php | 1 - .../DoctrineTransport.php | 1 - .../DoctrineTransportFactory.php | 1 - 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/NotificationTransport/Connection.php b/src/NotificationTransport/Connection.php index 86b42bd..c7ed3e4 100644 --- a/src/NotificationTransport/Connection.php +++ b/src/NotificationTransport/Connection.php @@ -41,10 +41,14 @@ class Connection implements ResetInterface protected const TABLE_OPTION_NAME = '_symfony_messenger_table_name'; protected const DEFAULT_OPTIONS = [ - 'table_name' => 'messenger_messages', - 'provider_name' => 'default', + 'table_name' => 'notification_sms', + 'provider_name' => null, + 'template_name' => null, 'redeliver_timeout' => 3600, 'auto_setup' => true, + 'payload' => [ + "models" => [] + ] ]; /** @@ -54,7 +58,7 @@ class Connection implements ResetInterface * * * table_name: name of the table * * connection: name of the Doctrine's entity manager - * * queue_name: name of the queue + * * provider_name: name of the queue * * redeliver_timeout: Timeout before redeliver messages still in handling state (i.e: delivered_at is not null and message is still in table). Default: 3600 * * auto_setup: Whether the table should be created automatically during send / get. Default: true */ @@ -150,7 +154,7 @@ public function send(Envelope $envelope, string $encodedMessage, array $headers, $encodedMessage, json_encode($headers), $this->configuration['provider_name'], - $notificationSmsTemplate->getCode(), + $this->configuration['template_name'], null, null, 0, @@ -246,7 +250,6 @@ public function get(): ?array public function ack(string $id): bool { try { - // return $this->driverConnection->delete($this->configuration['table_name'], ['id' => $id]) > 0; return $this->driverConnection->update($this->configuration['table_name'], ['handled' => true ],['id' => $id]) > 0; } catch (DBALException | Exception $exception) { throw new TransportException($exception->getMessage(), 0, $exception); @@ -343,13 +346,17 @@ private function createAvailableMessagesQueryBuilder(): QueryBuilder ->where('m.delivered_at is null OR m.delivered_at < ?') ->andWhere('m.available_at <= ?') ->andWhere('m.provider_name = ?') + ->andWhere('m.template_name = ?') ->setParameters([ $redeliverLimit, $now, $this->configuration['provider_name'], + $this->configuration['template_name'], ], [ Types::DATETIME_MUTABLE, Types::DATETIME_MUTABLE, + null, + null ]); } @@ -476,4 +483,3 @@ private function updateSchema(): void } } } -//class_alias(Connection::class, \Symfony\Component\Messenger\Transport\Doctrine\Connection::class); \ No newline at end of file diff --git a/src/NotificationTransport/DoctrineReceivedStamp.php b/src/NotificationTransport/DoctrineReceivedStamp.php index 180a5e4..2df0a72 100644 --- a/src/NotificationTransport/DoctrineReceivedStamp.php +++ b/src/NotificationTransport/DoctrineReceivedStamp.php @@ -30,4 +30,3 @@ public function getId(): string return $this->id; } } -//class_alias(DoctrineReceivedStamp::class, \Symfony\Component\Messenger\Transport\Doctrine\DoctrineReceivedStamp::class); \ No newline at end of file diff --git a/src/NotificationTransport/DoctrineReceiver.php b/src/NotificationTransport/DoctrineReceiver.php index 59e9bb0..04c7fdb 100644 --- a/src/NotificationTransport/DoctrineReceiver.php +++ b/src/NotificationTransport/DoctrineReceiver.php @@ -173,4 +173,3 @@ private function createEnvelopeFromData(array $data): Envelope ); } } -//class_alias(DoctrineReceiver::class, \Symfony\Component\Messenger\Transport\Doctrine\DoctrineReceiver::class); \ No newline at end of file diff --git a/src/NotificationTransport/DoctrineSender.php b/src/NotificationTransport/DoctrineSender.php index 4048185..390d8c3 100644 --- a/src/NotificationTransport/DoctrineSender.php +++ b/src/NotificationTransport/DoctrineSender.php @@ -55,4 +55,3 @@ public function send(Envelope $envelope): Envelope return $envelope->with(new TransportMessageIdStamp($id)); } } -//class_alias(DoctrineSender::class, \Symfony\Component\Messenger\Transport\Doctrine\DoctrineSender::class); \ No newline at end of file diff --git a/src/NotificationTransport/DoctrineTransport.php b/src/NotificationTransport/DoctrineTransport.php index 2ecf1e4..4b9c4d4 100644 --- a/src/NotificationTransport/DoctrineTransport.php +++ b/src/NotificationTransport/DoctrineTransport.php @@ -129,4 +129,3 @@ private function getSender(): DoctrineSender return $this->sender = new DoctrineSender($this->connection, $this->serializer); } } -//class_alias(DoctrineTransport::class, \Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransport::class); \ No newline at end of file diff --git a/src/NotificationTransport/DoctrineTransportFactory.php b/src/NotificationTransport/DoctrineTransportFactory.php index d9e745f..090fd23 100644 --- a/src/NotificationTransport/DoctrineTransportFactory.php +++ b/src/NotificationTransport/DoctrineTransportFactory.php @@ -62,4 +62,3 @@ public function supports(string $dsn, array $options): bool return 0 === strpos($dsn, 'notificationSms://'); } } -//class_alias(DoctrineTransportFactory::class, \Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransportFactory::class); \ No newline at end of file