Skip to content

Commit

Permalink
enhance(backend): MisskeyIO#615 のパフォーマンス改善 (MisskeyIO#638)
Browse files Browse the repository at this point in the history
  • Loading branch information
u1-liquid authored May 24, 2024
1 parent 2b7f438 commit 9e4ff38
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,9 @@ export class ReportAbuseProcessorService {
forwarded: resolver.forward && job.data.targetUserHost !== null && job.data.reporterHost === null,
});

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

const activeWebhooks = await this.webhookService.getActiveWebhooks();
for (const webhook of activeWebhooks) {
const webhookUser = await this.usersRepository.findOneByOrFail({
id: webhook.userId,
});
const isAdmin = await this.roleService.isAdministrator(webhookUser);
if (webhook.on.includes('reportResolved') && isAdmin) {
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.on.includes('reportResolved'));
for (const webhook of webhooks) {
if (await this.roleService.isAdministrator({ id: webhook.userId, isRoot: false })) {
this.queueService.webhookDeliver(webhook, 'reportResolved', {
updatedReport,
});
Expand Down
10 changes: 3 additions & 7 deletions packages/backend/src/server/api/endpoints/users/report-abuse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
category: ps.category,
}).then(x => this.abuseUserReportsRepository.findOneByOrFail(x.identifiers[0]));

const activeWebhooks = await this.webhookService.getActiveWebhooks();
for (const webhook of activeWebhooks) {
const webhookUser = await this.usersRepository.findOneByOrFail({
id: webhook.userId,
});
const isAdmin = await this.roleService.isAdministrator(webhookUser);
if (webhook.on.includes('reportCreated') && isAdmin) {
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.on.includes('reportCreated'));
for (const webhook of webhooks) {
if (await this.roleService.isAdministrator({ id: webhook.userId, isRoot: false })) {
this.queueService.webhookDeliver(webhook, 'reportCreated', {
report,
});
Expand Down

0 comments on commit 9e4ff38

Please sign in to comment.