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:
100
packages/backend/src/models/AbuseReportNotificationRecipient.ts
Normal file
100
packages/backend/src/models/AbuseReportNotificationRecipient.ts
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { Column, Entity, Index, JoinColumn, ManyToOne, PrimaryColumn } from 'typeorm';
|
||||
import { MiSystemWebhook } from '@/models/SystemWebhook.js';
|
||||
import { MiUserProfile } from '@/models/UserProfile.js';
|
||||
import { id } from './util/id.js';
|
||||
import { MiUser } from './User.js';
|
||||
|
||||
/**
|
||||
* 通報受信時に通知を送信する方法.
|
||||
*/
|
||||
export type RecipientMethod = 'email' | 'webhook';
|
||||
|
||||
@Entity('abuse_report_notification_recipient')
|
||||
export class MiAbuseReportNotificationRecipient {
|
||||
@PrimaryColumn(id())
|
||||
public id: string;
|
||||
|
||||
/**
|
||||
* 有効かどうか.
|
||||
*/
|
||||
@Index()
|
||||
@Column('boolean', {
|
||||
default: true,
|
||||
})
|
||||
public isActive: boolean;
|
||||
|
||||
/**
|
||||
* 更新日時.
|
||||
*/
|
||||
@Column('timestamp with time zone', {
|
||||
default: () => 'CURRENT_TIMESTAMP',
|
||||
})
|
||||
public updatedAt: Date;
|
||||
|
||||
/**
|
||||
* 通知設定名.
|
||||
*/
|
||||
@Column('varchar', {
|
||||
length: 255,
|
||||
})
|
||||
public name: string;
|
||||
|
||||
/**
|
||||
* 通知方法.
|
||||
*/
|
||||
@Index()
|
||||
@Column('varchar', {
|
||||
length: 64,
|
||||
})
|
||||
public method: RecipientMethod;
|
||||
|
||||
/**
|
||||
* 通知先のユーザID.
|
||||
*/
|
||||
@Index()
|
||||
@Column({
|
||||
...id(),
|
||||
nullable: true,
|
||||
})
|
||||
public userId: MiUser['id'] | null;
|
||||
|
||||
/**
|
||||
* 通知先のユーザ.
|
||||
*/
|
||||
@ManyToOne(type => MiUser, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'userId', referencedColumnName: 'id', foreignKeyConstraintName: 'FK_abuse_report_notification_recipient_userId1' })
|
||||
public user: MiUser | null;
|
||||
|
||||
/**
|
||||
* 通知先のユーザプロフィール.
|
||||
*/
|
||||
@ManyToOne(type => MiUserProfile, {})
|
||||
@JoinColumn({ name: 'userId', referencedColumnName: 'userId', foreignKeyConstraintName: 'FK_abuse_report_notification_recipient_userId2' })
|
||||
public userProfile: MiUserProfile | null;
|
||||
|
||||
/**
|
||||
* 通知先のシステムWebhookId.
|
||||
*/
|
||||
@Index()
|
||||
@Column({
|
||||
...id(),
|
||||
nullable: true,
|
||||
})
|
||||
public systemWebhookId: string | null;
|
||||
|
||||
/**
|
||||
* 通知先のシステムWebhook.
|
||||
*/
|
||||
@ManyToOne(type => MiSystemWebhook, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn()
|
||||
public systemWebhook: MiSystemWebhook | null;
|
||||
}
|
||||
Reference in New Issue
Block a user