feat(presentation): ActivityPub routes — WebFinger, NodeInfo, inbox, outbox
This commit is contained in:
@@ -9,6 +9,9 @@ use async_trait::async_trait;
|
||||
use sqlx::PgPool;
|
||||
use domain::{errors::DomainError, events::DomainEvent, ports::EventPublisher};
|
||||
use postgres_search::PgSearchRepository;
|
||||
use activitypub_base::{ApFederationConfig, FederationData};
|
||||
use activitypub::ThoughtsObjectHandler;
|
||||
use postgres_federation::{PostgresApUserRepository, PostgresFederationRepository};
|
||||
use state::AppState;
|
||||
|
||||
struct NoOpEventPublisher;
|
||||
@@ -35,6 +38,28 @@ pub async fn build_state(pool: PgPool, jwt_secret: String) -> AppState {
|
||||
}
|
||||
};
|
||||
|
||||
let base_url = std::env::var("BASE_URL")
|
||||
.unwrap_or_else(|_| "http://localhost:3000".into());
|
||||
let allow_registration = std::env::var("ALLOW_REGISTRATION")
|
||||
.map(|v| v == "true")
|
||||
.unwrap_or(true);
|
||||
let fed_debug = std::env::var("RUST_ENV")
|
||||
.map(|v| v != "production")
|
||||
.unwrap_or(true);
|
||||
|
||||
let fed_data = FederationData::new(
|
||||
Arc::new(PostgresFederationRepository::new(pool.clone())),
|
||||
Arc::new(PostgresApUserRepository::new(pool.clone(), base_url.clone())),
|
||||
Arc::new(ThoughtsObjectHandler::new(pool.clone(), &base_url)),
|
||||
base_url,
|
||||
allow_registration,
|
||||
"thoughts".to_string(),
|
||||
None,
|
||||
);
|
||||
|
||||
let fed_config = ApFederationConfig::new(fed_data, fed_debug).await
|
||||
.expect("federation config failed");
|
||||
|
||||
AppState {
|
||||
users: Arc::new(postgres::user::PgUserRepository::new(pool.clone())),
|
||||
thoughts: Arc::new(postgres::thought::PgThoughtRepository::new(pool.clone())),
|
||||
@@ -52,5 +77,6 @@ pub async fn build_state(pool: PgPool, jwt_secret: String) -> AppState {
|
||||
auth: Arc::new(auth::JwtAuthService::new(jwt_secret, 86400 * 30)),
|
||||
hasher: Arc::new(auth::Argon2PasswordHasher),
|
||||
events: event_publisher,
|
||||
fed_config,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user