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
28// Define some global TTLs.
29//
30// [RFC8030 notes](https://datatracker.ietf.org/doc/html/rfc8030#section-5.2) that
31// technically these are u32 values, but we should be kind and use u64. The RFC also
32// does not define a maximum TTL duration. Traditionally, Autopush has capped this
33// to 60 days, partly because we used to require monthly message table rotation.
34// (The TTL was given an extra 30 days grace in order to handle dates near the
35// turn of the month, when we might need to look in two tables for the data.)
36// Since we now have automatically applied garbage collection, we are at a bit of
37// liberty about how long these should be.
38//
39// That gets back to the concept that Push messages are supposed to be "timely".
40// A user may not appreciate that they have an undelivered calendar reminder from
41// 58 days ago, nor should they be interested in a meeting alert that happened last
42// month. When a User Agent (UA) connects, it receives all pending messages. If
43// a user has not used the User Agent in more than
44// [60 days](https://searchfox.org/mozilla-central/search?q=OFFER_PROFILE_RESET_INTERVAL_MS),
45// the User Agent suggest "refreshing Firefox", which essentially throws away one's
46// current profile. This would include all subscriptions a user may have had.
47//
48// To that end, messages left unread for more than 30 days should be considered
49// "abandoned" and any router info assigned to a User Agent that has not contacted
50// Autopush in 60 days can be discarded.
51
52/// The maximum TTL for notifications (30 days).
53/// In most use cases, converted to seconds through .num_seconds().
54pub const MAX_NOTIFICATION_TTL_SECS: u64 = 30 * 86400;
55
56/// FCM has a max TTL of 4 weeks (28 days).
57/// In most use cases, converted to seconds through .num_seconds().
58pub const MAX_FCM_NOTIFICATION_TTL_SECS: u64 = 28 * 86400;
59
60/// The maximum TTL for router records (60 days).
61/// In most use cases, converted to seconds through .num_seconds().
62pub const MAX_ROUTER_TTL_SECS: u64 = 60 * 86400;