2023-07-27 05:31:52 +00:00
|
|
|
/*
|
2024-02-13 15:50:11 +00:00
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
2023-07-27 05:31:52 +00:00
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-04-02 06:28:49 +00:00
|
|
|
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
|
2023-09-20 02:33:36 +00:00
|
|
|
import { id } from './util/id.js';
|
2023-08-16 08:51:28 +00:00
|
|
|
import { MiUser } from './User.js';
|
2022-04-02 06:28:49 +00:00
|
|
|
|
|
|
|
export const webhookEventTypes = ['mention', 'unfollow', 'follow', 'followed', 'note', 'reply', 'renote', 'reaction'] as const;
|
|
|
|
|
2023-08-16 08:51:28 +00:00
|
|
|
@Entity('webhook')
|
|
|
|
export class MiWebhook {
|
2022-04-02 06:28:49 +00:00
|
|
|
@PrimaryColumn(id())
|
|
|
|
public id: string;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column({
|
|
|
|
...id(),
|
|
|
|
comment: 'The owner ID.',
|
|
|
|
})
|
2023-08-16 08:51:28 +00:00
|
|
|
public userId: MiUser['id'];
|
2022-04-02 06:28:49 +00:00
|
|
|
|
2023-08-16 08:51:28 +00:00
|
|
|
@ManyToOne(type => MiUser, {
|
2022-04-02 06:28:49 +00:00
|
|
|
onDelete: 'CASCADE',
|
|
|
|
})
|
|
|
|
@JoinColumn()
|
2023-08-16 08:51:28 +00:00
|
|
|
public user: MiUser | null;
|
2022-04-02 06:28:49 +00:00
|
|
|
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 128,
|
|
|
|
comment: 'The name of the Antenna.',
|
|
|
|
})
|
|
|
|
public name: string;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 128, array: true, default: '{}',
|
|
|
|
})
|
|
|
|
public on: (typeof webhookEventTypes)[number][];
|
|
|
|
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 1024,
|
|
|
|
})
|
|
|
|
public url: string;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 1024,
|
|
|
|
})
|
|
|
|
public secret: string;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('boolean', {
|
|
|
|
default: true,
|
|
|
|
})
|
|
|
|
public active: boolean;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 直近のリクエスト送信日時
|
|
|
|
*/
|
|
|
|
@Column('timestamp with time zone', {
|
|
|
|
nullable: true,
|
|
|
|
})
|
|
|
|
public latestSentAt: Date | null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 直近のリクエスト送信時のHTTPステータスコード
|
|
|
|
*/
|
|
|
|
@Column('integer', {
|
|
|
|
nullable: true,
|
|
|
|
})
|
|
|
|
public latestStatus: number | null;
|
|
|
|
}
|