Deliver Announce(Note) activity to followers
This commit is contained in:
parent
c6b967567f
commit
a9b7426be4
2 changed files with 22 additions and 12 deletions
|
@ -228,11 +228,12 @@ pub fn create_activity_like(
|
||||||
pub fn create_activity_announce(
|
pub fn create_activity_announce(
|
||||||
instance_url: &str,
|
instance_url: &str,
|
||||||
actor_profile: &DbActorProfile,
|
actor_profile: &DbActorProfile,
|
||||||
object_id: &str,
|
post: &Post,
|
||||||
) -> Activity {
|
) -> Activity {
|
||||||
|
let object_id = post.get_object_id(instance_url);
|
||||||
let object = Object {
|
let object = Object {
|
||||||
context: Some(json!(AP_CONTEXT)),
|
context: Some(json!(AP_CONTEXT)),
|
||||||
id: object_id.to_string(),
|
id: object_id,
|
||||||
object_type: NOTE.to_string(),
|
object_type: NOTE.to_string(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
|
@ -253,17 +253,26 @@ async fn reblog(
|
||||||
get_actions_for_posts(db_client, ¤t_user.id, vec![&mut post]).await?;
|
get_actions_for_posts(db_client, ¤t_user.id, vec![&mut post]).await?;
|
||||||
|
|
||||||
// Federate
|
// Federate
|
||||||
let maybe_remote_actor = post.author.remote_actor()
|
let activity = create_activity_announce(
|
||||||
.map_err(|_| HttpError::InternalError)?;
|
&config.instance_url(),
|
||||||
if let Some(remote_actor) = maybe_remote_actor {
|
¤t_user.profile,
|
||||||
let object_id = post.object_id.as_ref().ok_or(HttpError::InternalError)?;
|
&post,
|
||||||
let activity = create_activity_announce(
|
);
|
||||||
&config.instance_url(),
|
let mut recipients: Vec<Actor> = Vec::new();
|
||||||
¤t_user.profile,
|
let followers = get_followers(db_client, ¤t_user.id).await?;
|
||||||
object_id,
|
for follower in followers {
|
||||||
);
|
let maybe_remote_follower = follower.remote_actor()
|
||||||
deliver_activity(&config, ¤t_user, activity, vec![remote_actor]);
|
.map_err(|_| HttpError::InternalError)?;
|
||||||
|
if let Some(remote_actor) = maybe_remote_follower {
|
||||||
|
recipients.push(remote_actor);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
let maybe_remote_author = post.author.remote_actor()
|
||||||
|
.map_err(|_| HttpError::InternalError)?;
|
||||||
|
if let Some(remote_actor) = maybe_remote_author {
|
||||||
|
recipients.push(remote_actor);
|
||||||
|
};
|
||||||
|
deliver_activity(&config, ¤t_user, activity, recipients);
|
||||||
|
|
||||||
let status = Status::from_post(post, &config.instance_url());
|
let status = Status::from_post(post, &config.instance_url());
|
||||||
Ok(HttpResponse::Ok().json(status))
|
Ok(HttpResponse::Ok().json(status))
|
||||||
|
|
Loading…
Reference in a new issue