Merge branch 'develop' of codeberg.org:calckey/calckey into develop
This commit is contained in:
commit
cb73e277e9
|
@ -9,6 +9,8 @@ import type { DbUserImportPostsJobData } from "@/queue/types.js";
|
||||||
import { queueLogger } from "../../logger.js";
|
import { queueLogger } from "../../logger.js";
|
||||||
import type Bull from "bull";
|
import type Bull from "bull";
|
||||||
import { htmlToMfm } from "@/remote/activitypub/misc/html-to-mfm.js";
|
import { htmlToMfm } from "@/remote/activitypub/misc/html-to-mfm.js";
|
||||||
|
import { resolveNote } from "@/remote/activitypub/models/note.js";
|
||||||
|
import { Note } from "@/models/entities/note.js";
|
||||||
|
|
||||||
const logger = queueLogger.createSubLogger("import-posts");
|
const logger = queueLogger.createSubLogger("import-posts");
|
||||||
|
|
||||||
|
@ -79,24 +81,26 @@ 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;
|
||||||
if (post.object.inReplyTo != null) {
|
if (post.object.inReplyTo != null) {
|
||||||
continue;
|
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}] ...`);
|
||||||
|
|
||||||
|
@ -105,7 +109,7 @@ export async function importPosts(
|
||||||
files: undefined,
|
files: undefined,
|
||||||
poll: undefined,
|
poll: undefined,
|
||||||
text: text || undefined,
|
text: text || undefined,
|
||||||
reply: null,
|
reply,
|
||||||
renote: null,
|
renote: null,
|
||||||
cw: post.sensitive,
|
cw: post.sensitive,
|
||||||
localOnly: false,
|
localOnly: false,
|
||||||
|
@ -121,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}`);
|
||||||
|
|
Loading…
Reference in New Issue