Use plain object ID instead of embedded activity in Accept(Follow)
This commit is contained in:
parent
51318046a8
commit
7c3d669e9b
1 changed files with 4 additions and 12 deletions
|
@ -1,13 +1,11 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_json::json;
|
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
activity::Object,
|
|
||||||
actors::types::Actor,
|
actors::types::Actor,
|
||||||
constants::AP_CONTEXT,
|
constants::AP_CONTEXT,
|
||||||
deliverer::OutgoingActivity,
|
deliverer::OutgoingActivity,
|
||||||
identifiers::{local_actor_id, local_object_id},
|
identifiers::{local_actor_id, local_object_id},
|
||||||
vocabulary::{ACCEPT, FOLLOW},
|
vocabulary::ACCEPT,
|
||||||
};
|
};
|
||||||
use crate::config::Instance;
|
use crate::config::Instance;
|
||||||
use crate::models::profiles::types::DbActorProfile;
|
use crate::models::profiles::types::DbActorProfile;
|
||||||
|
@ -24,7 +22,7 @@ struct AcceptFollow {
|
||||||
|
|
||||||
id: String,
|
id: String,
|
||||||
actor: String,
|
actor: String,
|
||||||
object: Object,
|
object: String,
|
||||||
|
|
||||||
to: Vec<String>,
|
to: Vec<String>,
|
||||||
}
|
}
|
||||||
|
@ -35,12 +33,6 @@ fn build_accept_follow(
|
||||||
source_actor_id: &str,
|
source_actor_id: &str,
|
||||||
follow_activity_id: &str,
|
follow_activity_id: &str,
|
||||||
) -> AcceptFollow {
|
) -> AcceptFollow {
|
||||||
let object = Object {
|
|
||||||
context: Some(json!(AP_CONTEXT)),
|
|
||||||
id: follow_activity_id.to_string(),
|
|
||||||
object_type: FOLLOW.to_string(),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
// Accept(Follow) is idempotent so its ID can be random
|
// Accept(Follow) is idempotent so its ID can be random
|
||||||
let activity_id = local_object_id(instance_url, &new_uuid());
|
let activity_id = local_object_id(instance_url, &new_uuid());
|
||||||
let actor_id = local_actor_id(instance_url, &actor_profile.username);
|
let actor_id = local_actor_id(instance_url, &actor_profile.username);
|
||||||
|
@ -49,7 +41,7 @@ fn build_accept_follow(
|
||||||
activity_type: ACCEPT.to_string(),
|
activity_type: ACCEPT.to_string(),
|
||||||
id: activity_id,
|
id: activity_id,
|
||||||
actor: actor_id,
|
actor: actor_id,
|
||||||
object: object,
|
object: follow_activity_id.to_string(),
|
||||||
to: vec![source_actor_id.to_string()],
|
to: vec![source_actor_id.to_string()],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +90,7 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(activity.id.starts_with(INSTANCE_URL), true);
|
assert_eq!(activity.id.starts_with(INSTANCE_URL), true);
|
||||||
assert_eq!(activity.activity_type, "Accept");
|
assert_eq!(activity.activity_type, "Accept");
|
||||||
assert_eq!(activity.object.id, follow_activity_id);
|
assert_eq!(activity.object, follow_activity_id);
|
||||||
assert_eq!(activity.to, vec![follower_id]);
|
assert_eq!(activity.to, vec![follower_id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue