feat: v2 rewrite — hexagonal arch, ActivityPub federation, NATS, deployment-ready #1

Merged
GKaszewski merged 334 commits from v2 into master 2026-05-16 09:42:43 +00:00
2 changed files with 27 additions and 3 deletions
Showing only changes of commit fcfc1750fc - Show all commits

View File

@@ -1528,8 +1528,26 @@ impl domain::ports::FederationActionPort for ActivityPubService {
) -> Result<Vec<domain::models::remote_note::RemoteNote>, domain::errors::DomainError> { ) -> Result<Vec<domain::models::remote_note::RemoteNote>, domain::errors::DomainError> {
use chrono::DateTime; use chrono::DateTime;
let url = format!("{}?page={}", outbox_url, page); // Fetch the base outbox to find the real first-page URL.
let resp: serde_json::Value = reqwest::Client::new() // Mastodon uses ?page=true; other servers may use ?page=1 or a different param.
let client = reqwest::Client::new();
let base: serde_json::Value = client
.get(outbox_url)
.header("Accept", "application/activity+json, application/ld+json")
.send()
.await
.map_err(|e| domain::errors::DomainError::ExternalService(e.to_string()))?
.json()
.await
.map_err(|e| domain::errors::DomainError::ExternalService(e.to_string()))?;
// Prefer the `first` link from the OrderedCollection; fall back to ?page=1.
let url = base["first"]
.as_str()
.map(|s| s.to_string())
.unwrap_or_else(|| format!("{}?page={}", outbox_url, page));
let resp: serde_json::Value = client
.get(&url) .get(&url)
.header("Accept", "application/activity+json, application/ld+json") .header("Accept", "application/activity+json, application/ld+json")
.send() .send()

View File

@@ -154,10 +154,16 @@ impl ActivityPubRepository for PgActivityPubRepository {
return Ok(id); return Ok(id);
} }
let new_id = uuid::Uuid::new_v4(); let new_id = uuid::Uuid::new_v4();
let handle = actor_ap_url let raw = actor_ap_url
.path() .path()
.trim_start_matches('/') .trim_start_matches('/')
.replace('/', "_"); .replace('/', "_");
// username column is VARCHAR(32); truncate long paths (e.g. UUID-based actor URLs)
let handle = if raw.len() <= 32 {
raw
} else {
format!("remote_{}", &new_id.to_string()[..13])
};
sqlx::query( sqlx::query(
"INSERT INTO users(id,username,email,password_hash,local,ap_id,created_at,updated_at) "INSERT INTO users(id,username,email,password_hash,local,ap_id,created_at,updated_at)
VALUES($1,$2,$3,'',false,$4,NOW(),NOW()) ON CONFLICT(ap_id) DO NOTHING", VALUES($1,$2,$3,'',false,$4,NOW(),NOW()) ON CONFLICT(ap_id) DO NOTHING",