Create unified handler for Undo() activities
This commit is contained in:
parent
648a217971
commit
67313dbac7
3 changed files with 10 additions and 8 deletions
|
@ -14,7 +14,7 @@ pub mod move_person;
|
|||
pub mod reject_follow;
|
||||
pub mod remove;
|
||||
pub mod undo;
|
||||
pub mod undo_follow;
|
||||
mod undo_follow;
|
||||
pub mod update;
|
||||
mod update_note;
|
||||
pub mod update_person;
|
||||
|
|
|
@ -3,8 +3,9 @@ use tokio_postgres::GenericClient;
|
|||
use crate::activitypub::{
|
||||
activity::Activity,
|
||||
receiver::find_object_id,
|
||||
vocabulary::{ANNOUNCE, LIKE},
|
||||
vocabulary::{ANNOUNCE, FOLLOW, LIKE},
|
||||
};
|
||||
use crate::config::Config;
|
||||
use crate::database::DatabaseError;
|
||||
use crate::errors::ValidationError;
|
||||
use crate::models::posts::queries::{
|
||||
|
@ -17,11 +18,17 @@ use crate::models::reactions::queries::{
|
|||
get_reaction_by_remote_activity_id,
|
||||
};
|
||||
use super::HandlerResult;
|
||||
use super::undo_follow::handle_undo_follow;
|
||||
|
||||
pub async fn handle_undo(
|
||||
config: &Config,
|
||||
db_client: &mut impl GenericClient,
|
||||
activity: Activity,
|
||||
) -> HandlerResult {
|
||||
if let Some(FOLLOW) = activity.object["type"].as_str() {
|
||||
return handle_undo_follow(config, db_client, activity).await
|
||||
};
|
||||
|
||||
let actor_profile = get_profile_by_remote_actor_id(
|
||||
db_client,
|
||||
&activity.actor,
|
||||
|
|
|
@ -31,7 +31,6 @@ use super::handlers::{
|
|||
reject_follow::handle_reject_follow,
|
||||
remove::handle_remove,
|
||||
undo::handle_undo,
|
||||
undo_follow::handle_undo_follow,
|
||||
update::handle_update,
|
||||
};
|
||||
use super::vocabulary::*;
|
||||
|
@ -255,13 +254,9 @@ pub async fn receive_activity(
|
|||
require_actor_signature(&activity.actor, &signer_id)?;
|
||||
handle_follow(config, db_client, activity).await?
|
||||
},
|
||||
(UNDO, FOLLOW) => {
|
||||
require_actor_signature(&activity.actor, &signer_id)?;
|
||||
handle_undo_follow(config, db_client, activity).await?
|
||||
},
|
||||
(UNDO, _) => {
|
||||
require_actor_signature(&activity.actor, &signer_id)?;
|
||||
handle_undo(db_client, activity).await?
|
||||
handle_undo(config, db_client, activity).await?
|
||||
},
|
||||
(UPDATE, _) => {
|
||||
require_actor_signature(&activity.actor, &signer_id)?;
|
||||
|
|
Loading…
Reference in a new issue