From a43e586e4c4d3d1cdf775836e4406b7e193f58a3 Mon Sep 17 00:00:00 2001 From: trisua Date: Sun, 15 Jun 2025 19:26:52 -0400 Subject: [PATCH] fix: don't send comment notif if our profile is private and we aren't following post owner --- crates/core/src/database/posts.rs | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/crates/core/src/database/posts.rs b/crates/core/src/database/posts.rs index 0d3f6dd..0e76fa1 100644 --- a/crates/core/src/database/posts.rs +++ b/crates/core/src/database/posts.rs @@ -1793,15 +1793,26 @@ impl DataManager { // send notification if data.owner != rt.owner { let owner = self.get_user_by_id(data.owner).await?; - self.create_notification(Notification::new( - "Your post has received a new comment!".to_string(), - format!( - "[@{}](/api/v1/auth/user/find/{}) has commented on your [post](/post/{}).", - owner.username, owner.id, rt.id - ), - rt.owner, - )) - .await?; + + // make sure we're actually following the person we're commenting to + // we shouldn't send the notif if we aren't, because they can't see it + // (only if our profile is private) + if !owner.settings.private_profile + | self + .get_userfollow_by_initiator_receiver(data.owner, rt.owner) + .await + .is_ok() + { + self.create_notification(Notification::new( + "Your post has received a new comment!".to_string(), + format!( + "[@{}](/api/v1/auth/user/find/{}) has commented on your [post](/post/{}).", + owner.username, owner.id, rt.id + ), + rt.owner, + )) + .await?; + } if !rt.context.comments_enabled { return Err(Error::NotAllowed);