feat(domain): ActivityPubRepository port with federation vocabulary
This commit is contained in:
@@ -154,3 +154,82 @@ pub trait SearchPort: Send + Sync {
|
||||
page: &PageParams,
|
||||
) -> Result<Paginated<User>, DomainError>;
|
||||
}
|
||||
|
||||
/// A local thought ready for AP serialization, with the author's username
|
||||
/// pre-joined so the handler can build AP URLs without a second query.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct OutboxEntry {
|
||||
pub thought: crate::models::thought::Thought,
|
||||
pub author_username: Username,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait ActivityPubRepository: Send + Sync {
|
||||
// ── Outbox (local → remote) ──────────────────────────────────────
|
||||
|
||||
/// All public local thoughts for this actor. Used for outbox totals
|
||||
/// and full-collection delivery.
|
||||
async fn outbox_entries_for_actor(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
) -> Result<Vec<OutboxEntry>, DomainError>;
|
||||
|
||||
/// Cursor page of public local thoughts, newest-first, before `before`.
|
||||
/// Used for OrderedCollectionPage responses.
|
||||
async fn outbox_page_for_actor(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
before: Option<chrono::DateTime<chrono::Utc>>,
|
||||
limit: usize,
|
||||
) -> Result<Vec<OutboxEntry>, DomainError>;
|
||||
|
||||
// ── Remote actor resolution ──────────────────────────────────────
|
||||
|
||||
/// Find the local UserId for a remote actor by its AP URL.
|
||||
async fn find_remote_actor_id(
|
||||
&self,
|
||||
actor_ap_url: &url::Url,
|
||||
) -> Result<Option<UserId>, DomainError>;
|
||||
|
||||
/// Ensure a remote actor placeholder exists; create one if absent.
|
||||
/// Idempotent — safe to call multiple times with the same URL.
|
||||
async fn intern_remote_actor(
|
||||
&self,
|
||||
actor_ap_url: &url::Url,
|
||||
) -> Result<UserId, DomainError>;
|
||||
|
||||
// ── Inbox processing (remote → local) ───────────────────────────
|
||||
|
||||
/// Persist an incoming remote Note. Idempotent on ap_id.
|
||||
async fn accept_note(
|
||||
&self,
|
||||
ap_id: &url::Url,
|
||||
author_id: &UserId,
|
||||
content: &str,
|
||||
published: chrono::DateTime<chrono::Utc>,
|
||||
sensitive: bool,
|
||||
content_warning: Option<String>,
|
||||
) -> Result<(), DomainError>;
|
||||
|
||||
/// Apply an Update to a previously accepted remote Note.
|
||||
async fn apply_note_update(
|
||||
&self,
|
||||
ap_id: &url::Url,
|
||||
new_content: &str,
|
||||
) -> Result<(), DomainError>;
|
||||
|
||||
/// Remove a specific remote Note (Delete activity). Only touches
|
||||
/// remotely-originated thoughts.
|
||||
async fn retract_note(&self, ap_id: &url::Url) -> Result<(), DomainError>;
|
||||
|
||||
/// Remove all Notes from a remote actor (actor-level Delete/Tombstone).
|
||||
async fn retract_actor_notes(
|
||||
&self,
|
||||
actor_ap_url: &url::Url,
|
||||
) -> Result<(), DomainError>;
|
||||
|
||||
// ── Node-level stats ─────────────────────────────────────────────
|
||||
|
||||
/// Total locally-authored thought count for NodeInfo responses.
|
||||
async fn count_local_notes(&self) -> Result<u64, DomainError>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user