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,46 +81,48 @@ 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) {
try { async () =>{
linenum++;
let reply: Note | null = null;
if (post.object.inReplyTo != null) {
reply = await resolveNote(post.object.inReplyTo);
}
if (post.directMessage) {
continue;
}
if (job.data.signatureCheck) {
if (!post.signature) {
continue;
}
}
let text;
try { try {
text = htmlToMfm(post.object.content, post.object.tag); linenum++;
let reply: Note | null = null;
if (post.object.inReplyTo != null) {
reply = await resolveNote(post.object.inReplyTo);
}
if (post.directMessage) {
return;
}
if (job.data.signatureCheck) {
if (!post.signature) {
return;
}
}
let text;
try {
text = htmlToMfm(post.object.content, post.object.tag);
} catch (e) {
return;
}
logger.info(`Posting[${linenum}] ...`);
const note = await create(user, {
createdAt: new Date(post.object.published),
files: undefined,
poll: undefined,
text: text || undefined,
reply,
renote: null,
cw: post.sensitive,
localOnly: false,
visibility: "hidden",
visibleUsers: [],
channel: null,
apMentions: new Array(0),
apHashtags: undefined,
apEmojis: undefined,
});
} catch (e) { } catch (e) {
continue; logger.warn(`Error in line:${linenum} ${e}`);
} }
logger.info(`Posting[${linenum}] ...`);
const note = await create(user, {
createdAt: new Date(post.object.published),
files: undefined,
poll: undefined,
text: text || undefined,
reply,
renote: null,
cw: post.sensitive,
localOnly: false,
visibility: "hidden",
visibleUsers: [],
channel: null,
apMentions: new Array(0),
apHashtags: undefined,
apEmojis: undefined,
});
} catch (e) {
logger.warn(`Error in line:${linenum} ${e}`);
} }
} }
} }