mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-22 10:15:10 +00:00
fail AbuseReportService.resolve
harder without remote users
as @fEmber noticed, if `findOneByOrFail` throws, we would have marked the report as resolved, without logging that this way, the whole operation fails (the frontend should not send us ids of users that can't be resolved!)
This commit is contained in:
parent
dadf6496d1
commit
6379deb5a7
1 changed files with 13 additions and 2 deletions
|
@ -93,6 +93,17 @@ export class AbuseReportService {
|
|||
id: In(params.map(it => it.reportId)),
|
||||
});
|
||||
|
||||
const targetUserMap = new Map();
|
||||
for (const report of reports) {
|
||||
const shouldForward = paramsMap.get(report.id)!.forward;
|
||||
|
||||
if (shouldForward && report.targetUserHost != null) {
|
||||
return targetUserMap.set(report.id, await this.usersRepository.findOneByOrFail({ id: report.targetUserId }));
|
||||
} else {
|
||||
return targetUserMap.set(report.id, null);
|
||||
}
|
||||
}
|
||||
|
||||
for (const report of reports) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const ps = paramsMap.get(report.id)!;
|
||||
|
@ -103,9 +114,9 @@ export class AbuseReportService {
|
|||
forwarded: ps.forward && report.targetUserHost !== null,
|
||||
});
|
||||
|
||||
if (ps.forward && report.targetUserHost != null) {
|
||||
const targetUser = targetUserMap.get(report.id)!;
|
||||
if (targetUser != null) {
|
||||
const actor = await this.instanceActorService.getInstanceActor();
|
||||
const targetUser = await this.usersRepository.findOneByOrFail({ id: report.targetUserId });
|
||||
|
||||
// eslint-disable-next-line
|
||||
const flag = this.apRendererService.renderFlag(actor, targetUser.uri!, report.comment);
|
||||
|
|
Loading…
Reference in a new issue