update post import

This commit is contained in:
April John 2023-05-24 20:21:15 +02:00
parent 2ce76a7097
commit 208c7d380a
3 changed files with 10 additions and 3 deletions

View File

@ -19,6 +19,8 @@ export function initialize<T>(name: string, limitPerSec = -1) {
} }
: undefined, : undefined,
settings: { settings: {
stalledInterval: 60,
maxStalledCount: 2,
backoffStrategies: { backoffStrategies: {
apBackoff, apBackoff,
}, },

View File

@ -20,9 +20,11 @@ export async function importMastoPost(
} }
const post = job.data.post; const post = job.data.post;
let reply: Note | null = null; let reply: Note | null = null;
job.progress(20);
if (post.object.inReplyTo != null) { if (post.object.inReplyTo != null) {
reply = await resolveNote(post.object.inReplyTo); reply = await resolveNote(post.object.inReplyTo);
} }
job.progress(40);
if (post.directMessage) { if (post.directMessage) {
done(); done();
return; return;
@ -33,13 +35,14 @@ export async function importMastoPost(
return; return;
} }
} }
job.progress(60);
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) {
throw e; throw e;
} }
job.progress(80);
const note = await create(user, { const note = await create(user, {
createdAt: new Date(post.object.published), createdAt: new Date(post.object.published),
files: undefined, files: undefined,
@ -56,6 +59,8 @@ export async function importMastoPost(
apHashtags: undefined, apHashtags: undefined,
apEmojis: undefined, apEmojis: undefined,
}); });
logger.succ("Imported"); job.progress(100);
done(); done();
logger.succ("Imported");
} }

View File

@ -20,7 +20,7 @@ export const inboxQueue = initializeQueue<InboxJobData>(
"inbox", "inbox",
config.inboxJobPerSec || 16, config.inboxJobPerSec || 16,
); );
export const dbQueue = initializeQueue<DbJobData>("db"); export const dbQueue = initializeQueue<DbJobData>("db", 256);
export const objectStorageQueue = export const objectStorageQueue =
initializeQueue<ObjectStorageJobData>("objectStorage"); initializeQueue<ObjectStorageJobData>("objectStorage");
export const webhookDeliverQueue = initializeQueue<WebhookDeliverJobData>( export const webhookDeliverQueue = initializeQueue<WebhookDeliverJobData>(