fix (backend): update note_file on note edits
TODO: move these processes to services/note/edit.ts
This commit is contained in:
parent
bd5e95a1f0
commit
d1d0328f8b
1 changed files with 8 additions and 0 deletions
|
@ -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(),
|
||||
|
|
Loading…
Reference in a new issue