2019-04-07 12:50:36 +00:00
|
|
|
import { Entity, Index, JoinColumn, ManyToOne, Column, PrimaryColumn } from 'typeorm';
|
2022-02-27 02:07:39 +00:00
|
|
|
import { notificationTypes } from '@/types.js';
|
2022-09-17 18:27:08 +00:00
|
|
|
import { id } from '../id.js';
|
|
|
|
import { User } from './User.js';
|
|
|
|
import { Note } from './Note.js';
|
|
|
|
import { FollowRequest } from './FollowRequest.js';
|
|
|
|
import { UserGroupInvitation } from './UserGroupInvitation.js';
|
|
|
|
import { AccessToken } from './AccessToken.js';
|
2019-04-07 12:50:36 +00:00
|
|
|
|
|
|
|
@Entity()
|
|
|
|
export class Notification {
|
|
|
|
@PrimaryColumn(id())
|
|
|
|
public id: string;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('timestamp with time zone', {
|
2021-12-09 14:58:30 +00:00
|
|
|
comment: 'The created date of the Notification.',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
|
|
|
public createdAt: Date;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 通知の受信者
|
|
|
|
*/
|
|
|
|
@Index()
|
|
|
|
@Column({
|
|
|
|
...id(),
|
2021-12-09 14:58:30 +00:00
|
|
|
comment: 'The ID of recipient user of the Notification.',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
|
|
|
public notifieeId: User['id'];
|
|
|
|
|
|
|
|
@ManyToOne(type => User, {
|
2021-12-09 14:58:30 +00:00
|
|
|
onDelete: 'CASCADE',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
|
|
|
@JoinColumn()
|
|
|
|
public notifiee: User | null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 通知の送信者(initiator)
|
|
|
|
*/
|
2020-03-28 09:07:41 +00:00
|
|
|
@Index()
|
2019-04-07 12:50:36 +00:00
|
|
|
@Column({
|
|
|
|
...id(),
|
2020-03-28 09:07:41 +00:00
|
|
|
nullable: true,
|
2021-12-09 14:58:30 +00:00
|
|
|
comment: 'The ID of sender user of the Notification.',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
2020-03-28 09:07:41 +00:00
|
|
|
public notifierId: User['id'] | null;
|
2019-04-07 12:50:36 +00:00
|
|
|
|
|
|
|
@ManyToOne(type => User, {
|
2021-12-09 14:58:30 +00:00
|
|
|
onDelete: 'CASCADE',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
|
|
|
@JoinColumn()
|
|
|
|
public notifier: User | null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 通知の種類。
|
|
|
|
* follow - フォローされた
|
|
|
|
* mention - 投稿で自分が言及された
|
2023-01-08 01:54:45 +00:00
|
|
|
* reply - 投稿に返信された
|
|
|
|
* renote - 投稿がRenoteされた
|
|
|
|
* quote - 投稿が引用Renoteされた
|
|
|
|
* reaction - 投稿にリアクションされた
|
|
|
|
* pollVote - 投稿のアンケートに投票された (廃止)
|
2022-03-06 07:06:27 +00:00
|
|
|
* pollEnded - 自分のアンケートもしくは自分が投票したアンケートが終了した
|
2020-01-29 19:37:25 +00:00
|
|
|
* receiveFollowRequest - フォローリクエストされた
|
|
|
|
* followRequestAccepted - 自分の送ったフォローリクエストが承認された
|
2020-02-12 17:17:54 +00:00
|
|
|
* groupInvited - グループに招待された
|
2020-03-28 09:07:41 +00:00
|
|
|
* app - アプリ通知
|
2019-04-07 12:50:36 +00:00
|
|
|
*/
|
2020-03-28 09:07:41 +00:00
|
|
|
@Index()
|
2020-01-29 19:37:25 +00:00
|
|
|
@Column('enum', {
|
2020-05-26 05:33:55 +00:00
|
|
|
enum: notificationTypes,
|
2021-12-09 14:58:30 +00:00
|
|
|
comment: 'The type of the Notification.',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
2020-05-26 05:33:55 +00:00
|
|
|
public type: typeof notificationTypes[number];
|
2019-04-07 12:50:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 通知が読まれたかどうか
|
|
|
|
*/
|
2020-03-28 09:07:41 +00:00
|
|
|
@Index()
|
2019-04-07 12:50:36 +00:00
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
2021-12-09 14:58:30 +00:00
|
|
|
comment: 'Whether the Notification is read.',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
|
|
|
public isRead: boolean;
|
|
|
|
|
|
|
|
@Column({
|
|
|
|
...id(),
|
2021-12-09 14:58:30 +00:00
|
|
|
nullable: true,
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
|
|
|
public noteId: Note['id'] | null;
|
|
|
|
|
|
|
|
@ManyToOne(type => Note, {
|
2021-12-09 14:58:30 +00:00
|
|
|
onDelete: 'CASCADE',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
|
|
|
@JoinColumn()
|
|
|
|
public note: Note | null;
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
@Column({
|
|
|
|
...id(),
|
2021-12-09 14:58:30 +00:00
|
|
|
nullable: true,
|
2020-01-29 19:37:25 +00:00
|
|
|
})
|
|
|
|
public followRequestId: FollowRequest['id'] | null;
|
|
|
|
|
|
|
|
@ManyToOne(type => FollowRequest, {
|
2021-12-09 14:58:30 +00:00
|
|
|
onDelete: 'CASCADE',
|
2020-01-29 19:37:25 +00:00
|
|
|
})
|
|
|
|
@JoinColumn()
|
|
|
|
public followRequest: FollowRequest | null;
|
|
|
|
|
2020-02-12 17:17:54 +00:00
|
|
|
@Column({
|
|
|
|
...id(),
|
2021-12-09 14:58:30 +00:00
|
|
|
nullable: true,
|
2020-02-12 17:17:54 +00:00
|
|
|
})
|
|
|
|
public userGroupInvitationId: UserGroupInvitation['id'] | null;
|
|
|
|
|
|
|
|
@ManyToOne(type => UserGroupInvitation, {
|
2021-12-09 14:58:30 +00:00
|
|
|
onDelete: 'CASCADE',
|
2020-02-12 17:17:54 +00:00
|
|
|
})
|
|
|
|
@JoinColumn()
|
|
|
|
public userGroupInvitation: UserGroupInvitation | null;
|
|
|
|
|
2019-04-07 12:50:36 +00:00
|
|
|
@Column('varchar', {
|
2021-12-09 14:58:30 +00:00
|
|
|
length: 128, nullable: true,
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
2020-03-28 09:07:41 +00:00
|
|
|
public reaction: string | null;
|
2019-04-07 12:50:36 +00:00
|
|
|
|
|
|
|
@Column('integer', {
|
2021-12-09 14:58:30 +00:00
|
|
|
nullable: true,
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
2020-03-28 09:07:41 +00:00
|
|
|
public choice: number | null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* アプリ通知のbody
|
|
|
|
*/
|
|
|
|
@Column('varchar', {
|
2021-12-09 14:58:30 +00:00
|
|
|
length: 2048, nullable: true,
|
2020-03-28 09:07:41 +00:00
|
|
|
})
|
|
|
|
public customBody: string | null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* アプリ通知のheader
|
|
|
|
* (省略時はアプリ名で表示されることを期待)
|
|
|
|
*/
|
|
|
|
@Column('varchar', {
|
2021-12-09 14:58:30 +00:00
|
|
|
length: 256, nullable: true,
|
2020-03-28 09:07:41 +00:00
|
|
|
})
|
|
|
|
public customHeader: string | null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* アプリ通知のicon(URL)
|
|
|
|
* (省略時はアプリアイコンで表示されることを期待)
|
|
|
|
*/
|
|
|
|
@Column('varchar', {
|
2021-12-09 14:58:30 +00:00
|
|
|
length: 1024, nullable: true,
|
2020-03-28 09:07:41 +00:00
|
|
|
})
|
|
|
|
public customIcon: string | null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* アプリ通知のアプリ(のトークン)
|
|
|
|
*/
|
|
|
|
@Index()
|
|
|
|
@Column({
|
|
|
|
...id(),
|
2021-12-09 14:58:30 +00:00
|
|
|
nullable: true,
|
2020-03-28 09:07:41 +00:00
|
|
|
})
|
|
|
|
public appAccessTokenId: AccessToken['id'] | null;
|
|
|
|
|
|
|
|
@ManyToOne(type => AccessToken, {
|
2021-12-09 14:58:30 +00:00
|
|
|
onDelete: 'CASCADE',
|
2020-03-28 09:07:41 +00:00
|
|
|
})
|
|
|
|
@JoinColumn()
|
|
|
|
public appAccessToken: AccessToken | null;
|
2019-04-07 12:50:36 +00:00
|
|
|
}
|