From 25763ee679dabc2a6e0b862e98357b79495e31bc Mon Sep 17 00:00:00 2001 From: GrapeApple0 <84321396+GrapeApple0@users.noreply.github.com> Date: Sat, 30 Sep 2023 05:53:12 +0000 Subject: [PATCH] =?UTF-8?q?=E3=83=8E=E3=83=BC=E3=83=88=E3=81=AE=E7=B7=A8?= =?UTF-8?q?=E9=9B=86=E5=B1=A5=E6=AD=B4=E3=82=92=E8=A6=8B=E3=82=8C=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB(=E6=96=B0=E8=A6=8F=E3=83=8E?= =?UTF-8?q?=E3=83=BC=E3=83=88=E3=81=AE=E3=81=BF)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migration/1696044626209-noteEditHistory.js | 16 ++++++++++++++++ .../src/core/entities/NoteEntityService.ts | 1 + packages/backend/src/models/Note.ts | 7 +++++++ .../backend/src/models/json-schema/note.ts | 4 ++++ .../src/server/api/endpoints/notes/update.ts | 2 +- .../frontend/src/components/MkNoteDetailed.vue | 18 ++++++++++++++++++ 6 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 packages/backend/migration/1696044626209-noteEditHistory.js diff --git a/packages/backend/migration/1696044626209-noteEditHistory.js b/packages/backend/migration/1696044626209-noteEditHistory.js new file mode 100644 index 0000000000..37a542aa1e --- /dev/null +++ b/packages/backend/migration/1696044626209-noteEditHistory.js @@ -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"`); + } +} diff --git a/packages/backend/src/core/entities/NoteEntityService.ts b/packages/backend/src/core/entities/NoteEntityService.ts index a024286b48..35dd23bbae 100644 --- a/packages/backend/src/core/entities/NoteEntityService.ts +++ b/packages/backend/src/core/entities/NoteEntityService.ts @@ -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, diff --git a/packages/backend/src/models/Note.ts b/packages/backend/src/models/Note.ts index f396a0cd7a..ac8c4632c1 100644 --- a/packages/backend/src/models/Note.ts +++ b/packages/backend/src/models/Note.ts @@ -29,6 +29,13 @@ export class MiNote { }) public updatedAt: Date | null; + @Column('varchar', { + length: 3000, + array: true, + default: '{}', + }) + public noteEditHistory: string[]; + @Index() @Column({ ...id(), diff --git a/packages/backend/src/models/json-schema/note.ts b/packages/backend/src/models/json-schema/note.ts index ad0cb3c45d..430801abf9 100644 --- a/packages/backend/src/models/json-schema/note.ts +++ b/packages/backend/src/models/json-schema/note.ts @@ -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, diff --git a/packages/backend/src/server/api/endpoints/notes/update.ts b/packages/backend/src/server/api/endpoints/notes/update.ts index cdf7f085e0..4381f81975 100644 --- a/packages/backend/src/server/api/endpoints/notes/update.ts +++ b/packages/backend/src/server/api/endpoints/notes/update.ts @@ -73,11 +73,11 @@ export default class extends Endpoint { // 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', { diff --git a/packages/frontend/src/components/MkNoteDetailed.vue b/packages/frontend/src/components/MkNoteDetailed.vue index ab8886e8ba..8afb3acb1f 100644 --- a/packages/frontend/src/components/MkNoteDetailed.vue +++ b/packages/frontend/src/components/MkNoteDetailed.vue @@ -137,6 +137,7 @@ SPDX-License-Identifier: AGPL-3.0-only +
@@ -173,6 +174,13 @@ SPDX-License-Identifier: AGPL-3.0-only
+
+
+
+ +
+
+
@@ -192,6 +200,7 @@ import * as mfm from 'mfm-js'; import * as Misskey from 'misskey-js'; import MkNoteSub from '@/components/MkNoteSub.vue'; import MkNoteSimple from '@/components/MkNoteSimple.vue'; +import MkNotePreview from '@/components/MkNotePreview.vue'; import MkReactionsViewer from '@/components/MkReactionsViewer.vue'; import MkMediaList from '@/components/MkMediaList.vue'; import MkCwButton from '@/components/MkCwButton.vue'; @@ -747,6 +756,9 @@ function loadConversation() { padding: 16px; } +.tab_history { + padding: 16px; +} .reactionTabs { display: flex; gap: 8px; @@ -810,6 +822,12 @@ function loadConversation() { } } +.historyNote { + padding-top: 10px; + min-height: 75px; + overflow: auto; +} + .muted { padding: 8px; text-align: center;