fix: don't allow users to mention users who have blocked them
This commit is contained in:
parent
303703a9a6
commit
efeb660de6
2 changed files with 26 additions and 0 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue