From 4ea40e361f68858aa4da4183bd8ec4a087e6341f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andri=20=C3=93skarsson?= Date: Sun, 19 Jan 2025 20:40:05 +0100 Subject: [PATCH] small improvements --- .../atproto/domain/store-post-with-record.ts | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/packages/atproto/domain/store-post-with-record.ts b/packages/atproto/domain/store-post-with-record.ts index 4d9c731..39edbcd 100644 --- a/packages/atproto/domain/store-post-with-record.ts +++ b/packages/atproto/domain/store-post-with-record.ts @@ -59,28 +59,27 @@ export async function storePost(ctx: AtContext, post: FeedPostWithUri) { cid: post.cid, }) .onConflictDoNothing(); - for (const et of extractedText) { - await tx - .insert(postTexts) - .values({ + await tx + .insert(postTexts) + .values( + extractedText.map((et) => ({ postId: post.uri, source: et.type, text: et.text, - }) - .onConflictDoNothing(); - } - - if (post.record.embed?.external) { - const embed = post.record.embed; - if (AppBskyEmbedExternal.isMain(embed)) { - const url = embed.external.uri; - if (!url.match(/(\w+\.(gif|png|jpeg|jpg))$/)) { - await addJob("scrape-external-url", { - url: embed.external.uri, - postId: post.uri, - }); - } + })) + ) + .onConflictDoNothing(); + }); + if (post.record.embed?.external) { + const embed = post.record.embed; + if (AppBskyEmbedExternal.isMain(embed)) { + const url = embed.external.uri; + if (!url.match(/(\w+\.(gif|png|jpeg|jpg))$/)) { + await addJob("scrape-external-url", { + url: embed.external.uri, + postId: post.uri, + }); } } - }); + } } -- 2.51.2