1
0
mirror of https://github.com/MisskeyIO/misskey synced 2024-11-27 14:28:49 +09:00

enhance(backend): MisskeyIO#615 のパフォーマンス改善 (MisskeyIO#638)

This commit is contained in:
まっちゃとーにゅ 2024-05-24 21:40:09 +09:00 committed by GitHub
parent 2b7f438862
commit 9e4ff380ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 21 deletions

View File

@ -88,13 +88,9 @@ export class ReportAbuseProcessorService {
forwarded: resolver.forward && job.data.targetUserHost !== null && job.data.reporterHost === null, forwarded: resolver.forward && job.data.targetUserHost !== null && job.data.reporterHost === null,
}); });
const activeWebhooks = await this.webhookService.getActiveWebhooks(); const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.on.includes('reportAutoResolved'));
for (const webhook of activeWebhooks) { for (const webhook of webhooks) {
const webhookUser = await this.usersRepository.findOneByOrFail({ if (await this.roleService.isAdministrator({ id: webhook.userId, isRoot: false })) {
id: webhook.userId,
});
const isAdmin = await this.roleService.isAdministrator(webhookUser);
if (webhook.on.includes('reportAutoResolved') && isAdmin) {
this.queueService.webhookDeliver(webhook, 'reportAutoResolved', { this.queueService.webhookDeliver(webhook, 'reportAutoResolved', {
resolver: resolver, resolver: resolver,
report: job.data, report: job.data,

View File

@ -69,13 +69,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
forwarded: ps.forward && report.targetUserHost != null, forwarded: ps.forward && report.targetUserHost != null,
}).then(() => this.abuseUserReportsRepository.findOneBy({ id: ps.reportId })); }).then(() => this.abuseUserReportsRepository.findOneBy({ id: ps.reportId }));
const activeWebhooks = await this.webhookService.getActiveWebhooks(); const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.on.includes('reportResolved'));
for (const webhook of activeWebhooks) { for (const webhook of webhooks) {
const webhookUser = await this.usersRepository.findOneByOrFail({ if (await this.roleService.isAdministrator({ id: webhook.userId, isRoot: false })) {
id: webhook.userId,
});
const isAdmin = await this.roleService.isAdministrator(webhookUser);
if (webhook.on.includes('reportResolved') && isAdmin) {
this.queueService.webhookDeliver(webhook, 'reportResolved', { this.queueService.webhookDeliver(webhook, 'reportResolved', {
updatedReport, updatedReport,
}); });

View File

@ -100,13 +100,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
category: ps.category, category: ps.category,
}).then(x => this.abuseUserReportsRepository.findOneByOrFail(x.identifiers[0])); }).then(x => this.abuseUserReportsRepository.findOneByOrFail(x.identifiers[0]));
const activeWebhooks = await this.webhookService.getActiveWebhooks(); const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.on.includes('reportCreated'));
for (const webhook of activeWebhooks) { for (const webhook of webhooks) {
const webhookUser = await this.usersRepository.findOneByOrFail({ if (await this.roleService.isAdministrator({ id: webhook.userId, isRoot: false })) {
id: webhook.userId,
});
const isAdmin = await this.roleService.isAdministrator(webhookUser);
if (webhook.on.includes('reportCreated') && isAdmin) {
this.queueService.webhookDeliver(webhook, 'reportCreated', { this.queueService.webhookDeliver(webhook, 'reportCreated', {
report, report,
}); });