mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-10 09:13:11 +08:00
Integrated PublishUpdatesGenerator in NotifyNewShortUrlToRabbitMq listener
This commit is contained in:
@@ -6,12 +6,10 @@ namespace Shlinkio\Shlink\Core\EventDispatcher\RabbitMq;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Shlinkio\Shlink\Common\Rest\DataTransformerInterface;
|
||||
use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface;
|
||||
use Shlinkio\Shlink\Common\UpdatePublishing\Update;
|
||||
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
||||
use Shlinkio\Shlink\Core\EventDispatcher\Event\ShortUrlCreated;
|
||||
use Shlinkio\Shlink\Core\EventDispatcher\Topic;
|
||||
use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface;
|
||||
use Shlinkio\Shlink\Core\Options\RabbitMqOptions;
|
||||
use Throwable;
|
||||
|
||||
@@ -19,9 +17,9 @@ class NotifyNewShortUrlToRabbitMq
|
||||
{
|
||||
public function __construct(
|
||||
private readonly PublishingHelperInterface $rabbitMqHelper,
|
||||
private readonly PublishingUpdatesGeneratorInterface $updatesGenerator,
|
||||
private readonly EntityManagerInterface $em,
|
||||
private readonly LoggerInterface $logger,
|
||||
private readonly DataTransformerInterface $shortUrlTransformer,
|
||||
private readonly RabbitMqOptions $options,
|
||||
) {
|
||||
}
|
||||
@@ -44,10 +42,7 @@ class NotifyNewShortUrlToRabbitMq
|
||||
}
|
||||
|
||||
try {
|
||||
$this->rabbitMqHelper->publishUpdate(Update::forTopicAndPayload(
|
||||
Topic::NEW_SHORT_URL->value,
|
||||
['shortUrl' => $this->shortUrlTransformer->transform($shortUrl)],
|
||||
));
|
||||
$this->rabbitMqHelper->publishUpdate($this->updatesGenerator->newShortUrlUpdate($shortUrl));
|
||||
} catch (Throwable $e) {
|
||||
$this->logger->debug('Error while trying to notify RabbitMQ with new short URL. {e}', ['e' => $e]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user