Refactor activity builders
This commit is contained in:
parent
1ea55b5d1a
commit
d090363698
2 changed files with 11 additions and 11 deletions
|
@ -261,7 +261,7 @@ pub fn create_activity_note(
|
||||||
let object = create_note(instance_host, instance_url, post);
|
let object = create_note(instance_host, instance_url, post);
|
||||||
let primary_audience = object.to.clone();
|
let primary_audience = object.to.clone();
|
||||||
let secondary_audience = object.cc.clone();
|
let secondary_audience = object.cc.clone();
|
||||||
let activity_id = get_object_url(instance_url, &post.id) + "/create";
|
let activity_id = format!("{}/create", object.id);
|
||||||
let activity = create_activity(
|
let activity = create_activity(
|
||||||
instance_url,
|
instance_url,
|
||||||
&post.author.username,
|
&post.author.username,
|
||||||
|
@ -277,17 +277,18 @@ pub fn create_activity_note(
|
||||||
pub fn create_activity_like(
|
pub fn create_activity_like(
|
||||||
instance_url: &str,
|
instance_url: &str,
|
||||||
actor_profile: &DbActorProfile,
|
actor_profile: &DbActorProfile,
|
||||||
note_id: &str,
|
post_id: &Uuid,
|
||||||
reaction_id: &Uuid,
|
reaction_id: &Uuid,
|
||||||
recipient_id: &str,
|
recipient_id: &str,
|
||||||
) -> Activity {
|
) -> Activity {
|
||||||
|
let object_id = get_object_url(instance_url, post_id);
|
||||||
let activity_id = get_object_url(instance_url, reaction_id);
|
let activity_id = get_object_url(instance_url, reaction_id);
|
||||||
let activity = create_activity(
|
let activity = create_activity(
|
||||||
instance_url,
|
instance_url,
|
||||||
&actor_profile.username,
|
&actor_profile.username,
|
||||||
LIKE,
|
LIKE,
|
||||||
activity_id,
|
activity_id,
|
||||||
note_id,
|
object_id,
|
||||||
vec![AP_PUBLIC.to_string(), recipient_id.to_string()],
|
vec![AP_PUBLIC.to_string(), recipient_id.to_string()],
|
||||||
vec![],
|
vec![],
|
||||||
);
|
);
|
||||||
|
@ -304,7 +305,7 @@ pub fn create_activity_undo_like(
|
||||||
instance_url,
|
instance_url,
|
||||||
reaction_id,
|
reaction_id,
|
||||||
);
|
);
|
||||||
let activity_id = get_object_url(instance_url, reaction_id) + "/undo";
|
let activity_id = format!("{}/undo", object_id);
|
||||||
create_activity(
|
create_activity(
|
||||||
instance_url,
|
instance_url,
|
||||||
&actor_profile.username,
|
&actor_profile.username,
|
||||||
|
@ -347,7 +348,7 @@ pub fn create_activity_undo_announce(
|
||||||
instance_url,
|
instance_url,
|
||||||
repost_id,
|
repost_id,
|
||||||
);
|
);
|
||||||
let activity_id = get_object_url(instance_url, repost_id) + "/undo";
|
let activity_id = format!("{}/undo", object_id);
|
||||||
let primary_audience = vec![
|
let primary_audience = vec![
|
||||||
AP_PUBLIC.to_string(),
|
AP_PUBLIC.to_string(),
|
||||||
recipient_id.to_string(),
|
recipient_id.to_string(),
|
||||||
|
@ -375,7 +376,7 @@ pub fn create_activity_delete_note(
|
||||||
former_type: Some(NOTE.to_string()),
|
former_type: Some(NOTE.to_string()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let activity_id = get_object_url(instance_url, &post.id) + "/delete";
|
let activity_id = format!("{}/delete", object.id);
|
||||||
let activity = create_activity(
|
let activity = create_activity(
|
||||||
instance_url,
|
instance_url,
|
||||||
&post.author.username,
|
&post.author.username,
|
||||||
|
@ -425,7 +426,7 @@ pub fn create_activity_accept_follow(
|
||||||
object_type: FOLLOW.to_string(),
|
object_type: FOLLOW.to_string(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let activity_id = follow_activity_id.to_string() + "/accept";
|
let activity_id = format!("{}/accept", follow_activity_id);
|
||||||
let activity = create_activity(
|
let activity = create_activity(
|
||||||
instance_url,
|
instance_url,
|
||||||
&actor_profile.username,
|
&actor_profile.username,
|
||||||
|
@ -454,13 +455,13 @@ pub fn create_activity_undo_follow(
|
||||||
);
|
);
|
||||||
let object = Object {
|
let object = Object {
|
||||||
context: Some(json!(AP_CONTEXT)),
|
context: Some(json!(AP_CONTEXT)),
|
||||||
id: follow_activity_id.clone(),
|
id: follow_activity_id,
|
||||||
object_type: FOLLOW.to_string(),
|
object_type: FOLLOW.to_string(),
|
||||||
actor: Some(follow_actor_id),
|
actor: Some(follow_actor_id),
|
||||||
object: Some(target_actor_id.to_owned()),
|
object: Some(target_actor_id.to_owned()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let activity_id = follow_activity_id + "/undo";
|
let activity_id = format!("{}/undo", object.id);
|
||||||
let activity = create_activity(
|
let activity = create_activity(
|
||||||
instance_url,
|
instance_url,
|
||||||
&actor_profile.username,
|
&actor_profile.username,
|
||||||
|
|
|
@ -239,11 +239,10 @@ async fn favourite(
|
||||||
// Federate
|
// Federate
|
||||||
let Audience { recipients, primary_recipient } =
|
let Audience { recipients, primary_recipient } =
|
||||||
get_like_recipients(db_client, &config.instance_url(), &post).await?;
|
get_like_recipients(db_client, &config.instance_url(), &post).await?;
|
||||||
let note_id = post.get_object_id(&config.instance_url());
|
|
||||||
let activity = create_activity_like(
|
let activity = create_activity_like(
|
||||||
&config.instance_url(),
|
&config.instance_url(),
|
||||||
¤t_user.profile,
|
¤t_user.profile,
|
||||||
¬e_id,
|
&post.id,
|
||||||
&reaction.id,
|
&reaction.id,
|
||||||
&primary_recipient,
|
&primary_recipient,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue