summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-03 22:53:01 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-03 22:53:01 +0200
commit2f7182ca3d8568aca24a73a6b6dc8da0f5fa6747 (patch)
tree928b1ccdec95a799afa1fb8b90716bac2c9a9d05
parentMerge pull request #411 from afeuerstein/master (diff)
downloadserver-2f7182ca3d8568aca24a73a6b6dc8da0f5fa6747.tar.xz
:bug: fix message reactions
-rw-r--r--api/src/routes/channels/#channel_id/messages/#message_id/reactions.ts4
-rw-r--r--util/src/entities/Message.ts6
2 files changed, 4 insertions, 6 deletions
diff --git a/api/src/routes/channels/#channel_id/messages/#message_id/reactions.ts b/api/src/routes/channels/#channel_id/messages/#message_id/reactions.ts
index f2b83d40..6b6a66b2 100644
--- a/api/src/routes/channels/#channel_id/messages/#message_id/reactions.ts
+++ b/api/src/routes/channels/#channel_id/messages/#message_id/reactions.ts
@@ -124,7 +124,7 @@ router.put("/:emoji/:user_id", route({ permission: "READ_MESSAGE_HISTORY" }), as
 		already_added.count++;
 	} else message.reactions.push({ count: 1, emoji, user_ids: [req.user_id] });
 
-	await Message.update({ id: message_id, channel_id }, message);
+	await message.save();
 
 	const member = channel.guild_id && (await Member.findOneOrFail({ id: req.user_id }));
 
@@ -165,7 +165,7 @@ router.delete("/:emoji/:user_id", route({}), async (req: Request, res: Response)
 
 	if (already_added.count <= 0) message.reactions.remove(already_added);
 
-	await Message.update({ id: message_id, channel_id }, message);
+	await message.save();
 
 	await emitEvent({
 		event: "MESSAGE_REACTION_REMOVE",
diff --git a/util/src/entities/Message.ts b/util/src/entities/Message.ts
index c4901693..04c3c7aa 100644
--- a/util/src/entities/Message.ts
+++ b/util/src/entities/Message.ts
@@ -74,9 +74,7 @@ export class Message extends BaseClass {
 	author_id: string;
 
 	@JoinColumn({ name: "author_id", referencedColumnName: "id" })
-	@ManyToOne(() => User, {
-		onDelete: "CASCADE",
-	})
+	@ManyToOne(() => User)
 	author?: User;
 
 	@Column({ nullable: true })
@@ -120,7 +118,7 @@ export class Message extends BaseClass {
 	mention_everyone?: boolean;
 
 	@JoinTable({ name: "message_user_mentions" })
-	@ManyToMany(() => User, { orphanedRowAction: "delete", onDelete: "CASCADE", cascade: true })
+	@ManyToMany(() => User)
 	mentions: User[];
 
 	@JoinTable({ name: "message_role_mentions" })