if (($options =
$message->
getOptions()) && !
$options instanceof MercureOptions
) { throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" for options.', __CLASS__, MercureOptions::
class));
} $options ??=
new MercureOptions($this->topics
);
// @see https://www.w3.org/TR/activitystreams-core/#jsonld
$update =
new Update($options->
getTopics() ??
$this->topics,
json_encode([ '@context' => 'https://www.w3.org/ns/activitystreams',
'type' => 'Announce',
'summary' =>
$message->
getSubject(),
]),
$options->
isPrivate(),
$options->
getId(),
$options->
getType(),
$options->
getRetry());
try { $messageId =
$this->hub->
publish($update);
$sentMessage =
new SentMessage($message,
(string) $this);
$sentMessage->
setMessageId($messageId);
return $sentMessage;
} catch (MercureRuntimeException|InvalidArgumentException
$e) { throw new RuntimeException('Unable to post the Mercure message: '.
$e->
getMessage(),
$e->
getCode(),
$e);
} }