diff --git a/src/Controller/ArticleController.php b/src/Controller/ArticleController.php index ec37ee8..c9ab9fc 100644 --- a/src/Controller/ArticleController.php +++ b/src/Controller/ArticleController.php @@ -138,7 +138,7 @@ class ArticleController extends AbstractController */ #[Route('/article-editor/create', name: 'editor-create')] #[Route('/article-editor/edit/{slug}', name: 'editor-edit-slug')] - public function newArticle(Request $request, EntityManagerInterface $entityManager, $slug = null): Response + public function newArticle(Request $request, NostrClient $nostrClient, EntityManagerInterface $entityManager, $slug = null): Response { if (!$slug) { $article = new Article(); @@ -178,6 +178,11 @@ class ArticleController extends AbstractController }); $recentArticles = array_values($recentArticles); // get drafts + // look for drafts on relays first, grab latest 5 from there + // one week ago + $since = new \DateTime(); + $aWeekAgo = $since->sub(new \DateInterval('P1D'))->getTimestamp(); + $nostrClient->getLongFormContentForPubkey($currentPubkey, $aWeekAgo, KindsEnum::LONGFORM_DRAFT->value); $drafts = $entityManager->getRepository(Article::class) ->findBy(['pubkey' => $currentPubkey, 'kind' => KindsEnum::LONGFORM_DRAFT], ['createdAt' => 'DESC'], 5); diff --git a/src/Service/NostrClient.php b/src/Service/NostrClient.php index 5f7c455..ebd66e8 100644 --- a/src/Service/NostrClient.php +++ b/src/Service/NostrClient.php @@ -533,7 +533,7 @@ class NostrClient /** * @throws \Exception */ - public function getLongFormContentForPubkey(string $ident, ?int $since = null): array + public function getLongFormContentForPubkey(string $ident, ?int $since = null, ?int $kind = KindsEnum::LONGFORM->value ): array { // Add user relays to the default set $authorRelays = $this->getTopReputableRelaysForAuthor($ident); @@ -553,7 +553,7 @@ class NostrClient } $request = $this->createNostrRequest( - kinds: [KindsEnum::LONGFORM], + kinds: [$kind], filters: $filters, relaySet: $relaySet );