re-fetch notes after create/edit to ensure they have all fields populated
This commit is contained in:
@@ -227,7 +227,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async create(user: MiUser & {
|
public async create(user: MiUser & {
|
||||||
id: MiUser['id'];
|
id: MiUser['id'];
|
||||||
username: MiUser['username'];
|
username: MiUser['username'];
|
||||||
host: MiUser['host'];
|
host: MiUser['host'];
|
||||||
@@ -539,7 +539,8 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||||||
await this.notesRepository.insert(insert);
|
await this.notesRepository.insert(insert);
|
||||||
}
|
}
|
||||||
|
|
||||||
return insert;
|
// Re-fetch note to get the default values of null / unset fields.
|
||||||
|
return await this.notesRepository.findOneByOrFail({ id: insert.id });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// duplicate key error
|
// duplicate key error
|
||||||
if (isDuplicateKeyValueError(e)) {
|
if (isDuplicateKeyValueError(e)) {
|
||||||
|
|||||||
@@ -574,12 +574,15 @@ export class NoteEditService implements OnApplicationShutdown {
|
|||||||
await this.notesRepository.update(oldnote.id, note);
|
await this.notesRepository.update(oldnote.id, note);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Re-fetch note to get the default values of null / unset fields.
|
||||||
|
const edited = await this.notesRepository.findOneByOrFail({ id: note.id });
|
||||||
|
|
||||||
setImmediate('post edited', { signal: this.#shutdownController.signal }).then(
|
setImmediate('post edited', { signal: this.#shutdownController.signal }).then(
|
||||||
() => this.postNoteEdited(note, oldnote, user, data, silent, tags!, mentionedUsers!),
|
() => this.postNoteEdited(edited, oldnote, user, data, silent, tags!, mentionedUsers!),
|
||||||
() => { /* aborted, ignore this */ },
|
() => { /* aborted, ignore this */ },
|
||||||
);
|
);
|
||||||
|
|
||||||
return note;
|
return edited;
|
||||||
} else {
|
} else {
|
||||||
return oldnote;
|
return oldnote;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user