ノートの編集履歴を見れるように(新規ノートのみ)
This commit is contained in:
parent
6840434661
commit
25763ee679
6 changed files with 47 additions and 1 deletions
16
packages/backend/migration/1696044626209-noteEditHistory.js
Normal file
16
packages/backend/migration/1696044626209-noteEditHistory.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class NoteEditHistory1696044626209 {
|
||||
name = 'NoteEditHistory1696044626209'
|
||||
|
||||
async up(queryRunner) {
|
||||
await queryRunner.query(`ALTER TABLE "note" ADD "noteEditHistory" varchar(3000) array DEFAULT '{}'`);
|
||||
}
|
||||
|
||||
async down(queryRunner) {
|
||||
await queryRunner.query(`ALTER TABLE "note" DROP "noteEditHistory"`);
|
||||
}
|
||||
}
|
||||
|
|
@ -309,6 +309,7 @@ export class NoteEntityService implements OnModuleInit {
|
|||
id: note.id,
|
||||
createdAt: note.createdAt.toISOString(),
|
||||
updatedAt: note.updatedAt ? note.updatedAt.toISOString() : undefined,
|
||||
noteEditHistory: note.noteEditHistory.length ? note.noteEditHistory : undefined,
|
||||
userId: note.userId,
|
||||
user: this.userEntityService.pack(note.user ?? note.userId, me, {
|
||||
detail: false,
|
||||
|
|
|
|||
|
|
@ -29,6 +29,13 @@ export class MiNote {
|
|||
})
|
||||
public updatedAt: Date | null;
|
||||
|
||||
@Column('varchar', {
|
||||
length: 3000,
|
||||
array: true,
|
||||
default: '{}',
|
||||
})
|
||||
public noteEditHistory: string[];
|
||||
|
||||
@Index()
|
||||
@Column({
|
||||
...id(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,10 @@ export const packedNoteSchema = {
|
|||
optional: true, nullable: true,
|
||||
format: 'date-time',
|
||||
},
|
||||
noteEditHistory: {
|
||||
type: 'array',
|
||||
optional: true, nullable: false,
|
||||
},
|
||||
deletedAt: {
|
||||
type: 'string',
|
||||
optional: true, nullable: true,
|
||||
|
|
|
|||
|
|
@ -73,11 +73,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
if (note.userId !== me.id) {
|
||||
throw new ApiError(meta.errors.noSuchNote);
|
||||
}
|
||||
|
||||
await this.notesRepository.update({ id: note.id }, {
|
||||
updatedAt: new Date(),
|
||||
cw: ps.cw,
|
||||
text: ps.text,
|
||||
noteEditHistory: [...note.noteEditHistory, note.text!],
|
||||
});
|
||||
|
||||
this.globalEventService.publishNoteStream(note.id, 'updated', {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue