Skip to content

Commit

Permalink
wire a clock for the BlueSky transport in the FrameworkBundle
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Jun 17, 2024
1 parent 916718c commit bcc78f2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2865,6 +2865,12 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $
->addArgument(new Reference('http_client', ContainerBuilder::NULL_ON_INVALID_REFERENCE));
}

if (ContainerBuilder::willBeAvailable('symfony/bluesky-notifier', NotifierBridge\BlueSky\BlueSkyTransportFactory::class, ['symfony/framework-bundle', 'symfony/notifier'])) {
$container->getDefinition($classToServices[NotifierBridge\Bluesky\BlueskyTransportFactory::class])
->addArgument(new Reference('logger'))
->addArgument(new Reference('clock', ContainerBuilder::NULL_ON_INVALID_REFERENCE));
}

if (isset($config['admin_recipients'])) {
$notifier = $container->getDefinition('notifier');
foreach ($config['admin_recipients'] as $i => $recipient) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
]);

$chatterFactories = [
'bluesky' => Bridge\Bluesky\BlueskyTransportFactory::class,
'brevo' => Bridge\Brevo\BrevoTransportFactory::class,
'chatwork' => Bridge\Chatwork\ChatworkTransportFactory::class,
'discord' => Bridge\Discord\DiscordTransportFactory::class,
Expand Down Expand Up @@ -56,6 +55,11 @@
->tag('chatter.transport_factory');
}

$container->services()
->set('notifier.transport_factory.bluesky', Bridge\Bluesky\BlueskyTransportFactory::class)
->parent('notifier.transport_factory.abstract')
->tag('chatter.transport_factory');

$texterFactories = [
'all-my-sms' => Bridge\AllMySms\AllMySmsTransportFactory::class,
'bandwidth' => Bridge\Bandwidth\BandwidthTransportFactory::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Symfony\Component\Clock\ClockInterface;
use Symfony\Component\Notifier\Exception\UnsupportedSchemeException;
use Symfony\Component\Notifier\Transport\AbstractTransportFactory;
use Symfony\Component\Notifier\Transport\Dsn;
Expand All @@ -28,6 +29,7 @@ public function __construct(
?EventDispatcherInterface $dispatcher = null,
?HttpClientInterface $client = null,
private ?LoggerInterface $logger = null,
private readonly ?ClockInterface $clock = null,
) {
parent::__construct($dispatcher, $client);
}
Expand All @@ -43,7 +45,7 @@ public function create(Dsn $dsn): BlueskyTransport
$user = $this->getUser($dsn);
$secret = $this->getPassword($dsn);

return (new BlueskyTransport($user, $secret, $this->logger ?? new NullLogger(), $this->client, $this->dispatcher))
return (new BlueskyTransport($user, $secret, $this->logger ?? new NullLogger(), $this->client, $this->dispatcher, $this->clock))
->setHost($dsn->getHost())
->setPort($dsn->getPort());
}
Expand Down

0 comments on commit bcc78f2

Please sign in to comment.