2023-07-27 07:31:52 +02:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-04-02 08:28:49 +02:00
|
|
|
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
|
|
|
|
import { id } from '../id.js';
|
2023-08-16 10:51:28 +02:00
|
|
|
import { MiUser } from './User.js';
|
2022-04-02 08:28:49 +02:00
|
|
|
|
|
|
|
export const webhookEventTypes = ['mention', 'unfollow', 'follow', 'followed', 'note', 'reply', 'renote', 'reaction'] as const;
|
|
|
|
|
2023-08-16 10:51:28 +02:00
|
|
|
@Entity('webhook')
|
|
|
|
export class MiWebhook {
|
2022-04-02 08:28:49 +02:00
|
|
|
@PrimaryColumn(id())
|
|
|
|
public id: string;
|
|
|
|
|
|
|
|
@Column('timestamp with time zone', {
|
|
|
|
comment: 'The created date of the Antenna.',
|
|
|
|
})
|
|
|
|
public createdAt: Date;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column({
|
|
|
|
...id(),
|
|
|
|
comment: 'The owner ID.',
|
|
|
|
})
|
2023-08-16 10:51:28 +02:00
|
|
|
public userId: MiUser['id'];
|
2022-04-02 08:28:49 +02:00
|
|
|
|
2023-08-16 10:51:28 +02:00
|
|
|
@ManyToOne(type => MiUser, {
|
2022-04-02 08:28:49 +02:00
|
|
|
onDelete: 'CASCADE',
|
|
|
|
})
|
|
|
|
@JoinColumn()
|
2023-08-16 10:51:28 +02:00
|
|
|
public user: MiUser | null;
|
2022-04-02 08:28:49 +02: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;
|
|
|
|
}
|