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