fix: Bug when requester already has recipient in whitelist
Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
parent
8f791acd5d
commit
92492288c0
1 changed files with 6 additions and 1 deletions
|
@ -23,6 +23,7 @@ use oxidetalis_entities::prelude::*;
|
||||||
use sea_orm::DatabaseConnection;
|
use sea_orm::DatabaseConnection;
|
||||||
|
|
||||||
use crate::database::InChatRequestsExt;
|
use crate::database::InChatRequestsExt;
|
||||||
|
use crate::errors::ServerError;
|
||||||
use crate::extensions::OnlineUsersExt;
|
use crate::extensions::OnlineUsersExt;
|
||||||
use crate::{
|
use crate::{
|
||||||
database::{OutChatRequestsExt, UserTableExt, UsersStatusExt},
|
database::{OutChatRequestsExt, UserTableExt, UsersStatusExt},
|
||||||
|
@ -56,7 +57,11 @@ pub async fn handle_chat_request(
|
||||||
return Some(WsError::RecipientBlacklist.into());
|
return Some(WsError::RecipientBlacklist.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
try_ws!(Some db.add_to_whitelist(from_user, to_public_key).await);
|
// To ignore the error if the requester added the recipient to the whitelist
|
||||||
|
// table before send a request to them
|
||||||
|
if let Err(ServerError::Internal(_)) = db.add_to_whitelist(from_user, to_public_key).await {
|
||||||
|
return Some(WsError::InternalServerError.into());
|
||||||
|
}
|
||||||
|
|
||||||
if try_ws!(Some db.is_whitelisted(&to_user, &from_public_key).await) {
|
if try_ws!(Some db.is_whitelisted(&to_user, &from_public_key).await) {
|
||||||
return Some(WsError::AlreadyInRecipientWhitelist.into());
|
return Some(WsError::AlreadyInRecipientWhitelist.into());
|
||||||
|
|
Loading…
Reference in a new issue