wip
This commit is contained in:
parent
1766e923db
commit
7352387045
|
|
@ -23,6 +23,7 @@ import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { MetaService } from '@/core/MetaService.js';
|
import { MetaService } from '@/core/MetaService.js';
|
||||||
import { SearchService } from '@/core/SearchService.js';
|
import { SearchService } from '@/core/SearchService.js';
|
||||||
|
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class NoteDeleteService {
|
export class NoteDeleteService {
|
||||||
|
|
@ -48,6 +49,7 @@ export class NoteDeleteService {
|
||||||
private apDeliverManagerService: ApDeliverManagerService,
|
private apDeliverManagerService: ApDeliverManagerService,
|
||||||
private metaService: MetaService,
|
private metaService: MetaService,
|
||||||
private searchService: SearchService,
|
private searchService: SearchService,
|
||||||
|
private moderationLogService: ModerationLogService,
|
||||||
private notesChart: NotesChart,
|
private notesChart: NotesChart,
|
||||||
private perUserNotesChart: PerUserNotesChart,
|
private perUserNotesChart: PerUserNotesChart,
|
||||||
private instanceChart: InstanceChart,
|
private instanceChart: InstanceChart,
|
||||||
|
|
@ -58,7 +60,7 @@ export class NoteDeleteService {
|
||||||
* @param user 投稿者
|
* @param user 投稿者
|
||||||
* @param note 投稿
|
* @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 deletedAt = new Date();
|
||||||
const cascadingNotes = await this.findCascadingNotes(note);
|
const cascadingNotes = await this.findCascadingNotes(note);
|
||||||
|
|
||||||
|
|
@ -131,6 +133,14 @@ export class NoteDeleteService {
|
||||||
id: note.id,
|
id: note.id,
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (deleter && (note.userId !== deleter.id)) {
|
||||||
|
this.moderationLogService.log(deleter, 'deleteNote', {
|
||||||
|
noteId: note.id,
|
||||||
|
noteUserId: note.userId,
|
||||||
|
note: note,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ export const moderationLogTypes = [
|
||||||
'clearQueue',
|
'clearQueue',
|
||||||
'promoteQueue',
|
'promoteQueue',
|
||||||
'deleteDriveFile',
|
'deleteDriveFile',
|
||||||
|
'deleteNote',
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
export type ModerationLogPayloads = {
|
export type ModerationLogPayloads = {
|
||||||
|
|
@ -87,4 +88,9 @@ export type ModerationLogPayloads = {
|
||||||
fileId: string;
|
fileId: string;
|
||||||
fileUserId: string | null;
|
fileUserId: string | null;
|
||||||
};
|
};
|
||||||
|
deleteNote: {
|
||||||
|
noteId: string;
|
||||||
|
noteUserId: string;
|
||||||
|
note: any;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ export const moderationLogTypes = [
|
||||||
'clearQueue',
|
'clearQueue',
|
||||||
'promoteQueue',
|
'promoteQueue',
|
||||||
'deleteDriveFile',
|
'deleteDriveFile',
|
||||||
|
'deleteNote',
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
export type ModerationLogPayloads = {
|
export type ModerationLogPayloads = {
|
||||||
|
|
@ -105,4 +106,9 @@ export type ModerationLogPayloads = {
|
||||||
fileId: string;
|
fileId: string;
|
||||||
fileUserId: string | null;
|
fileUserId: string | null;
|
||||||
};
|
};
|
||||||
|
deleteNote: {
|
||||||
|
noteId: string;
|
||||||
|
noteUserId: string;
|
||||||
|
note: any;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue