feat: 通報の即時解決機能を追加 (#113)

* feat: 通報の即時解決機能を追加

* fix: 条件変更時に有効期限を変更していないのに勝手に更新される問題を修正

* fix: 条件のパターンの削除ができない問題を修正

* fix: リソルバーの通報を解決する判定基準が間違っていたのを修正

* fix: 変更する変数が間違っていたのを修正

* fix: getUTCMonthはゼロ始まりかも

* enhance: Storybookのストーリーを作成

* fix: 色々修正

* fix: 型エラーを修正

* [ci skip] Update CHANGELOG.md

* [ci skip] Update CHANGELOG.md

* Update CHANGELOG.md

* リファクタリング

* refactor: 型定義をよりよくした

* refactor: beforeExpiresAtの初期値はundefinedの方がいい

* refactor: 変数の名前を変更

* Fix: リモートサーバーから転送された通報も対象に追加

* Update CHANGELOG.md

* take review

---------

Co-authored-by: Chocolate Pie <106949016+chocolate-pie@users.noreply.github.com>
This commit is contained in:
まっちゃとーにゅ
2023-07-28 01:17:17 +09:00
committed by GitHub
parent 27f57b031b
commit 0bed053b7d
29 changed files with 1059 additions and 44 deletions

View File

@@ -2,6 +2,7 @@ import { randomUUID } from 'node:crypto';
import { Inject, Injectable } from '@nestjs/common';
import type { IActivity } from '@/core/activitypub/type.js';
import type { DriveFile } from '@/models/entities/DriveFile.js';
import type { AbuseUserReport } from '@/models/entities/AbuseUserReport.js';
import type { Webhook, webhookEventTypes } from '@/models/entities/Webhook.js';
import type { Config } from '@/config.js';
import { DI } from '@/di-symbols.js';
@@ -336,6 +337,11 @@ export class QueueService {
});
}
@bindThis
public createReportAbuseJob(report: AbuseUserReport) {
return this.dbQueue.add('reportAbuse', report);
}
@bindThis
public createFollowJob(followings: { from: ThinUser, to: ThinUser, requestId?: string, silent?: boolean }[]) {
const jobs = followings.map(rel => this.generateRelationshipJobData('follow', rel));

View File

@@ -512,7 +512,7 @@ export class ApInboxService {
});
if (users.length < 1) return 'skip';
await this.abuseUserReportsRepository.insert({
const report = await this.abuseUserReportsRepository.insert({
id: this.idService.genId(),
createdAt: new Date(),
targetUserId: users[0].id,
@@ -520,7 +520,9 @@ export class ApInboxService {
reporterId: actor.id,
reporterHost: actor.host,
comment: `${activity.content}\n${JSON.stringify(uris, null, 2)}`,
});
}).then(x => this.abuseUserReportsRepository.findOneByOrFail(x.identifiers[0]));
this.queueService.createReportAbuseJob(report);
return 'ok';
}