Ignore Accept(Follow) if follow request is already accepted
This commit is contained in:
parent
d0f97a33b3
commit
9aafe0eaf4
2 changed files with 10 additions and 0 deletions
|
@ -13,6 +13,7 @@ use crate::models::relationships::queries::{
|
||||||
follow_request_accepted,
|
follow_request_accepted,
|
||||||
get_follow_request_by_id,
|
get_follow_request_by_id,
|
||||||
};
|
};
|
||||||
|
use crate::models::relationships::types::FollowRequestStatus;
|
||||||
use super::HandlerResult;
|
use super::HandlerResult;
|
||||||
|
|
||||||
pub async fn handle_accept_follow(
|
pub async fn handle_accept_follow(
|
||||||
|
@ -30,6 +31,10 @@ pub async fn handle_accept_follow(
|
||||||
if follow_request.target_id != actor_profile.id {
|
if follow_request.target_id != actor_profile.id {
|
||||||
return Err(ValidationError("actor is not a target").into());
|
return Err(ValidationError("actor is not a target").into());
|
||||||
};
|
};
|
||||||
|
if matches!(follow_request.request_status, FollowRequestStatus::Accepted) {
|
||||||
|
// Ignore Accept if follow request already accepted
|
||||||
|
return Ok(None);
|
||||||
|
};
|
||||||
follow_request_accepted(db_client, &follow_request_id).await?;
|
follow_request_accepted(db_client, &follow_request_id).await?;
|
||||||
Ok(Some(FOLLOW))
|
Ok(Some(FOLLOW))
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ use crate::models::relationships::queries::{
|
||||||
follow_request_rejected,
|
follow_request_rejected,
|
||||||
get_follow_request_by_id,
|
get_follow_request_by_id,
|
||||||
};
|
};
|
||||||
|
use crate::models::relationships::types::FollowRequestStatus;
|
||||||
use super::HandlerResult;
|
use super::HandlerResult;
|
||||||
|
|
||||||
pub async fn handle_reject_follow(
|
pub async fn handle_reject_follow(
|
||||||
|
@ -30,6 +31,10 @@ pub async fn handle_reject_follow(
|
||||||
if follow_request.target_id != actor_profile.id {
|
if follow_request.target_id != actor_profile.id {
|
||||||
return Err(ValidationError("actor is not a target").into());
|
return Err(ValidationError("actor is not a target").into());
|
||||||
};
|
};
|
||||||
|
if matches!(follow_request.request_status, FollowRequestStatus::Rejected) {
|
||||||
|
// Ignore Reject if follow request already rejected
|
||||||
|
return Ok(None);
|
||||||
|
};
|
||||||
follow_request_rejected(db_client, &follow_request_id).await?;
|
follow_request_rejected(db_client, &follow_request_id).await?;
|
||||||
Ok(Some(FOLLOW))
|
Ok(Some(FOLLOW))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue