feat: 通報を受けた際にメールまたはWebhookで通知を送出出来るようにする (#13758)
* feat: 通報を受けた際にメールまたはWebhookで通知を送出出来るようにする * モデログに対応&エンドポイントを単一オブジェクトでのサポートに変更(API経由で大量に作るシチュエーションもないと思うので) * fix spdx * fix migration * fix migration * fix models * add e2e webhook * tweak * fix modlog * fix bugs * add tests and fix bugs * add tests and fix bugs * add tests * fix path * regenerate locale * 混入除去 * 混入除去 * add abuseReportResolved * fix pnpm-lock.yaml * add abuseReportResolved test * fix bugs * fix ui * add tests * fix CHANGELOG.md * add tests * add RoleService.getModeratorIds tests * WebhookServiceをUserとSystemに分割 * fix CHANGELOG.md * fix test * insertOneを使う用に * fix * regenerate locales * revert version * separate webhook job queue * fix * 🎨 * Update QueueProcessorService.ts --------- Co-authored-by: osamu <46447427+sam-osamu@users.noreply.github.com> Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
This commit is contained in:
98
packages/backend/src/models/SystemWebhook.ts
Normal file
98
packages/backend/src/models/SystemWebhook.ts
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { Column, Entity, Index, PrimaryColumn } from 'typeorm';
|
||||
import { Serialized } from '@/types.js';
|
||||
import { id } from './util/id.js';
|
||||
|
||||
export const systemWebhookEventTypes = [
|
||||
// ユーザからの通報を受けたとき
|
||||
'abuseReport',
|
||||
// 通報を処理したとき
|
||||
'abuseReportResolved',
|
||||
] as const;
|
||||
export type SystemWebhookEventType = typeof systemWebhookEventTypes[number];
|
||||
|
||||
@Entity('system_webhook')
|
||||
export class MiSystemWebhook {
|
||||
@PrimaryColumn(id())
|
||||
public id: string;
|
||||
|
||||
/**
|
||||
* 有効かどうか.
|
||||
*/
|
||||
@Index('IDX_system_webhook_isActive', { synchronize: false })
|
||||
@Column('boolean', {
|
||||
default: true,
|
||||
})
|
||||
public isActive: boolean;
|
||||
|
||||
/**
|
||||
* 更新日時.
|
||||
*/
|
||||
@Column('timestamp with time zone', {
|
||||
default: () => 'CURRENT_TIMESTAMP',
|
||||
})
|
||||
public updatedAt: Date;
|
||||
|
||||
/**
|
||||
* 最後に送信された日時.
|
||||
*/
|
||||
@Column('timestamp with time zone', {
|
||||
nullable: true,
|
||||
})
|
||||
public latestSentAt: Date | null;
|
||||
|
||||
/**
|
||||
* 最後に送信されたステータスコード
|
||||
*/
|
||||
@Column('integer', {
|
||||
nullable: true,
|
||||
})
|
||||
public latestStatus: number | null;
|
||||
|
||||
/**
|
||||
* 通知設定名.
|
||||
*/
|
||||
@Column('varchar', {
|
||||
length: 255,
|
||||
})
|
||||
public name: string;
|
||||
|
||||
/**
|
||||
* イベント種別.
|
||||
*/
|
||||
@Index('IDX_system_webhook_on', { synchronize: false })
|
||||
@Column('varchar', {
|
||||
length: 128,
|
||||
array: true,
|
||||
default: '{}',
|
||||
})
|
||||
public on: SystemWebhookEventType[];
|
||||
|
||||
/**
|
||||
* Webhook送信先のURL.
|
||||
*/
|
||||
@Column('varchar', {
|
||||
length: 1024,
|
||||
})
|
||||
public url: string;
|
||||
|
||||
/**
|
||||
* Webhook検証用の値.
|
||||
*/
|
||||
@Column('varchar', {
|
||||
length: 1024,
|
||||
})
|
||||
public secret: string;
|
||||
|
||||
static deserialize(obj: Serialized<MiSystemWebhook>): MiSystemWebhook {
|
||||
return {
|
||||
...obj,
|
||||
updatedAt: new Date(obj.updatedAt),
|
||||
latestSentAt: obj.latestSentAt ? new Date(obj.latestSentAt) : null,
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user