summary refs log tree commit diff
path: root/util/src/entities
diff options
context:
space:
mode:
authorLobo Metalúrgico <43734867+LoboMetalurgico@users.noreply.github.com>2021-10-09 23:44:59 -0300
committerGitHub <noreply@github.com>2021-10-09 23:44:59 -0300
commitd359652b24a7f6f1cef7f9824a484355fc8586db (patch)
tree07e33dbfd0e46217e97f3cc6bd8937e83490b4a7 /util/src/entities
parent(api): fix some issues (diff)
parent:sparkles: random guest username generation added (diff)
downloadserver-d359652b24a7f6f1cef7f9824a484355fc8586db.tar.xz
Merge branch 'fosscord:master' into milestoneV1/routes/implement/emojis
Diffstat (limited to 'util/src/entities')
-rw-r--r--util/src/entities/ReadState.ts13
1 files changed, 7 insertions, 6 deletions
diff --git a/util/src/entities/ReadState.ts b/util/src/entities/ReadState.ts
index 68e867a0..89480e83 100644
--- a/util/src/entities/ReadState.ts
+++ b/util/src/entities/ReadState.ts
@@ -1,4 +1,4 @@
-import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
+import { Column, Entity, Index, JoinColumn, ManyToOne, RelationId } from "typeorm";
 import { BaseClass } from "./BaseClass";
 import { Channel } from "./Channel";
 import { Message } from "./Message";
@@ -9,8 +9,9 @@ import { User } from "./User";
 // public read receipt ≥ notification cursor ≥ private fully read marker
 
 @Entity("read_states")
+@Index(["channel_id", "user_id"], { unique: true })
 export class ReadState extends BaseClass {
-	@Column({ nullable: true })
+	@Column()
 	@RelationId((read_state: ReadState) => read_state.channel)
 	channel_id: string;
 
@@ -20,7 +21,7 @@ export class ReadState extends BaseClass {
 	})
 	channel: Channel;
 
-	@Column({ nullable: true })
+	@Column()
 	@RelationId((read_state: ReadState) => read_state.user)
 	user_id: string;
 
@@ -35,15 +36,15 @@ export class ReadState extends BaseClass {
 	last_message_id: string;
 
 	@JoinColumn({ name: "last_message_id" })
-	@ManyToOne(() => Message)
+	@ManyToOne(() => Message, { nullable: true })
 	last_message?: Message;
 
 	@Column({ nullable: true })
 	last_pin_timestamp?: Date;
 
-	@Column()
+	@Column({ nullable: true })
 	mention_count: number;
 
-	@Column()
+	@Column({ nullable: true })
 	manual: boolean;
 }