2023-01-13 05:40:33 +01:00
|
|
|
import {
|
|
|
|
Entity,
|
|
|
|
Index,
|
|
|
|
JoinColumn,
|
|
|
|
Column,
|
|
|
|
ManyToOne,
|
|
|
|
PrimaryColumn,
|
|
|
|
} from "typeorm";
|
|
|
|
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()
|
2023-05-29 18:31:02 +02:00
|
|
|
@Index(["noteId", "userId"], { unique: true })
|
2020-07-27 06:34:20 +02:00
|
|
|
export class MutedNote {
|
|
|
|
@PrimaryColumn(id())
|
|
|
|
public id: string;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column({
|
|
|
|
...id(),
|
2023-05-29 18:31:02 +02:00
|
|
|
comment: "The note ID.",
|
2020-07-27 06:34:20 +02:00
|
|
|
})
|
2023-01-13 05:40:33 +01:00
|
|
|
public noteId: Note["id"];
|
2020-07-27 06:34:20 +02:00
|
|
|
|
2023-05-29 18:31:02 +02:00
|
|
|
@ManyToOne((type) => Note, {
|
|
|
|
onDelete: "CASCADE",
|
2020-07-27 06:34:20 +02:00
|
|
|
})
|
|
|
|
@JoinColumn()
|
|
|
|
public note: Note | null;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column({
|
|
|
|
...id(),
|
2023-05-29 18:31:02 +02:00
|
|
|
comment: "The user ID.",
|
2020-07-27 06:34:20 +02:00
|
|
|
})
|
2023-01-13 05:40:33 +01:00
|
|
|
public userId: User["id"];
|
2020-07-27 06:34:20 +02:00
|
|
|
|
2023-05-29 18:31:02 +02:00
|
|
|
@ManyToOne((type) => User, {
|
|
|
|
onDelete: "CASCADE",
|
2020-07-27 06:34:20 +02:00
|
|
|
})
|
|
|
|
@JoinColumn()
|
|
|
|
public user: User | null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ミュートされた理由。
|
|
|
|
*/
|
|
|
|
@Index()
|
2023-05-29 18:31:02 +02:00
|
|
|
@Column("enum", {
|
2020-07-27 06:34:20 +02:00
|
|
|
enum: mutedNoteReasons,
|
2023-05-29 18:31:02 +02:00
|
|
|
comment: "The reason of the MutedNote.",
|
2020-07-27 06:34:20 +02:00
|
|
|
})
|
|
|
|
public reason: typeof mutedNoteReasons[number];
|
|
|
|
}
|