feat: MovieDto enrichment, movie detail page, PWA, watchlist, watchlist federation
This commit is contained in:
@@ -4,11 +4,11 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[features]
|
||||
default = ["sqlite"]
|
||||
default = ["sqlite", "sqlite-federation"]
|
||||
sqlite = ["dep:sqlite", "dep:sqlite-event-queue", "dep:sqlite-search"]
|
||||
postgres = ["dep:postgres", "dep:postgres-event-queue", "dep:postgres-search"]
|
||||
nats = ["dep:nats"]
|
||||
federation = []
|
||||
federation = ["application/federation"]
|
||||
sqlite-federation = ["sqlite", "dep:sqlite-federation", "dep:activitypub", "federation"]
|
||||
postgres-federation = ["postgres", "dep:postgres-federation", "dep:activitypub", "federation"]
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ use anyhow::Context;
|
||||
use domain::ports::{
|
||||
DiaryRepository, ImageRefCommand, ImageRefQuery, ImportProfileRepository,
|
||||
ImportSessionRepository, MovieProfileRepository, MovieRepository, PersonCommand, PersonQuery,
|
||||
ReviewRepository, SearchCommand, SearchPort, StatsRepository, UserRepository,
|
||||
ReviewRepository, SearchCommand, SearchPort, StatsRepository, UserRepository, WatchlistRepository,
|
||||
};
|
||||
|
||||
pub enum DbPool {
|
||||
@@ -23,6 +23,7 @@ pub struct Repos {
|
||||
pub import_session: Arc<dyn ImportSessionRepository>,
|
||||
pub import_profile: Arc<dyn ImportProfileRepository>,
|
||||
pub movie_profile: Arc<dyn MovieProfileRepository>,
|
||||
pub watchlist: Arc<dyn WatchlistRepository>,
|
||||
pub image_ref_command: Arc<dyn ImageRefCommand>,
|
||||
pub image_ref_query: Arc<dyn ImageRefQuery>,
|
||||
pub person_command: Arc<dyn PersonCommand>,
|
||||
@@ -35,26 +36,26 @@ pub async fn connect(database_url: &str, backend: &str) -> anyhow::Result<(Repos
|
||||
match backend {
|
||||
#[cfg(feature = "postgres")]
|
||||
"postgres" => {
|
||||
let (pool, m, r, d, s, u, is, ip, mp) =
|
||||
let (pool, m, r, d, s, u, is, ip, mp, wl) =
|
||||
postgres::wire(database_url).await.context("PostgreSQL connection failed")?;
|
||||
let (image_ref_command, image_ref_query) = postgres::create_image_ref(pool.clone());
|
||||
let (person_command, person_query) = postgres::create_person_adapter(pool.clone());
|
||||
let (search_command, search_port) = postgres_search::create_search_adapter(pool.clone());
|
||||
Ok((Repos { movie: m, review: r, diary: d, stats: s, user: u,
|
||||
import_session: is, import_profile: ip, movie_profile: mp,
|
||||
import_session: is, import_profile: ip, movie_profile: mp, watchlist: wl,
|
||||
image_ref_command, image_ref_query,
|
||||
person_command, person_query, search_command, search_port },
|
||||
DbPool::Postgres(pool)))
|
||||
}
|
||||
#[cfg(feature = "sqlite")]
|
||||
_ => {
|
||||
let (pool, m, r, d, s, u, is, ip, mp) =
|
||||
let (pool, m, r, d, s, u, is, ip, mp, wl) =
|
||||
sqlite::wire(database_url).await.context("SQLite connection failed")?;
|
||||
let (image_ref_command, image_ref_query) = sqlite::create_image_ref(pool.clone());
|
||||
let (person_command, person_query) = sqlite::create_person_adapter(pool.clone());
|
||||
let (search_command, search_port) = sqlite_search::create_search_adapter(pool.clone());
|
||||
Ok((Repos { movie: m, review: r, diary: d, stats: s, user: u,
|
||||
import_session: is, import_profile: ip, movie_profile: mp,
|
||||
import_session: is, import_profile: ip, movie_profile: mp, watchlist: wl,
|
||||
image_ref_command, image_ref_query,
|
||||
person_command, person_query, search_command, search_port },
|
||||
DbPool::Sqlite(pool)))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
#[cfg(feature = "nats")]
|
||||
use anyhow::Context;
|
||||
use domain::ports::{EventConsumer, EventPublisher};
|
||||
|
||||
|
||||
@@ -48,6 +48,14 @@ async fn main() -> anyhow::Result<()> {
|
||||
app_config.base_url.clone(),
|
||||
app_config.allow_registration,
|
||||
);
|
||||
// Wire federation repos early to get remote_watchlist_repo for AppContext.
|
||||
#[cfg(feature = "federation")]
|
||||
let (fed_federation_repo, _fed_social_query, fed_review_store, fed_remote_watchlist_repo) = match &db_pool {
|
||||
#[cfg(feature = "sqlite-federation")]
|
||||
db::DbPool::Sqlite(pool) => sqlite_federation::wire(pool.clone()),
|
||||
#[cfg(feature = "postgres-federation")]
|
||||
db::DbPool::Postgres(pool) => postgres_federation::wire(pool.clone()),
|
||||
};
|
||||
|
||||
let ctx = AppContext {
|
||||
movie_repository: repos.movie,
|
||||
@@ -66,6 +74,9 @@ async fn main() -> anyhow::Result<()> {
|
||||
import_session_repository: repos.import_session,
|
||||
import_profile_repository: repos.import_profile,
|
||||
movie_profile_repository: repos.movie_profile,
|
||||
watchlist_repository: repos.watchlist,
|
||||
#[cfg(feature = "federation")]
|
||||
remote_watchlist_repository: fed_remote_watchlist_repo.clone(),
|
||||
person_command: Arc::clone(&person_command),
|
||||
person_query: Arc::clone(&person_query),
|
||||
search_port: Arc::clone(&search_port),
|
||||
@@ -155,16 +166,11 @@ async fn main() -> anyhow::Result<()> {
|
||||
|
||||
#[cfg(feature = "federation")]
|
||||
{
|
||||
let (federation_repo, _social_query, review_store) = match &db_pool {
|
||||
#[cfg(feature = "sqlite-federation")]
|
||||
db::DbPool::Sqlite(pool) => sqlite_federation::wire(pool.clone()),
|
||||
#[cfg(feature = "postgres-federation")]
|
||||
db::DbPool::Postgres(pool) => postgres_federation::wire(pool.clone()),
|
||||
};
|
||||
|
||||
let ap = activitypub::wire(
|
||||
federation_repo,
|
||||
review_store,
|
||||
fed_federation_repo,
|
||||
fed_review_store,
|
||||
fed_remote_watchlist_repo,
|
||||
Arc::clone(&ctx.watchlist_repository),
|
||||
fed_user_repo,
|
||||
fed_movie_repo,
|
||||
fed_review_repo,
|
||||
|
||||
Reference in New Issue
Block a user