feat(ap): broadcast Update(Actor) when user updates their profile

This commit is contained in:
2026-05-15 05:32:25 +02:00
parent d360e506db
commit ca1ebc4b68
7 changed files with 45 additions and 1 deletions

View File

@@ -277,6 +277,10 @@ impl FederationEventService {
.await
}
DomainEvent::ProfileUpdated { user_id } => {
self.ap.broadcast_actor_update(user_id).await
}
_ => Ok(()),
}
}
@@ -308,6 +312,7 @@ mod tests {
undo_announced: Mutex<Vec<String>>,
liked: Mutex<Vec<String>>,
undo_liked: Mutex<Vec<String>>,
actor_updated: Mutex<Vec<UserId>>,
}
#[async_trait]
@@ -366,6 +371,11 @@ mod tests {
self.undo_liked.lock().unwrap().push(ap_id.to_string());
Ok(())
}
async fn broadcast_actor_update(&self, user_id: &UserId) -> Result<(), DomainError> {
self.actor_updated.lock().unwrap().push(user_id.clone());
Ok(())
}
}
fn alice() -> User {

View File

@@ -1,7 +1,8 @@
use domain::{
errors::DomainError,
events::DomainEvent,
models::{top_friend::TopFriend, user::User},
ports::{TopFriendRepository, UserRepository},
ports::{EventPublisher, TopFriendRepository, UserRepository},
value_objects::{UserId, Username},
};
@@ -38,8 +39,10 @@ pub async fn get_user_by_id_or_username(
}
}
#[allow(clippy::too_many_arguments)]
pub async fn update_profile(
users: &dyn UserRepository,
events: &dyn EventPublisher,
user_id: &UserId,
display_name: Option<String>,
bio: Option<String>,
@@ -56,6 +59,11 @@ pub async fn update_profile(
header_url,
custom_css,
)
.await?;
events
.publish(&DomainEvent::ProfileUpdated {
user_id: user_id.clone(),
})
.await
}