feat: v2 rewrite — hexagonal arch, ActivityPub federation, NATS, deployment-ready #1
@@ -22,6 +22,7 @@ pub struct DbActor {
|
||||
pub public_key_pem: String,
|
||||
pub private_key_pem: Option<String>,
|
||||
pub inbox_url: Url,
|
||||
pub shared_inbox_url: Option<Url>,
|
||||
pub outbox_url: Url,
|
||||
pub followers_url: Url,
|
||||
pub following_url: Url,
|
||||
@@ -118,6 +119,7 @@ pub async fn get_local_actor(
|
||||
|
||||
let ap_id = crate::urls::actor_url(&data.base_url, user_id);
|
||||
let inbox_url = Url::parse(&format!("{}/inbox", &ap_id)).expect("valid inbox url");
|
||||
let shared_inbox_url = Url::parse(&format!("{}/inbox", data.base_url)).ok();
|
||||
let outbox_url = Url::parse(&format!("{}/outbox", &ap_id)).expect("valid outbox url");
|
||||
let followers_url = Url::parse(&format!("{}/followers", &ap_id)).expect("valid followers url");
|
||||
let following_url = Url::parse(&format!("{}/following", &ap_id)).expect("valid following url");
|
||||
@@ -128,6 +130,7 @@ pub async fn get_local_actor(
|
||||
public_key_pem: public_key,
|
||||
private_key_pem: Some(private_key),
|
||||
inbox_url,
|
||||
shared_inbox_url,
|
||||
outbox_url,
|
||||
followers_url,
|
||||
following_url,
|
||||
@@ -181,6 +184,7 @@ impl Object for DbActor {
|
||||
|
||||
let ap_id = crate::urls::actor_url(&data.base_url, user_id);
|
||||
let inbox_url = Url::parse(&format!("{}/inbox", &ap_id)).expect("valid url");
|
||||
let shared_inbox_url = Url::parse(&format!("{}/inbox", data.base_url)).ok();
|
||||
let outbox_url = Url::parse(&format!("{}/outbox", &ap_id)).expect("valid url");
|
||||
let followers_url = Url::parse(&format!("{}/followers", &ap_id)).expect("valid url");
|
||||
let following_url = Url::parse(&format!("{}/following", &ap_id)).expect("valid url");
|
||||
@@ -191,6 +195,7 @@ impl Object for DbActor {
|
||||
public_key_pem: public_key,
|
||||
private_key_pem: private_key,
|
||||
inbox_url,
|
||||
shared_inbox_url,
|
||||
outbox_url,
|
||||
followers_url,
|
||||
following_url,
|
||||
@@ -268,11 +273,12 @@ impl Object for DbActor {
|
||||
}
|
||||
|
||||
async fn from_json(json: Self::Kind, data: &Data<Self::DataType>) -> Result<Self, Self::Error> {
|
||||
let shared_inbox_url = json.endpoints.as_ref().map(|e| e.shared_inbox.to_string());
|
||||
let actor = RemoteActor {
|
||||
url: json.id.inner().to_string(),
|
||||
handle: json.preferred_username.clone(),
|
||||
inbox_url: json.inbox.to_string(),
|
||||
shared_inbox_url: None,
|
||||
shared_inbox_url,
|
||||
display_name: json.name.clone(),
|
||||
avatar_url: json.icon.as_ref().map(|i| i.url.to_string()),
|
||||
outbox_url: Some(json.outbox.to_string()),
|
||||
@@ -283,6 +289,10 @@ impl Object for DbActor {
|
||||
let user_id = uuid::Uuid::new_v5(&uuid::Uuid::NAMESPACE_URL, url_str.as_bytes());
|
||||
let ap_id = json.id.inner().clone();
|
||||
let inbox_url = json.inbox.clone();
|
||||
let shared_inbox_url = json
|
||||
.endpoints
|
||||
.as_ref()
|
||||
.and_then(|e| Url::parse(e.shared_inbox.as_str()).ok());
|
||||
let outbox_url = json.outbox.clone();
|
||||
let followers_url = json.followers.clone();
|
||||
let following_url = json.following.clone();
|
||||
@@ -293,6 +303,7 @@ impl Object for DbActor {
|
||||
public_key_pem: json.public_key.public_key_pem,
|
||||
private_key_pem: None,
|
||||
inbox_url,
|
||||
shared_inbox_url,
|
||||
outbox_url,
|
||||
followers_url,
|
||||
following_url,
|
||||
|
||||
@@ -575,7 +575,10 @@ impl ActivityPubService {
|
||||
url: remote_actor.ap_id.to_string(),
|
||||
handle: full_handle,
|
||||
inbox_url: remote_actor.inbox_url.to_string(),
|
||||
shared_inbox_url: None,
|
||||
shared_inbox_url: remote_actor
|
||||
.shared_inbox_url
|
||||
.as_ref()
|
||||
.map(|u| u.to_string()),
|
||||
display_name: Some(remote_actor.username.clone()),
|
||||
avatar_url: remote_actor.avatar_url.as_ref().map(|u| u.to_string()),
|
||||
outbox_url: Some(remote_actor.outbox_url.to_string()),
|
||||
@@ -1638,7 +1641,7 @@ impl domain::ports::FederationActionPort for ActivityPubService {
|
||||
handle: full_handle,
|
||||
display_name: Some(actor.username.clone()),
|
||||
inbox_url: actor.inbox_url.to_string(),
|
||||
shared_inbox_url: None,
|
||||
shared_inbox_url: actor.shared_inbox_url.as_ref().map(|u| u.to_string()),
|
||||
public_key: actor.public_key_pem.clone(),
|
||||
avatar_url: actor.avatar_url.as_ref().map(|u| u.to_string()),
|
||||
last_fetched_at: actor.last_refreshed_at,
|
||||
|
||||
Reference in New Issue
Block a user