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