From dbf81cdecaa24b57292cec7bfb3bd1c9c3cd7e2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nu=C5=A1a=20Puk=C5=A1i=C4=8D?= Date: Fri, 10 Oct 2025 14:11:28 +0200 Subject: [PATCH] Metadata --- src/Controller/DefaultController.php | 2 +- .../NostrSchemeExtension/NostrRawNpubParser.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Controller/DefaultController.php b/src/Controller/DefaultController.php index b4c9a48..18689f7 100644 --- a/src/Controller/DefaultController.php +++ b/src/Controller/DefaultController.php @@ -351,7 +351,7 @@ class DefaultController extends AbstractController $key = new Key(); $npub = $key->convertPublicKeyToBech32($article->getPubkey()); - $author = $redisCacheService->getMetadata($npub); + $author = $redisCacheService->getMetadata($article->getPubkey()); // set canonical url to this article as article-slug path $canonical = $this->generateUrl('article-slug', [ diff --git a/src/Util/CommonMark/NostrSchemeExtension/NostrRawNpubParser.php b/src/Util/CommonMark/NostrSchemeExtension/NostrRawNpubParser.php index e33bfca..d9114ba 100644 --- a/src/Util/CommonMark/NostrSchemeExtension/NostrRawNpubParser.php +++ b/src/Util/CommonMark/NostrSchemeExtension/NostrRawNpubParser.php @@ -3,6 +3,7 @@ namespace App\Util\CommonMark\NostrSchemeExtension; use App\Service\RedisCacheService; +use App\Util\NostrKeyUtil; use League\CommonMark\Parser\Inline\InlineParserInterface; use League\CommonMark\Parser\Inline\InlineParserMatch; use League\CommonMark\Parser\InlineParserContext; @@ -14,7 +15,10 @@ use League\CommonMark\Parser\InlineParserContext; readonly class NostrRawNpubParser implements InlineParserInterface { - public function __construct(private RedisCacheService $redisCacheService) + public function __construct( + private RedisCacheService $redisCacheService, + private NostrKeyUtil $nostrKeyUtil, + ) { } @@ -28,7 +32,8 @@ readonly class NostrRawNpubParser implements InlineParserInterface $cursor = $inlineContext->getCursor(); // Get the match and extract relevant parts $fullMatch = $inlineContext->getFullMatch(); - $meta = $this->redisCacheService->getMetadata($fullMatch); + + $meta = $this->redisCacheService->getMetadata($this->nostrKeyUtil->npubToHex($fullMatch)); // Use shortened npub as default name, from first and last 8 characters of the fullMatch $name = substr($fullMatch, 0, 8) . '...' . substr($fullMatch, -8);