From 66429527ca4bb7bd69bff81c4cb8eab91f9fdcb3 Mon Sep 17 00:00:00 2001 From: cutestnekoaqua Date: Wed, 29 Mar 2023 21:15:06 +0200 Subject: [PATCH] catch errors --- .../src/queue/processors/db/import-posts.ts | 59 ++++++++++--------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/packages/backend/src/queue/processors/db/import-posts.ts b/packages/backend/src/queue/processors/db/import-posts.ts index a1cfab7353..19576a97f2 100644 --- a/packages/backend/src/queue/processors/db/import-posts.ts +++ b/packages/backend/src/queue/processors/db/import-posts.ts @@ -80,34 +80,39 @@ export async function importPosts( } } else { for (const post of parsed.orderedItems) { - linenum++; - if (post.inReplyTo != null) { - logger.info(`Is reply, skip [${linenum}] ...`); - continue; + try { + linenum++; + if (post.inReplyTo != null) { + logger.info(`Is reply, skip [${linenum}] ...`); + continue; + } + if (post.directMessage) { + logger.info(`Is dm, skip [${linenum}] ...`); + continue; + } + const text = htmlToMfm(post.content, post.tag); + logger.info(`Posting[${linenum}] ...`); + + const note = await create(user, { + createdAt: new Date(post.published), + files: undefined, + poll: undefined, + text: text || undefined, + reply: null, + renote: null, + cw: post.sensitive, + localOnly: false, + visibility: "public", + visibleUsers: [], + channel: null, + apMentions: null, + apHashtags: undefined, + apEmojis: undefined, + }); + } catch (e) { + logger.warn(`Error in line:${linenum} ${e}`); } - if (post.directMessage) { - logger.info(`Is dm, skip [${linenum}] ...`); - continue; - } - const text = htmlToMfm(post.content, post.tag); - logger.info(`Posting[${linenum}] ...`); - - const note = await create(user, { - createdAt: new Date(post.published), - files: undefined, - poll: undefined, - text: text || undefined, - reply: null, - renote: null, - cw: post.sensitive, - localOnly: false, - visibility: "public", - visibleUsers: [], - channel: null, - apMentions: null, - apHashtags: undefined, - apEmojis: undefined, - }); + } } } catch (e) {