- UserProfile struct groups display_name/bio/avatar/banner/also_known_as/profile_fields - User::from_persistence takes UserProfile (6 args, was 11) - PersistedReview struct for Review::from_persistence (1 arg, was 8) - WatchlistApInput struct for watchlist_to_ap_object (1 arg, was 8) - ActivityPubDeps struct for activitypub::wire (1 arg, was 11) - FederationRepos type alias for wire() return types - FeedSortBy: impl std::str::FromStr instead of inherent from_str - postgres users.rs: row_to_user takes &PgRow like sqlite - collapse nested ifs in multipart handlers - type alias for complex return types (image-converter, worker) - tui: allow large_enum_variant at crate level (pre-existing, unrelated)
42 lines
1.1 KiB
Rust
42 lines
1.1 KiB
Rust
mod backfill;
|
|
mod config;
|
|
mod handler;
|
|
|
|
pub use backfill::ConversionBackfillJob;
|
|
pub use config::{ConversionConfig, Format};
|
|
pub use handler::ImageConversionHandler;
|
|
|
|
use domain::ports::{
|
|
EventHandler, EventPublisher, ImageRefCommand, ImageRefQuery, ImageStorage, PeriodicJob,
|
|
};
|
|
use std::sync::Arc;
|
|
|
|
type ConversionPair = (Arc<dyn EventHandler>, Arc<dyn PeriodicJob>);
|
|
|
|
pub fn build(
|
|
image_storage: Arc<dyn ImageStorage>,
|
|
image_ref_command: Arc<dyn ImageRefCommand>,
|
|
image_ref_query: Arc<dyn ImageRefQuery>,
|
|
event_publisher: Arc<dyn EventPublisher>,
|
|
) -> anyhow::Result<Option<ConversionPair>> {
|
|
let config = match ConversionConfig::from_env()? {
|
|
Some(c) => c,
|
|
None => return Ok(None),
|
|
};
|
|
|
|
let format = config.format;
|
|
|
|
let handler = Arc::new(ImageConversionHandler::new(
|
|
Arc::clone(&image_storage),
|
|
image_ref_command,
|
|
format,
|
|
)) as Arc<dyn EventHandler>;
|
|
|
|
let job = Arc::new(ConversionBackfillJob::new(
|
|
image_ref_query,
|
|
Arc::clone(&event_publisher),
|
|
)) as Arc<dyn PeriodicJob>;
|
|
|
|
Ok(Some((handler, job)))
|
|
}
|