refactor(domain): remove ap_id/inbox_url from User and Thought; use ActivityPubRepository lookups
This commit is contained in:
@@ -74,6 +74,7 @@ fn thought_note_json(
|
||||
thought: &domain::models::thought::Thought,
|
||||
local_actor: &crate::actors::DbActor,
|
||||
base_url: &str,
|
||||
in_reply_to_url: Option<&str>,
|
||||
) -> anyhow::Result<(url::Url, serde_json::Value)> {
|
||||
let ap_id = url::Url::parse(&format!("{}/thoughts/{}", base_url, thought.id))?;
|
||||
|
||||
@@ -107,7 +108,7 @@ fn thought_note_json(
|
||||
if let Some(ref cw) = thought.content_warning {
|
||||
note["summary"] = serde_json::json!(cw);
|
||||
}
|
||||
if let Some(ref reply_url) = thought.in_reply_to_url {
|
||||
if let Some(reply_url) = in_reply_to_url {
|
||||
note["inReplyTo"] = serde_json::json!(reply_url);
|
||||
}
|
||||
if let Some(updated_at) = thought.updated_at {
|
||||
@@ -1415,6 +1416,7 @@ impl domain::ports::OutboundFederationPort for ActivityPubService {
|
||||
author_user_id: &domain::value_objects::UserId,
|
||||
thought: &domain::models::thought::Thought,
|
||||
_author_username: &str,
|
||||
in_reply_to_url: Option<&str>,
|
||||
) -> Result<(), domain::errors::DomainError> {
|
||||
let user_uuid = author_user_id.as_uuid();
|
||||
let data = self.federation_config.to_request_data();
|
||||
@@ -1426,8 +1428,9 @@ impl domain::ports::OutboundFederationPort for ActivityPubService {
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
let (ap_id, note) = thought_note_json(thought, &local_actor, &self.base_url)
|
||||
.map_err(|e| domain::errors::DomainError::Internal(e.to_string()))?;
|
||||
let (ap_id, note) =
|
||||
thought_note_json(thought, &local_actor, &self.base_url, in_reply_to_url)
|
||||
.map_err(|e| domain::errors::DomainError::Internal(e.to_string()))?;
|
||||
|
||||
let create = crate::activities::CreateActivity {
|
||||
id: ap_id,
|
||||
@@ -1476,6 +1479,7 @@ impl domain::ports::OutboundFederationPort for ActivityPubService {
|
||||
author_user_id: &domain::value_objects::UserId,
|
||||
thought: &domain::models::thought::Thought,
|
||||
_author_username: &str,
|
||||
in_reply_to_url: Option<&str>,
|
||||
) -> Result<(), domain::errors::DomainError> {
|
||||
let user_uuid = author_user_id.as_uuid();
|
||||
let data = self.federation_config.to_request_data();
|
||||
@@ -1487,8 +1491,9 @@ impl domain::ports::OutboundFederationPort for ActivityPubService {
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
let (_ap_id, note) = thought_note_json(thought, &local_actor, &self.base_url)
|
||||
.map_err(|e| domain::errors::DomainError::Internal(e.to_string()))?;
|
||||
let (_ap_id, note) =
|
||||
thought_note_json(thought, &local_actor, &self.base_url, in_reply_to_url)
|
||||
.map_err(|e| domain::errors::DomainError::Internal(e.to_string()))?;
|
||||
|
||||
let update_id = url::Url::parse(&format!(
|
||||
"{}/activities/update/{}",
|
||||
|
||||
Reference in New Issue
Block a user