fix: import remote outbox on outbound follow accept (k-ap 0.4.2)
k-ap now emits OutboundFollowAccepted when remote accepts our follow. Bridge maps it to FollowAccepted domain event. Worker handler looks up the actor's outbox URL and calls import_remote_outbox. Previously the accept was silent — no backfill happened, feed stayed empty.
This commit is contained in:
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -2892,9 +2892,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "k-ap"
|
name = "k-ap"
|
||||||
version = "0.4.1"
|
version = "0.4.2"
|
||||||
source = "sparse+https://git.gabrielkaszewski.dev/api/packages/GKaszewski/cargo/"
|
source = "sparse+https://git.gabrielkaszewski.dev/api/packages/GKaszewski/cargo/"
|
||||||
checksum = "03e39c04075b39960c329feba896a16aba37f0863669c28e7106b7cc45a9988d"
|
checksum = "4291cac43b119cce0be6e2ba8d85339f3f4c69b266cb7c00fb4cb179302b97e4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"activitypub_federation",
|
"activitypub_federation",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
@@ -6714,7 +6714,7 @@ version = "0.1.11"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ version = "0.1.0"
|
|||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
k-ap = { version = "0.4.1", registry = "gitea" }
|
k-ap = { version = "0.4.2", registry = "gitea" }
|
||||||
domain = { workspace = true }
|
domain = { workspace = true }
|
||||||
axum = { workspace = true }
|
axum = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
|
|||||||
@@ -46,6 +46,28 @@ impl k_ap::EventPublisher for FederationEventBridge {
|
|||||||
tracing::warn!(inbox = %inbox, error = %error, "federation delivery failed permanently");
|
tracing::warn!(inbox = %inbox, error = %error, "federation delivery failed permanently");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
FederationEvent::OutboundFollowAccepted {
|
||||||
|
local_user_id,
|
||||||
|
remote_actor_url,
|
||||||
|
outbox_url,
|
||||||
|
} => {
|
||||||
|
let identity = domain::value_objects::SocialIdentity::Remote {
|
||||||
|
actor_url: remote_actor_url,
|
||||||
|
};
|
||||||
|
self.domain_publisher
|
||||||
|
.publish(&DomainEvent::FollowAccepted {
|
||||||
|
owner: UserId::from_uuid(local_user_id),
|
||||||
|
requester: identity,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.map_err(|e| anyhow::anyhow!(e.to_string()))?;
|
||||||
|
|
||||||
|
if let Some(outbox) = outbox_url {
|
||||||
|
tracing::info!(outbox = %outbox, "importing remote outbox after follow accepted");
|
||||||
|
// Handled by FollowBackfillHandler reacting to FollowAccepted
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use domain::{
|
use domain::{errors::DomainError, events::DomainEvent, ports::EventHandler, value_objects::SocialIdentity};
|
||||||
errors::DomainError, events::DomainEvent, ports::EventHandler, value_objects::SocialIdentity,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub struct FollowBackfillHandler {
|
pub struct FollowBackfillHandler {
|
||||||
pub ap_service: Arc<dyn activitypub::ActivityPubPort>,
|
pub ap_service: Arc<dyn activitypub::ActivityPubPort>,
|
||||||
@@ -14,10 +12,26 @@ impl EventHandler for FollowBackfillHandler {
|
|||||||
async fn handle(&self, event: &DomainEvent) -> Result<(), DomainError> {
|
async fn handle(&self, event: &DomainEvent) -> Result<(), DomainError> {
|
||||||
match event {
|
match event {
|
||||||
DomainEvent::FollowAccepted {
|
DomainEvent::FollowAccepted {
|
||||||
|
owner,
|
||||||
requester: SocialIdentity::Remote { actor_url },
|
requester: SocialIdentity::Remote { actor_url },
|
||||||
..
|
|
||||||
} => {
|
} => {
|
||||||
tracing::info!(actor = %actor_url, "follow accepted from remote actor");
|
tracing::info!(actor = %actor_url, "follow accepted — looking up outbox for import");
|
||||||
|
let following = self
|
||||||
|
.ap_service
|
||||||
|
.get_following(owner.value())
|
||||||
|
.await
|
||||||
|
.map_err(|e| DomainError::InfrastructureError(e.to_string()))?;
|
||||||
|
if let Some(actor) = following.iter().find(|a| a.url == *actor_url) {
|
||||||
|
if let Some(outbox_url) = &actor.outbox_url {
|
||||||
|
tracing::info!(outbox = %outbox_url, actor = %actor_url, "importing remote outbox");
|
||||||
|
self.ap_service
|
||||||
|
.import_remote_outbox(outbox_url, actor_url)
|
||||||
|
.await
|
||||||
|
.map_err(|e| DomainError::InfrastructureError(e.to_string()))?;
|
||||||
|
} else {
|
||||||
|
tracing::warn!(actor = %actor_url, "no outbox URL for accepted follow — skipping import");
|
||||||
|
}
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
DomainEvent::BackfillFollower {
|
DomainEvent::BackfillFollower {
|
||||||
|
|||||||
Reference in New Issue
Block a user