Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/Transport/GpsReceiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use JsonException;
use LogicException;
use PetitPress\GpsMessengerBundle\Transport\Stamp\GpsReceivedStamp;
use PetitPress\GpsMessengerBundle\Transport\Stamp\GpsReceiverOptionsStamp;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Exception\MessageDecodingFailedException;
use Symfony\Component\Messenger\Exception\TransportException;
Expand All @@ -24,6 +25,7 @@ final class GpsReceiver implements ReceiverInterface
private PubSubClient $pubSubClient;
private GpsConfigurationInterface $gpsConfiguration;
private SerializerInterface $serializer;
private array $subcriptionInfo;

public function __construct(
PubSubClient $pubSubClient,
Expand Down Expand Up @@ -117,6 +119,15 @@ private function createEnvelopeFromPubSubMessage(Message $message): Envelope
throw new MessageDecodingFailedException($exception->getMessage(), 0, $exception);
}

return $this->serializer->decode($rawData)->with(new GpsReceivedStamp($message));
return $this->serializer->decode($rawData)->with(new GpsReceivedStamp($message))->with(new GpsReceiverOptionsStamp($this->getInfo()));
}

private function getInfo(): array
{
if (!$this->subcriptionInfo) {
$this->subcriptionInfo = $this->pubSubClient->subscription($this->gpsConfiguration->getSubscriptionName())->info() ?? [];
}

return $this->subcriptionInfo;
}
}
24 changes: 24 additions & 0 deletions src/Transport/Stamp/GpsReceiverOptionsStamp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace PetitPress\GpsMessengerBundle\Transport\Stamp;

use Symfony\Component\Messenger\Stamp\StampInterface;

/**
* @author Ignacio Visedo <naxo8628@gmail.com>
*/
final class GpsReceiverOptionsStamp implements StampInterface
{
public function __construct(private array $subscriptionInfo)
{
}

public function getSubscriptionInfo(): array
{
return $this->subscriptionInfo;
}


}
Loading