fix: don't send comment notif if our profile is private and we aren't following post owner

This commit is contained in:
trisua 2025-06-15 19:26:52 -04:00
parent b7b84d15b7
commit a43e586e4c

View file

@ -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);