autopush_common/
lib.rs

1#![recursion_limit = "1024"]
2
3#[macro_use]
4extern crate slog;
5#[macro_use]
6extern crate slog_scope;
7
8#[macro_use]
9pub mod db;
10pub mod endpoint;
11pub mod errors;
12pub mod logging;
13pub mod metric_name;
14pub mod metrics;
15pub mod middleware;
16pub mod notification;
17#[cfg(feature = "reliable_report")]
18pub mod redis_util;
19#[cfg(feature = "reliable_report")]
20pub mod reliability;
21pub mod sentry;
22pub mod tags;
23pub mod test_support;
24
25#[macro_use]
26pub mod util;
27
28use chrono::TimeDelta;
29
30// Define some global TTLs.
31//
32// [RFC8030 notes](https://datatracker.ietf.org/doc/html/rfc8030#section-5.2) that
33// technically these are u32 values, but we should be kind and use u64. The RFC also
34// does not define a maximum TTL duration. Traditionally, Autopush has capped this
35// to 60 days, partly because we used to require monthly message table rotation.
36// (The TTL was given an extra 30 days grace in order to handle dates near the
37// turn of the month, when we might need to look in two tables for the data.)
38// Since we now have automatically applied garbage collection, we are at a bit of
39// liberty about how long these should be.
40//
41// That gets back to the concept that Push messages are supposed to be "timely".
42// A user may not appreciate that they have an undelivered calendar reminder from
43// 58 days ago, nor should they be interested in a meeting alert that happened last
44// month. When a User Agent (UA) connects, it receives all pending messages. If
45// a user has not used the User Agent in more than
46// [60 days](https://searchfox.org/mozilla-central/search?q=OFFER_PROFILE_RESET_INTERVAL_MS),
47// the User Agent suggest "refreshing Firefox", which essentially throws away one's
48// current profile. This would include all subscriptions a user may have had.
49//
50// To that end, messages left unread for more than 30 days should be considered
51// "abandoned" and any router info assigned to a User Agent that has not contacted
52// Autopush in 60 days can be discarded.
53
54/// The maximum TTL for notifications (30 days).
55/// In most use cases, converted to seconds through .num_seconds().
56pub const MAX_NOTIFICATION_TTL: TimeDelta = TimeDelta::days(30);
57
58/// FCM has a max TTL of 4 weeks (28 days).
59/// In most use cases, converted to seconds through .num_seconds().
60pub const MAX_FCM_NOTIFICATION_TTL: TimeDelta = TimeDelta::days(28);
61
62/// The maximum TTL for router records (60 days).
63/// In most use cases, converted to seconds through .num_seconds().
64pub const MAX_ROUTER_TTL: TimeDelta = TimeDelta::days(60);