From 2fa5a4dc1fe903180e2ac81caad82441863e51a0 Mon Sep 17 00:00:00 2001 From: trisua Date: Sun, 4 May 2025 16:42:17 -0400 Subject: [PATCH] fix: don't send notif when a user you've blocked likes your post fix: don't allow users you've blocked to add you to a chat --- crates/core/src/database/channels.rs | 12 ++++++++++++ crates/core/src/database/reactions.rs | 25 ++++++++++++++++--------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/crates/core/src/database/channels.rs b/crates/core/src/database/channels.rs index a99c58a..6026c48 100644 --- a/crates/core/src/database/channels.rs +++ b/crates/core/src/database/channels.rs @@ -130,6 +130,18 @@ impl DataManager { return Err(Error::NotAllowed); } } + // check members + else { + for member in &data.members { + if self + .get_userblock_by_initiator_receiver(member.to_owned(), data.owner) + .await + .is_ok() + { + return Err(Error::NotAllowed); + } + } + } // ... let conn = match self.connect().await { diff --git a/crates/core/src/database/reactions.rs b/crates/core/src/database/reactions.rs index 9549125..83ef2cc 100644 --- a/crates/core/src/database/reactions.rs +++ b/crates/core/src/database/reactions.rs @@ -125,15 +125,22 @@ impl DataManager { let post = self.get_post_by_id(data.asset).await.unwrap(); if post.owner != user.id { - self.create_notification(Notification::new( - "Your post has received a like!".to_string(), - format!( - "[@{}](/api/v1/auth/user/find/{}) has liked your [post](/post/{})!", - user.username, user.id, data.asset - ), - post.owner, - )) - .await? + // check block status (don't send notif if blocked) + if self + .get_userblock_by_initiator_receiver(post.owner, user.id) + .await + .is_err() + { + self.create_notification(Notification::new( + "Your post has received a like!".to_string(), + format!( + "[@{}](/api/v1/auth/user/find/{}) has liked your [post](/post/{})!", + user.username, user.id, data.asset + ), + post.owner, + )) + .await? + } } } }