Skip to content

Commit

Permalink
new options added
Browse files Browse the repository at this point in the history
  • Loading branch information
emrecanmuslumdns committed Dec 31, 2020
1 parent 84a915c commit 59fc261
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
18 changes: 12 additions & 6 deletions src/NotificationTransport/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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" => []
]
];

/**
Expand All @@ -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
*/
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
]);
}

Expand Down Expand Up @@ -476,4 +483,3 @@ private function updateSchema(): void
}
}
}
//class_alias(Connection::class, \Symfony\Component\Messenger\Transport\Doctrine\Connection::class);
1 change: 0 additions & 1 deletion src/NotificationTransport/DoctrineReceivedStamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ public function getId(): string
return $this->id;
}
}
//class_alias(DoctrineReceivedStamp::class, \Symfony\Component\Messenger\Transport\Doctrine\DoctrineReceivedStamp::class);
1 change: 0 additions & 1 deletion src/NotificationTransport/DoctrineReceiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,3 @@ private function createEnvelopeFromData(array $data): Envelope
);
}
}
//class_alias(DoctrineReceiver::class, \Symfony\Component\Messenger\Transport\Doctrine\DoctrineReceiver::class);
1 change: 0 additions & 1 deletion src/NotificationTransport/DoctrineSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
1 change: 0 additions & 1 deletion src/NotificationTransport/DoctrineTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
1 change: 0 additions & 1 deletion src/NotificationTransport/DoctrineTransportFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 59fc261

Please sign in to comment.