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