fix: don't send comment notif if our profile is private and we aren't following post owner
This commit is contained in:
parent
b7b84d15b7
commit
a43e586e4c
1 changed files with 20 additions and 9 deletions
|
@ -1793,15 +1793,26 @@ impl DataManager {
|
||||||
// send notification
|
// send notification
|
||||||
if data.owner != rt.owner {
|
if data.owner != rt.owner {
|
||||||
let owner = self.get_user_by_id(data.owner).await?;
|
let owner = self.get_user_by_id(data.owner).await?;
|
||||||
self.create_notification(Notification::new(
|
|
||||||
"Your post has received a new comment!".to_string(),
|
// make sure we're actually following the person we're commenting to
|
||||||
format!(
|
// we shouldn't send the notif if we aren't, because they can't see it
|
||||||
"[@{}](/api/v1/auth/user/find/{}) has commented on your [post](/post/{}).",
|
// (only if our profile is private)
|
||||||
owner.username, owner.id, rt.id
|
if !owner.settings.private_profile
|
||||||
),
|
| self
|
||||||
rt.owner,
|
.get_userfollow_by_initiator_receiver(data.owner, rt.owner)
|
||||||
))
|
.await
|
||||||
.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 {
|
if !rt.context.comments_enabled {
|
||||||
return Err(Error::NotAllowed);
|
return Err(Error::NotAllowed);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue