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);
}
}
// 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 {

View file

@ -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?
}
}
}
}