diff options
| author | misskey-release-bot[bot] <157398866+misskey-release-bot[bot]@users.noreply.github.com> | 2024-07-31 11:20:31 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-31 11:20:31 +0000 |
| commit | e98f66db51aabef925ea1a8faee6c37f67071107 (patch) | |
| tree | 168fcc9219f7511bbf9bc198568406bd49fc31bb /packages/backend/src/models/SystemWebhook.ts | |
| parent | fix: remove unreleased section (#14246) (diff) | |
| parent | Release: 2024.7.0 (diff) | |
| download | sharkey-e98f66db51aabef925ea1a8faee6c37f67071107.tar.gz sharkey-e98f66db51aabef925ea1a8faee6c37f67071107.tar.bz2 sharkey-e98f66db51aabef925ea1a8faee6c37f67071107.zip | |
Merge pull request #14233 from misskey-dev/develop
Release: 2024.7.0
Diffstat (limited to 'packages/backend/src/models/SystemWebhook.ts')
| -rw-r--r-- | packages/backend/src/models/SystemWebhook.ts | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/packages/backend/src/models/SystemWebhook.ts b/packages/backend/src/models/SystemWebhook.ts new file mode 100644 index 0000000000..d6c27eae51 --- /dev/null +++ b/packages/backend/src/models/SystemWebhook.ts @@ -0,0 +1,100 @@ +/* + * 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', + // ユーザが作成された時 + 'userCreated', +] 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, + }; + } +} |