]> Untitled Git - lemmy.git/blob - crates/apub/src/fetcher/mod.rs
Remove ActivityFields trait, deserialize into another struct instead
[lemmy.git] / crates / apub / src / fetcher / mod.rs
1 pub mod object_id;
2 pub mod post_or_comment;
3 pub mod search;
4 pub mod user_or_community;
5
6 use chrono::NaiveDateTime;
7 use lemmy_db_schema::naive_now;
8
9 static ACTOR_REFETCH_INTERVAL_SECONDS: i64 = 24 * 60 * 60;
10 static ACTOR_REFETCH_INTERVAL_SECONDS_DEBUG: i64 = 10;
11
12 /// Determines when a remote actor should be refetched from its instance. In release builds, this is
13 /// `ACTOR_REFETCH_INTERVAL_SECONDS` after the last refetch, in debug builds
14 /// `ACTOR_REFETCH_INTERVAL_SECONDS_DEBUG`.
15 ///
16 /// TODO it won't pick up new avatars, summaries etc until a day after.
17 /// Actors need an "update" activity pushed to other servers to fix this.
18 fn should_refetch_object(last_refreshed: NaiveDateTime) -> bool {
19   let update_interval = if cfg!(debug_assertions) {
20     // avoid infinite loop when fetching community outbox
21     chrono::Duration::seconds(ACTOR_REFETCH_INTERVAL_SECONDS_DEBUG)
22   } else {
23     chrono::Duration::seconds(ACTOR_REFETCH_INTERVAL_SECONDS)
24   };
25   last_refreshed.lt(&(naive_now() - update_interval))
26 }