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
This commit is contained in:
trisua 2025-05-04 16:42:17 -04:00
parent e727de9c63
commit 2fa5a4dc1f
2 changed files with 28 additions and 9 deletions

View file

@ -130,6 +130,18 @@ impl DataManager {
return Err(Error::NotAllowed); 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 { let conn = match self.connect().await {

View file

@ -125,15 +125,22 @@ impl DataManager {
let post = self.get_post_by_id(data.asset).await.unwrap(); let post = self.get_post_by_id(data.asset).await.unwrap();
if post.owner != user.id { if post.owner != user.id {
self.create_notification(Notification::new( // check block status (don't send notif if blocked)
"Your post has received a like!".to_string(), if self
format!( .get_userblock_by_initiator_receiver(post.owner, user.id)
"[@{}](/api/v1/auth/user/find/{}) has liked your [post](/post/{})!", .await
user.username, user.id, data.asset .is_err()
), {
post.owner, self.create_notification(Notification::new(
)) "Your post has received a like!".to_string(),
.await? format!(
"[@{}](/api/v1/auth/user/find/{}) has liked your [post](/post/{})!",
user.username, user.id, data.asset
),
post.owner,
))
.await?
}
} }
} }
} }