mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-22 17:03:49 +01:00
Merge branch 'develop' of codeberg.org:calckey/calckey into develop
This commit is contained in:
commit
72b224a40c
@ -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,45 +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++;
|
|
||||||
if (post.object.inReplyTo != null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
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++;
|
||||||
} catch (e) {
|
let reply: Note | null = null;
|
||||||
continue;
|
if (post.object.inReplyTo != null) {
|
||||||
}
|
reply = await resolveNote(post.object.inReplyTo);
|
||||||
logger.info(`Posting[${linenum}] ...`);
|
}
|
||||||
|
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, {
|
const note = await create(user, {
|
||||||
createdAt: new Date(post.object.published),
|
createdAt: new Date(post.object.published),
|
||||||
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,
|
||||||
visibility: "hidden",
|
visibility: "hidden",
|
||||||
visibleUsers: [],
|
visibleUsers: [],
|
||||||
channel: null,
|
channel: null,
|
||||||
apMentions: new Array(0),
|
apMentions: new Array(0),
|
||||||
apHashtags: undefined,
|
apHashtags: undefined,
|
||||||
apEmojis: undefined,
|
apEmojis: undefined,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.warn(`Error in line:${linenum} ${e}`);
|
logger.warn(`Error in line:${linenum} ${e}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user