fix (backend): update note_file on note edits

TODO: move these processes to services/note/edit.ts
This commit is contained in:
naskya 2024-03-26 19:42:19 +09:00
parent bd5e95a1f0
commit d1d0328f8b
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C

View file

@ -9,6 +9,7 @@ import {
UserProfiles,
Polls,
NoteEdits,
NoteFiles,
} from "@/models/index.js";
import type { DriveFile } from "@/models/entities/drive-file.js";
import type { IMentionedRemoteUsers, Note } from "@/models/entities/note.js";
@ -605,6 +606,13 @@ export default define(meta, paramDef, async (ps, user) => {
update.updatedAt = new Date();
await Notes.update(note.id, update);
if (update.fileIds != null) {
await NoteFiles.delete({ noteId: note.id });
await NoteFiles.insert(
update.fileIds.map((fileId) => ({ noteId: note.id, fileId })),
);
}
// Add NoteEdit history for the previous one
await NoteEdits.insert({
id: genId(),