mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-12-13 10:28:25 +00:00
fix users/report-abuse endpoint being really slow
This commit is contained in:
parent
51ad31b5a4
commit
84ca3621d8
2 changed files with 9 additions and 6 deletions
|
|
@ -14,6 +14,7 @@ import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
|
||||||
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||||
import { SystemAccountService } from '@/core/SystemAccountService.js';
|
import { SystemAccountService } from '@/core/SystemAccountService.js';
|
||||||
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
||||||
|
import { trackPromise } from '@/misc/promise-tracker.js';
|
||||||
import { IdService } from './IdService.js';
|
import { IdService } from './IdService.js';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
|
@ -68,11 +69,11 @@ export class AbuseReportService {
|
||||||
reports.push(report);
|
reports.push(report);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.all([
|
trackPromise(Promise.all([
|
||||||
this.abuseReportNotificationService.notifyAdminStream(reports),
|
this.abuseReportNotificationService.notifyAdminStream(reports),
|
||||||
this.abuseReportNotificationService.notifySystemWebhook(reports, 'abuseReport'),
|
this.abuseReportNotificationService.notifySystemWebhook(reports, 'abuseReport'),
|
||||||
this.abuseReportNotificationService.notifyMail(reports),
|
this.abuseReportNotificationService.notifyMail(reports),
|
||||||
]);
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import { GetterService } from '@/server/api/GetterService.js';
|
||||||
import { RoleService } from '@/core/RoleService.js';
|
import { RoleService } from '@/core/RoleService.js';
|
||||||
import { AbuseReportService } from '@/core/AbuseReportService.js';
|
import { AbuseReportService } from '@/core/AbuseReportService.js';
|
||||||
import { ApiError } from '../../error.js';
|
import { ApiError } from '../../error.js';
|
||||||
|
import { CacheService } from '@/core/CacheService.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['users'],
|
tags: ['users'],
|
||||||
|
|
@ -60,13 +61,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
private getterService: GetterService,
|
private getterService: GetterService,
|
||||||
private roleService: RoleService,
|
private roleService: RoleService,
|
||||||
private abuseReportService: AbuseReportService,
|
private abuseReportService: AbuseReportService,
|
||||||
|
private readonly cacheService: CacheService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
// Lookup user
|
// Lookup user
|
||||||
const targetUser = await this.getterService.getUser(ps.userId).catch(err => {
|
const targetUser = await this.cacheService.findOptionalUserById(ps.userId);
|
||||||
if (err.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
|
if (!targetUser) {
|
||||||
throw err;
|
throw new ApiError(meta.errors.noSuchUser);
|
||||||
});
|
}
|
||||||
|
|
||||||
if (targetUser.id === me.id) {
|
if (targetUser.id === me.id) {
|
||||||
throw new ApiError(meta.errors.cannotReportYourself);
|
throw new ApiError(meta.errors.cannotReportYourself);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue