chore: make DeletedNote hold replyUserId and renoteUserId

This commit is contained in:
anatawa12 2025-08-02 22:47:07 +09:00
parent 14515994fd
commit 82e8c5ff25
No known key found for this signature in database
GPG Key ID: 9CA909848B8E4EA6
4 changed files with 21 additions and 1 deletions

View File

@ -7,7 +7,7 @@ export class DeletedNote1754137937997 {
name = 'DeletedNote1754137937997'
async up(queryRunner) {
await queryRunner.query(`CREATE TABLE "deleted_note" ("id" character varying(32) NOT NULL, "deletedAt" TIMESTAMP WITH TIME ZONE, "replyId" character varying(32), "renoteId" character varying(32), "userId" character varying(32) NOT NULL, "localOnly" boolean NOT NULL DEFAULT false, "uri" character varying(512), "url" character varying(512), "channelId" character varying(32), CONSTRAINT "PK_1cb67148b7b707a03c63b2165fc" PRIMARY KEY ("id")); COMMENT ON COLUMN "deleted_note"."replyId" IS 'The ID of reply target.'; COMMENT ON COLUMN "deleted_note"."renoteId" IS 'The ID of renote target.'; COMMENT ON COLUMN "deleted_note"."userId" IS 'The ID of author.'; COMMENT ON COLUMN "deleted_note"."uri" IS 'The URI of a note. it will be null when the note is local.'; COMMENT ON COLUMN "deleted_note"."url" IS 'The human readable url of a note. it will be null when the note is local.'; COMMENT ON COLUMN "deleted_note"."channelId" IS 'The ID of source channel.'`);
await queryRunner.query(`CREATE TABLE "deleted_note" ("id" character varying(32) NOT NULL, "deletedAt" TIMESTAMP WITH TIME ZONE, "replyId" character varying(32), "renoteId" character varying(32), "userId" character varying(32) NOT NULL, "localOnly" boolean NOT NULL DEFAULT false, "uri" character varying(512), "url" character varying(512), "channelId" character varying(32), "replyUserId" character varying(32), "renoteUserId" character varying(32), CONSTRAINT "PK_1cb67148b7b707a03c63b2165fc" PRIMARY KEY ("id")); COMMENT ON COLUMN "deleted_note"."replyId" IS 'The ID of reply target.'; COMMENT ON COLUMN "deleted_note"."renoteId" IS 'The ID of renote target.'; COMMENT ON COLUMN "deleted_note"."userId" IS 'The ID of author.'; COMMENT ON COLUMN "deleted_note"."uri" IS 'The URI of a note. it will be null when the note is local.'; COMMENT ON COLUMN "deleted_note"."url" IS 'The human readable url of a note. it will be null when the note is local.'; COMMENT ON COLUMN "deleted_note"."channelId" IS 'The ID of source channel.'; COMMENT ON COLUMN "deleted_note"."replyUserId" IS '[Denormalized]'; COMMENT ON COLUMN "deleted_note"."renoteUserId" IS '[Denormalized]'`);
await queryRunner.query(`CREATE INDEX "IDX_12797cfa4c15d03d0dd649bc4b" ON "deleted_note" ("replyId") `);
await queryRunner.query(`CREATE INDEX "IDX_b6a4a8f31a98ddc5e07995c840" ON "deleted_note" ("renoteId") `);
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_95c76b088692f600b7a5352a4b" ON "deleted_note" ("uri") `);

View File

@ -130,6 +130,8 @@ export class NoteDeleteService {
uri: note.uri,
url: note.url,
channelId: note.channelId,
replyUserId: note.replyUserId,
renoteUserId: note.renoteUserId,
});
});

View File

@ -99,6 +99,20 @@ export class MiDeletedNote {
})
public channelId: MiChannel['id'] | null;
@Column({
...id(),
nullable: true,
comment: '[Denormalized]',
})
public replyUserId: MiUser['id'] | null;
@Column({
...id(),
nullable: true,
comment: '[Denormalized]',
})
public renoteUserId: MiUser['id'] | null;
@ManyToOne(type => MiChannel, {
onDelete: 'CASCADE',
})

View File

@ -86,6 +86,8 @@ export class CleanRemoteNotesProcessorService {
'uri',
'url',
'channelId',
'replyUserId',
'renoteUserId',
] as const];
let notes: Pick<MiNote, typeof selectColumns[number]>[] = await this.notesRepository.find({
where: {
@ -156,6 +158,8 @@ export class CleanRemoteNotesProcessorService {
localOnly: note.localOnly,
uri: note.uri,
url: note.url,
replyUserId: note.replyUserId,
renoteUserId: note.renoteUserId,
})));
await transaction.delete(MiNote, notes.map(note => note.id));
});