diff --git a/packages/backend/src/misc/post.ts b/packages/backend/src/misc/post.ts deleted file mode 100644 index fd89a4d7e3..0000000000 --- a/packages/backend/src/misc/post.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { noteVisibilities } from "@/types.js"; - -export type Post = { - text: string | undefined; - cw: string | null; - localOnly: boolean; - createdAt: Date; - visibility: string; -}; - -export function parse(acct: any): Post { - return { - text: acct.text || undefined, - cw: acct.cw, - localOnly: acct.localOnly, - createdAt: new Date(acct.createdAt), - visibility: noteVisibilities.includes(acct.visibility) - ? acct.visibility - : "specified", - }; -} - -export function toJson(acct: Post): string { - return { text: acct.text, cw: acct.cw, localOnly: acct.localOnly }.toString(); -} diff --git a/packages/backend/src/queue/processors/db/import-firefish-post.ts b/packages/backend/src/queue/processors/db/import-firefish-post.ts index 8d318a0d2a..d0044819ec 100644 --- a/packages/backend/src/queue/processors/db/import-firefish-post.ts +++ b/packages/backend/src/queue/processors/db/import-firefish-post.ts @@ -1,4 +1,3 @@ -import * as Post from "@/misc/post.js"; import create from "@/services/note/create.js"; import { NoteFiles, Users } from "@/models/index.js"; import type { DbUserImportMastoPostJobData } from "@/queue/types.js"; @@ -10,6 +9,7 @@ import { createImportCkPostJob } from "@/queue/index.js"; import { Notes, NoteEdits } from "@/models/index.js"; import type { Note } from "@/models/entities/note.js"; import { genId } from "backend-rs"; +import { noteVisibilities } from "@/types.js"; const logger = queueLogger.createSubLogger("import-firefish-post"); @@ -52,10 +52,15 @@ export async function importCkPost( logger.info(`Skipped adding file to drive: ${url}`); } } - const { text, cw, localOnly, createdAt, visibility } = Post.parse(post); + + const createdAt = new Date(post.createdAt); + const visibility = noteVisibilities.includes(post.visibility) + ? post.visibility + : "specified"; + let note = await Notes.findOneBy({ - createdAt: createdAt, - text: text, + createdAt, + text: post.text || undefined, userId: user.id, }); @@ -95,16 +100,16 @@ export async function importCkPost( note = await create( user, { - createdAt: createdAt, + createdAt, scheduledAt: undefined, files: files.length === 0 ? undefined : files, poll: undefined, - text: text || undefined, + text: post.text || undefined, reply: post.replyId ? job.data.parent : null, renote: post.renoteId ? job.data.parent : null, - cw: cw, - localOnly, - visibility: visibility, + cw: post.cw, + localOnly: post.localOnly, + visibility, visibleUsers: [], channel: null, apMentions: new Array(0),