This commit is contained in:
syuilo 2023-09-23 18:06:26 +09:00
parent 1766e923db
commit 7352387045
4 changed files with 24 additions and 2 deletions

View File

@ -23,6 +23,7 @@ import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { bindThis } from '@/decorators.js';
import { MetaService } from '@/core/MetaService.js';
import { SearchService } from '@/core/SearchService.js';
import { ModerationLogService } from '@/core/ModerationLogService.js';
@Injectable()
export class NoteDeleteService {
@ -48,6 +49,7 @@ export class NoteDeleteService {
private apDeliverManagerService: ApDeliverManagerService,
private metaService: MetaService,
private searchService: SearchService,
private moderationLogService: ModerationLogService,
private notesChart: NotesChart,
private perUserNotesChart: PerUserNotesChart,
private instanceChart: InstanceChart,
@ -58,7 +60,7 @@ export class NoteDeleteService {
* @param user 稿
* @param note 稿
*/
async delete(user: { id: MiUser['id']; uri: MiUser['uri']; host: MiUser['host']; isBot: MiUser['isBot']; }, note: MiNote, quiet = false) {
async delete(user: { id: MiUser['id']; uri: MiUser['uri']; host: MiUser['host']; isBot: MiUser['isBot']; }, note: MiNote, quiet = false, deleter?: MiUser) {
const deletedAt = new Date();
const cascadingNotes = await this.findCascadingNotes(note);
@ -131,6 +133,14 @@ export class NoteDeleteService {
id: note.id,
userId: user.id,
});
if (deleter && (note.userId !== deleter.id)) {
this.moderationLogService.log(deleter, 'deleteNote', {
noteId: note.id,
noteUserId: note.userId,
note: note,
});
}
}
@bindThis

View File

@ -70,7 +70,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}
// この操作を行うのが投稿者とは限らない(例えばモデレーター)ため
await this.noteDeleteService.delete(await this.usersRepository.findOneByOrFail({ id: note.userId }), note);
await this.noteDeleteService.delete(await this.usersRepository.findOneByOrFail({ id: note.userId }), note, false, me);
});
}
}

View File

@ -40,6 +40,7 @@ export const moderationLogTypes = [
'clearQueue',
'promoteQueue',
'deleteDriveFile',
'deleteNote',
] as const;
export type ModerationLogPayloads = {
@ -87,4 +88,9 @@ export type ModerationLogPayloads = {
fileId: string;
fileUserId: string | null;
};
deleteNote: {
noteId: string;
noteUserId: string;
note: any;
}
};

View File

@ -58,6 +58,7 @@ export const moderationLogTypes = [
'clearQueue',
'promoteQueue',
'deleteDriveFile',
'deleteNote',
] as const;
export type ModerationLogPayloads = {
@ -105,4 +106,9 @@ export type ModerationLogPayloads = {
fileId: string;
fileUserId: string | null;
};
deleteNote: {
noteId: string;
noteUserId: string;
note: any;
}
};