feat: emit OutboundFollowAccepted when remote accepts our follow
v0.4.2 — consumers can now react to outbound follow acceptance (e.g. import_remote_outbox to backfill). Previously the accept handler silently updated the DB with no event for consumers.
This commit is contained in:
@@ -49,14 +49,32 @@ impl Activity for AcceptActivity {
|
||||
}
|
||||
let local_user_id = crate::urls::extract_user_id_from_url(self.object.actor.inner())
|
||||
.ok_or_else(|| Error::bad_request(anyhow::anyhow!("invalid actor URL in Follow")))?;
|
||||
let remote_actor_url = self.actor.inner().as_str().to_string();
|
||||
data.follow_repo
|
||||
.update_following_status(
|
||||
local_user_id,
|
||||
self.actor.inner().as_str(),
|
||||
&remote_actor_url,
|
||||
FollowingStatus::Accepted,
|
||||
)
|
||||
.await?;
|
||||
tracing::info!(remote_actor = %self.actor.inner(), "follow accepted by remote");
|
||||
tracing::info!(remote_actor = %remote_actor_url, "follow accepted by remote");
|
||||
|
||||
if let Some(publisher) = &data.event_publisher {
|
||||
let outbox_url = data
|
||||
.actor_repo
|
||||
.get_remote_actor(&remote_actor_url)
|
||||
.await
|
||||
.ok()
|
||||
.flatten()
|
||||
.and_then(|a| a.outbox_url);
|
||||
let _ = publisher
|
||||
.publish(crate::data::FederationEvent::OutboundFollowAccepted {
|
||||
local_user_id,
|
||||
remote_actor_url,
|
||||
outbox_url,
|
||||
})
|
||||
.await;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,13 @@ pub enum FederationEvent {
|
||||
owner_user_id: uuid::Uuid,
|
||||
follower_inbox_url: String,
|
||||
},
|
||||
/// A remote actor accepted our outbound follow request.
|
||||
/// Call `ActivityPubService::import_remote_outbox(outbox_url, actor_url)` to backfill.
|
||||
OutboundFollowAccepted {
|
||||
local_user_id: uuid::Uuid,
|
||||
remote_actor_url: String,
|
||||
outbox_url: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
/// Receives typed federation events.
|
||||
|
||||
Reference in New Issue
Block a user