diff --git a/upub/core/src/config.rs b/upub/core/src/config.rs index ec8e10f9..c78a20f9 100644 --- a/upub/core/src/config.rs +++ b/upub/core/src/config.rs @@ -79,6 +79,9 @@ pub struct SecurityConfig { #[serde_inline_default(20)] pub thread_crawl_depth: u32, + + #[serde_inline_default(30)] + pub job_expiration_days: u32, } diff --git a/upub/core/src/model/job.rs b/upub/core/src/model/job.rs index ac54d9bf..afcf15ca 100644 --- a/upub/core/src/model/job.rs +++ b/upub/core/src/model/job.rs @@ -42,10 +42,6 @@ impl Model { } } - pub fn expired(&self) -> bool { - chrono::Utc::now() - self.published > chrono::Duration::days(7) - } - pub fn repeat(self) -> ActiveModel { ActiveModel { internal: sea_orm::ActiveValue::NotSet, diff --git a/upub/core/src/traits/process.rs b/upub/core/src/traits/process.rs index 517d2ad7..9ccfd800 100644 --- a/upub/core/src/traits/process.rs +++ b/upub/core/src/traits/process.rs @@ -1,5 +1,5 @@ use apb::{target::Addressed, Activity, Base, Object}; -use sea_orm::{sea_query::Expr, ActiveValue::{NotSet, Set}, ColumnTrait, Condition, DatabaseTransaction, EntityTrait, QueryFilter, QuerySelect, SelectColumns, TransactionTrait}; +use sea_orm::{sea_query::Expr, ActiveValue::{NotSet, Set}, ColumnTrait, Condition, DatabaseTransaction, EntityTrait, QueryFilter, QuerySelect, SelectColumns}; use crate::{ext::{AnyQuery, LoggableError}, model, traits::{fetch::Pull, Addresser, Fetcher, Normalizer}}; #[derive(Debug, thiserror::Error)] diff --git a/upub/worker/src/dispatcher.rs b/upub/worker/src/dispatcher.rs index 23282e21..16d020fe 100644 --- a/upub/worker/src/dispatcher.rs +++ b/upub/worker/src/dispatcher.rs @@ -99,7 +99,7 @@ impl JobDispatcher for Context { }, } - if job.expired() { + if chrono::Utc::now() > job.published + chrono::Duration::days(self.cfg().security.job_expiration_days as i64) { tracing::info!("dropping expired job {job:?}"); restart!(now); }