fix(activitypub-base): validate update Note id URL, add updated field to Update Notes
This commit is contained in:
@@ -1278,6 +1278,8 @@ impl ActivityPubService {
|
|||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl domain::ports::OutboundFederationPort for ActivityPubService {
|
impl domain::ports::OutboundFederationPort for ActivityPubService {
|
||||||
|
// Actor identity (ap_id, followers_url) comes from federation config via get_local_actor.
|
||||||
|
// author_username is provided by the caller but not needed here.
|
||||||
async fn broadcast_create(
|
async fn broadcast_create(
|
||||||
&self,
|
&self,
|
||||||
author_user_id: &domain::value_objects::UserId,
|
author_user_id: &domain::value_objects::UserId,
|
||||||
@@ -1328,6 +1330,8 @@ impl domain::ports::OutboundFederationPort for ActivityPubService {
|
|||||||
.map_err(|e| domain::errors::DomainError::Internal(e.to_string()))
|
.map_err(|e| domain::errors::DomainError::Internal(e.to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Actor identity (ap_id, followers_url) comes from federation config via get_local_actor.
|
||||||
|
// author_username is provided by the caller but not needed here.
|
||||||
async fn broadcast_update(
|
async fn broadcast_update(
|
||||||
&self,
|
&self,
|
||||||
author_user_id: &domain::value_objects::UserId,
|
author_user_id: &domain::value_objects::UserId,
|
||||||
@@ -1340,10 +1344,11 @@ impl domain::ports::OutboundFederationPort for ActivityPubService {
|
|||||||
.await
|
.await
|
||||||
.map_err(|e| domain::errors::DomainError::Internal(e.to_string()))?;
|
.map_err(|e| domain::errors::DomainError::Internal(e.to_string()))?;
|
||||||
|
|
||||||
let ap_id = format!("{}/thoughts/{}", self.base_url, thought.id);
|
let ap_id = url::Url::parse(&format!("{}/thoughts/{}", self.base_url, thought.id))
|
||||||
|
.map_err(|e| domain::errors::DomainError::Internal(e.to_string()))?;
|
||||||
let mut note = serde_json::json!({
|
let mut note = serde_json::json!({
|
||||||
"type": "Note",
|
"type": "Note",
|
||||||
"id": ap_id,
|
"id": ap_id.to_string(),
|
||||||
"attributedTo": local_actor.ap_id.to_string(),
|
"attributedTo": local_actor.ap_id.to_string(),
|
||||||
"content": thought.content.as_str(),
|
"content": thought.content.as_str(),
|
||||||
"published": thought.created_at.to_rfc3339(),
|
"published": thought.created_at.to_rfc3339(),
|
||||||
@@ -1357,6 +1362,9 @@ impl domain::ports::OutboundFederationPort for ActivityPubService {
|
|||||||
if let Some(ref reply_url) = thought.in_reply_to_url {
|
if let Some(ref reply_url) = thought.in_reply_to_url {
|
||||||
note["inReplyTo"] = serde_json::json!(reply_url);
|
note["inReplyTo"] = serde_json::json!(reply_url);
|
||||||
}
|
}
|
||||||
|
if let Some(updated_at) = thought.updated_at {
|
||||||
|
note["updated"] = serde_json::json!(updated_at.to_rfc3339());
|
||||||
|
}
|
||||||
|
|
||||||
self.broadcast_update_to_followers(user_uuid, note)
|
self.broadcast_update_to_followers(user_uuid, note)
|
||||||
.await
|
.await
|
||||||
|
|||||||
Reference in New Issue
Block a user