2020-07-27 07:34:20 +03:00
|
|
|
import { Entity, Index, JoinColumn, Column, ManyToOne, PrimaryColumn } from 'typeorm';
|
2021-08-19 12:33:41 +03:00
|
|
|
import { Note } from './note.js';
|
|
|
|
import { User } from './user.js';
|
|
|
|
import { id } from '../id.js';
|
|
|
|
import { mutedNoteReasons } from '../../types.js';
|
2020-07-27 07:34:20 +03:00
|
|
|
|
|
|
|
@Entity()
|
|
|
|
@Index(['noteId', 'userId'], { unique: true })
|
|
|
|
export class MutedNote {
|
|
|
|
@PrimaryColumn(id())
|
|
|
|
public id: string;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column({
|
|
|
|
...id(),
|
|
|
|
comment: 'The note ID.'
|
|
|
|
})
|
|
|
|
public noteId: Note['id'];
|
|
|
|
|
|
|
|
@ManyToOne(type => Note, {
|
|
|
|
onDelete: 'CASCADE'
|
|
|
|
})
|
|
|
|
@JoinColumn()
|
|
|
|
public note: Note | null;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column({
|
|
|
|
...id(),
|
|
|
|
comment: 'The user ID.'
|
|
|
|
})
|
|
|
|
public userId: User['id'];
|
|
|
|
|
|
|
|
@ManyToOne(type => User, {
|
|
|
|
onDelete: 'CASCADE'
|
|
|
|
})
|
|
|
|
@JoinColumn()
|
|
|
|
public user: User | null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ミュートされた理由。
|
|
|
|
*/
|
|
|
|
@Index()
|
|
|
|
@Column('enum', {
|
|
|
|
enum: mutedNoteReasons,
|
|
|
|
comment: 'The reason of the MutedNote.'
|
|
|
|
})
|
|
|
|
public reason: typeof mutedNoteReasons[number];
|
|
|
|
}
|