Merge remote-tracking branch 'misskey-mattyatea/report' into develop
# Conflicts: # locales/index.d.ts # locales/ja-JP.yml # packages/backend/src/models/Meta.ts # packages/backend/src/server/api/endpoints/admin/meta.ts # packages/backend/src/server/api/endpoints/admin/update-meta.ts
This commit is contained in:
commit
7a3eb26c4d
16 changed files with 276 additions and 71 deletions
|
|
@ -158,6 +158,8 @@ export interface AdminEventTypes {
|
|||
targetUserId: MiUser['id'],
|
||||
reporterId: MiUser['id'],
|
||||
comment: string;
|
||||
notes: any[];
|
||||
noteIds: string[];
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,14 @@
|
|||
*/
|
||||
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { In } from 'typeorm';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { AbuseUserReportsRepository } from '@/models/_.js';
|
||||
import type { AbuseUserReportsRepository, NotesRepository } from '@/models/_.js';
|
||||
import { awaitAll } from '@/misc/prelude/await-all.js';
|
||||
import type { MiAbuseUserReport } from '@/models/AbuseUserReport.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { IdService } from '@/core/IdService.js';
|
||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||
import { UserEntityService } from './UserEntityService.js';
|
||||
|
||||
@Injectable()
|
||||
|
|
@ -18,7 +20,11 @@ export class AbuseUserReportEntityService {
|
|||
@Inject(DI.abuseUserReportsRepository)
|
||||
private abuseUserReportsRepository: AbuseUserReportsRepository,
|
||||
|
||||
@Inject(DI.notesRepository)
|
||||
private notesRepository: NotesRepository,
|
||||
|
||||
private userEntityService: UserEntityService,
|
||||
private noteEntityService: NoteEntityService,
|
||||
private idService: IdService,
|
||||
) {
|
||||
}
|
||||
|
|
@ -28,11 +34,27 @@ export class AbuseUserReportEntityService {
|
|||
src: MiAbuseUserReport['id'] | MiAbuseUserReport,
|
||||
) {
|
||||
const report = typeof src === 'object' ? src : await this.abuseUserReportsRepository.findOneByOrFail({ id: src });
|
||||
const notes = [];
|
||||
|
||||
if (report.noteIds && report.noteIds.length > 0) {
|
||||
for (const x of report.noteIds) {
|
||||
const exists = await this.notesRepository.countBy({ id: x });
|
||||
if (exists === 0) {
|
||||
notes.push('deleted');
|
||||
continue;
|
||||
}
|
||||
notes.push(await this.noteEntityService.pack(x));
|
||||
}
|
||||
} else if (report.notes.length > 0) {
|
||||
notes.push(...(report.notes));
|
||||
}
|
||||
|
||||
console.log(report.notes.length, null, notes);
|
||||
return await awaitAll({
|
||||
id: report.id,
|
||||
createdAt: this.idService.parse(report.id).date.toISOString(),
|
||||
comment: report.comment,
|
||||
notes,
|
||||
resolved: report.resolved,
|
||||
reporterId: report.reporterId,
|
||||
targetUserId: report.targetUserId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue