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(
|
||||
instance_url: &str,
|
||||
actor_profile: &DbActorProfile,
|
||||
object_id: &str,
|
||||
post: &Post,
|
||||
) -> Activity {
|
||||
let object_id = post.get_object_id(instance_url);
|
||||
let object = Object {
|
||||
context: Some(json!(AP_CONTEXT)),
|
||||
id: object_id.to_string(),
|
||||
id: object_id,
|
||||
object_type: NOTE.to_string(),
|
||||
..Default::default()
|
||||
};
|
||||
|
|
|
@ -253,17 +253,26 @@ async fn reblog(
|
|||
get_actions_for_posts(db_client, ¤t_user.id, vec![&mut post]).await?;
|
||||
|
||||
// Federate
|
||||
let maybe_remote_actor = post.author.remote_actor()
|
||||
.map_err(|_| HttpError::InternalError)?;
|
||||
if let Some(remote_actor) = maybe_remote_actor {
|
||||
let object_id = post.object_id.as_ref().ok_or(HttpError::InternalError)?;
|
||||
let activity = create_activity_announce(
|
||||
&config.instance_url(),
|
||||
¤t_user.profile,
|
||||
object_id,
|
||||
);
|
||||
deliver_activity(&config, ¤t_user, activity, vec![remote_actor]);
|
||||
let activity = create_activity_announce(
|
||||
&config.instance_url(),
|
||||
¤t_user.profile,
|
||||
&post,
|
||||
);
|
||||
let mut recipients: Vec<Actor> = Vec::new();
|
||||
let followers = get_followers(db_client, ¤t_user.id).await?;
|
||||
for follower in followers {
|
||||
let maybe_remote_follower = follower.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());
|
||||
Ok(HttpResponse::Ok().json(status))
|
||||
|
|
Loading…
Reference in a new issue