summary refs log tree commit diff
path: root/util/src/entities/ReadState.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-01 10:47:00 +0200
committerGitHub <noreply@github.com>2021-09-01 10:47:00 +0200
commitdf1d633c4b56bea97e0b76da34171d80c0c6a3ff (patch)
tree7e57837ec000a641935a32649ac17b38ef2e29d8 /util/src/entities/ReadState.ts
parentMerge pull request #287 from EMREOYUN/patch-1 (diff)
parentMerge pull request #299 from AlTech98/typeorm (diff)
downloadserver-df1d633c4b56bea97e0b76da34171d80c0c6a3ff.tar.xz
Merge pull request #300 from fosscord/typeorm
Diffstat (limited to '')
-rw-r--r--util/src/entities/ReadState.ts45
1 files changed, 45 insertions, 0 deletions
diff --git a/util/src/entities/ReadState.ts b/util/src/entities/ReadState.ts
new file mode 100644

index 00000000..8dd05b21 --- /dev/null +++ b/util/src/entities/ReadState.ts
@@ -0,0 +1,45 @@ +import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; +import { BaseClass } from "./BaseClass"; +import { Channel } from "./Channel"; +import { Message } from "./Message"; +import { User } from "./User"; + +// for read receipts +// notification cursor and public read receipt need to be forwards-only (the former to prevent re-pinging when marked as unread, and the latter to be acceptable as a legal acknowledgement in criminal proceedings), and private read marker needs to be advance-rewind capable +// public read receipt ≥ notification cursor ≥ private fully read marker + +@Entity("read_states") +export class ReadState extends BaseClass { + @Column({ nullable: true }) + @RelationId((read_state: ReadState) => read_state.channel) + channel_id: string; + + @JoinColumn({ name: "channel_id" }) + @ManyToOne(() => Channel) + channel: Channel; + + @Column({ nullable: true }) + @RelationId((read_state: ReadState) => read_state.user) + user_id: string; + + @JoinColumn({ name: "user_id" }) + @ManyToOne(() => User) + user: User; + + @Column({ nullable: true }) + @RelationId((read_state: ReadState) => read_state.last_message) + last_message_id: string; + + @JoinColumn({ name: "last_message_id" }) + @ManyToOne(() => Message) + last_message?: Message; + + @Column({ nullable: true }) + last_pin_timestamp?: Date; + + @Column() + mention_count: number; + + @Column() + manual: boolean; +}