fix: run post import async

This commit is contained in:
April John 2023-05-08 22:30:40 +02:00
parent ecf263bd91
commit 3bedd1b347
1 changed files with 39 additions and 37 deletions

View File

@ -81,6 +81,7 @@ export async function importPosts(
} else if (parsed instanceof Object) { } else if (parsed instanceof Object) {
logger.info("Parsing animal style posts"); logger.info("Parsing animal style posts");
for (const post of parsed.orderedItems) { for (const post of parsed.orderedItems) {
async () =>{
try { try {
linenum++; linenum++;
let reply: Note | null = null; let reply: Note | null = null;
@ -88,18 +89,18 @@ export async function importPosts(
reply = await resolveNote(post.object.inReplyTo); reply = await resolveNote(post.object.inReplyTo);
} }
if (post.directMessage) { if (post.directMessage) {
continue; return;
} }
if (job.data.signatureCheck) { if (job.data.signatureCheck) {
if (!post.signature) { if (!post.signature) {
continue; return;
} }
} }
let text; let text;
try { try {
text = htmlToMfm(post.object.content, post.object.tag); text = htmlToMfm(post.object.content, post.object.tag);
} catch (e) { } catch (e) {
continue; return;
} }
logger.info(`Posting[${linenum}] ...`); logger.info(`Posting[${linenum}] ...`);
@ -124,6 +125,7 @@ export async function importPosts(
} }
} }
} }
}
} catch (e) { } catch (e) {
// handle error // handle error
logger.warn(`Error reading: ${e}`); logger.warn(`Error reading: ${e}`);