feat(domain): RemoteActor fields, RemoteNote, FetchRemoteActorPosts event, fetch_outbox_page port

This commit is contained in:
2026-05-14 22:08:26 +02:00
parent cbfaeb95ac
commit 70fc4fbcd0
9 changed files with 78 additions and 1 deletions

View File

@@ -60,6 +60,10 @@ pub enum DomainEvent {
UserRegistered {
user_id: UserId,
},
FetchRemoteActorPosts {
actor_ap_url: String,
outbox_url: String,
},
}
pub struct EventEnvelope {

View File

@@ -2,6 +2,7 @@ pub mod api_key;
pub mod feed;
pub mod notification;
pub mod remote_actor;
pub mod remote_note;
pub mod social;
pub mod tag;
pub mod thought;

View File

@@ -10,4 +10,9 @@ pub struct RemoteActor {
pub public_key: String,
pub avatar_url: Option<String>,
pub last_fetched_at: DateTime<Utc>,
pub bio: Option<String>,
pub banner_url: Option<String>,
pub also_known_as: Option<String>,
pub outbox_url: Option<String>,
pub attachment: Vec<(String, String)>,
}

View File

@@ -0,0 +1,10 @@
use chrono::{DateTime, Utc};
#[derive(Debug, Clone)]
pub struct RemoteNote {
pub ap_id: String,
pub content: String,
pub published: DateTime<Utc>,
pub sensitive: bool,
pub content_warning: Option<String>,
}

View File

@@ -209,6 +209,11 @@ pub trait FederationActionPort: Send + Sync {
user_id: &UserId,
page: Option<u32>,
) -> Result<String, DomainError>;
async fn fetch_outbox_page(
&self,
outbox_url: &str,
page: u32,
) -> Result<Vec<crate::models::remote_note::RemoteNote>, DomainError>;
}
#[async_trait]

View File

@@ -567,6 +567,14 @@ impl FederationActionPort for TestStore {
) -> Result<String, DomainError> {
Err(DomainError::NotFound)
}
async fn fetch_outbox_page(
&self,
_outbox_url: &str,
_page: u32,
) -> Result<Vec<crate::models::remote_note::RemoteNote>, DomainError> {
Ok(vec![])
}
}
#[async_trait]
@@ -833,6 +841,16 @@ mod federation_port_tests {
let err = store.actor_json(&UserId::new()).await.unwrap_err();
assert!(matches!(err, DomainError::NotFound));
}
#[tokio::test]
async fn test_store_fetch_outbox_returns_empty() {
let store = TestStore::default();
let notes = store
.fetch_outbox_page("https://example.com/outbox", 1)
.await
.unwrap();
assert!(notes.is_empty());
}
}
#[cfg(test)]