diff --git a/src/Util/CommonMark/Converter.php b/src/Util/CommonMark/Converter.php index e09f7f8..c35de76 100644 --- a/src/Util/CommonMark/Converter.php +++ b/src/Util/CommonMark/Converter.php @@ -6,6 +6,7 @@ use App\Service\NostrClient; use App\Service\RedisCacheService; use App\Util\CommonMark\ImagesExtension\RawImageLinkExtension; use App\Util\CommonMark\NostrSchemeExtension\NostrSchemeExtension; +use App\Util\NostrKeyUtil; use League\CommonMark\Environment\Environment; use League\CommonMark\Exception\CommonMarkException; use League\CommonMark\Extension\Autolink\AutolinkExtension; @@ -29,7 +30,8 @@ readonly class Converter public function __construct( private RedisCacheService $redisCacheService, private NostrClient $nostrClient, - private TwigEnvironment $twig + private TwigEnvironment $twig, + private NostrKeyUtil $nostrKeyUtil ){} /** @@ -68,7 +70,7 @@ readonly class Converter $environment->addExtension(new TableExtension()); $environment->addExtension(new StrikethroughExtension()); // create a custom extension, that handles nostr mentions - $environment->addExtension(new NostrSchemeExtension($this->redisCacheService, $this->nostrClient, $this->twig)); + $environment->addExtension(new NostrSchemeExtension($this->redisCacheService, $this->nostrClient, $this->twig, $this->nostrKeyUtil)); $environment->addExtension(new SmartPunctExtension()); $environment->addExtension(new EmbedExtension()); $environment->addRenderer(Embed::class, new HtmlDecorator(new EmbedRenderer(), 'div', ['class' => 'embedded-content'])); diff --git a/src/Util/CommonMark/NostrSchemeExtension/NostrSchemeExtension.php b/src/Util/CommonMark/NostrSchemeExtension/NostrSchemeExtension.php index 3441716..c906bd0 100644 --- a/src/Util/CommonMark/NostrSchemeExtension/NostrSchemeExtension.php +++ b/src/Util/CommonMark/NostrSchemeExtension/NostrSchemeExtension.php @@ -4,6 +4,7 @@ namespace App\Util\CommonMark\NostrSchemeExtension; use App\Service\NostrClient; use App\Service\RedisCacheService; +use App\Util\NostrKeyUtil; use League\CommonMark\Environment\EnvironmentBuilderInterface; use League\CommonMark\Extension\ExtensionInterface; use Twig\Environment; @@ -14,16 +15,17 @@ class NostrSchemeExtension implements ExtensionInterface public function __construct( private readonly RedisCacheService $redisCacheService, private readonly NostrClient $nostrClient, - private readonly Environment $twig + private readonly Environment $twig, + private readonly NostrKeyUtil $nostrKeyUtil ) { } public function register(EnvironmentBuilderInterface $environment): void { $environment - ->addInlineParser(new NostrMentionParser($this->redisCacheService), 200) - ->addInlineParser(new NostrSchemeParser($this->redisCacheService, $this->nostrClient, $this->twig), 199) - ->addInlineParser(new NostrRawNpubParser($this->redisCacheService), 198) + ->addInlineParser(new NostrMentionParser($this->redisCacheService, $this->nostrKeyUtil), 200) + ->addInlineParser(new NostrSchemeParser($this->redisCacheService, $this->nostrClient, $this->twig, $this->nostrKeyUtil), 199) + ->addInlineParser(new NostrRawNpubParser($this->redisCacheService, $this->nostrKeyUtil), 198) ->addRenderer(NostrSchemeData::class, new NostrEventRenderer(), 2) ->addRenderer(NostrEmbeddedCard::class, new NostrEmbeddedCardRenderer(), 3)