refactoring

Resolve #7779
This commit is contained in:
syuilo 2021-11-12 02:02:25 +09:00
parent 037837b551
commit 0e4a111f81
1714 changed files with 20803 additions and 11751 deletions

View file

@ -0,0 +1,172 @@
import { Entity, Index, JoinColumn, ManyToOne, Column, PrimaryColumn } from 'typeorm';
import { User } from './user';
import { id } from '../id';
import { Note } from './note';
import { FollowRequest } from './follow-request';
import { UserGroupInvitation } from './user-group-invitation';
import { AccessToken } from './access-token';
import { notificationTypes } from '@/types';
@Entity()
export class Notification {
@PrimaryColumn(id())
public id: string;
@Index()
@Column('timestamp with time zone', {
comment: 'The created date of the Notification.'
})
public createdAt: Date;
/**
*
*/
@Index()
@Column({
...id(),
comment: 'The ID of recipient user of the Notification.'
})
public notifieeId: User['id'];
@ManyToOne(type => User, {
onDelete: 'CASCADE'
})
@JoinColumn()
public notifiee: User | null;
/**
* (initiator)
*/
@Index()
@Column({
...id(),
nullable: true,
comment: 'The ID of sender user of the Notification.'
})
public notifierId: User['id'] | null;
@ManyToOne(type => User, {
onDelete: 'CASCADE'
})
@JoinColumn()
public notifier: User | null;
/**
*
* follow -
* mention - 稿
* reply - (Watchしている)稿
* renote - (Watchしている)稿Renoteされた
* quote - (Watchしている)稿Renoteされた
* reaction - (Watchしている)稿
* pollVote - (Watchしている)稿
* receiveFollowRequest -
* followRequestAccepted -
* groupInvited -
* app -
*/
@Index()
@Column('enum', {
enum: notificationTypes,
comment: 'The type of the Notification.'
})
public type: typeof notificationTypes[number];
/**
*
*/
@Index()
@Column('boolean', {
default: false,
comment: 'Whether the Notification is read.'
})
public isRead: boolean;
@Column({
...id(),
nullable: true
})
public noteId: Note['id'] | null;
@ManyToOne(type => Note, {
onDelete: 'CASCADE'
})
@JoinColumn()
public note: Note | null;
@Column({
...id(),
nullable: true
})
public followRequestId: FollowRequest['id'] | null;
@ManyToOne(type => FollowRequest, {
onDelete: 'CASCADE'
})
@JoinColumn()
public followRequest: FollowRequest | null;
@Column({
...id(),
nullable: true
})
public userGroupInvitationId: UserGroupInvitation['id'] | null;
@ManyToOne(type => UserGroupInvitation, {
onDelete: 'CASCADE'
})
@JoinColumn()
public userGroupInvitation: UserGroupInvitation | null;
@Column('varchar', {
length: 128, nullable: true
})
public reaction: string | null;
@Column('integer', {
nullable: true
})
public choice: number | null;
/**
* body
*/
@Column('varchar', {
length: 2048, nullable: true
})
public customBody: string | null;
/**
* header
* ()
*/
@Column('varchar', {
length: 256, nullable: true
})
public customHeader: string | null;
/**
* icon(URL)
* ()
*/
@Column('varchar', {
length: 1024, nullable: true
})
public customIcon: string | null;
/**
* ()
*/
@Index()
@Column({
...id(),
nullable: true
})
public appAccessTokenId: AccessToken['id'] | null;
@ManyToOne(type => AccessToken, {
onDelete: 'CASCADE'
})
@JoinColumn()
public appAccessToken: AccessToken | null;
}