fix: don't allow users to mention users who have blocked them

This commit is contained in:
trisua 2025-05-08 17:41:15 -04:00
parent 303703a9a6
commit efeb660de6
2 changed files with 26 additions and 0 deletions

View file

@ -147,6 +147,17 @@ impl DataManager {
ua.to_owned()
} else {
let user = self.get_user_by_username(&username).await?;
// check blocked status
if self
.get_userblock_by_initiator_receiver(user.id, data.owner)
.await
.is_ok()
{
return Err(Error::NotAllowed);
}
// create notif
self.create_notification(Notification::new(
"You've been mentioned in a message!".to_string(),
format!(
@ -156,6 +167,8 @@ impl DataManager {
user.id,
))
.await?;
// ...
already_notified.insert(username.to_owned(), user.clone());
user
}

View file

@ -860,6 +860,17 @@ impl DataManager {
ua.to_owned()
} else {
let user = self.get_user_by_username(&username).await?;
// check blocked status
if self
.get_userblock_by_initiator_receiver(user.id, data.owner)
.await
.is_ok()
{
return Err(Error::NotAllowed);
}
// send notif
self.create_notification(Notification::new(
"You've been mentioned in a post!".to_string(),
format!(
@ -869,6 +880,8 @@ impl DataManager {
user.id,
))
.await?;
// ...
already_notified.insert(username.to_owned(), user.clone());
user
}