configs/
local_notifications.rs

1use i18n::I18nString;
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4use tsify_next::Tsify;
5
6use crate::validated_types::NonZeroU64;
7
8/// Title and body the OS renders for one local notification. Both are
9/// translated server-side before the config reaches the client — the Unity
10/// client has no runtime translation and reads the value verbatim.
11#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, Tsify)]
12pub struct LocalNotificationText {
13    #[schemars(title = "Заголовок уведомления")]
14    pub title: I18nString,
15
16    #[schemars(title = "Текст уведомления")]
17    pub body: I18nString,
18}
19
20/// One rung of the win-back ladder. The whole ladder is scheduled when the
21/// player leaves and cancelled wholesale when the game is opened again.
22#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, Tsify)]
23pub struct WinBackNotification {
24    /// Minutes rather than hours so a tester can set a two-minute rung and
25    /// verify delivery on a device without waiting a day.
26    #[schemars(title = "Через сколько минут после выхода из игры показать")]
27    pub delay_minutes: NonZeroU64,
28
29    #[schemars(title = "Текст")]
30    pub text: LocalNotificationText,
31}
32
33#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, Tsify)]
34pub struct LocalNotificationsSettings {
35    #[schemars(
36        title = "Уведомления включены",
37        description = "Общий выключатель. При false клиент не планирует ни одного уведомления."
38    )]
39    pub enabled: bool,
40
41    #[schemars(
42        title = "Лестница возвращающих уведомлений",
43        description = "Планируется целиком при выходе из игры, снимается при следующем запуске."
44    )]
45    pub win_back: Vec<WinBackNotification>,
46
47    #[schemars(title = "АФК-награды накопились полностью")]
48    pub afk_rewards_capped: LocalNotificationText,
49
50    #[schemars(title = "Улучшение сундука предметов завершено")]
51    pub item_case_upgrade_finished: LocalNotificationText,
52
53    #[schemars(title = "Улучшение таланта завершено")]
54    pub talent_upgrade_finished: LocalNotificationText,
55
56    /// The day boundary is UTC midnight — see `AdUsageData::should_reset`,
57    /// which compares dates, not elapsed time.
58    #[schemars(title = "Наступил ежедневный сброс")]
59    pub daily_reset: LocalNotificationText,
60
61    #[schemars(title = "Бустер скоро закончится")]
62    pub boost_expiring: LocalNotificationText,
63
64    /// Only the soonest-expiring buff is announced; warning about each one
65    /// separately would stack several notifications on a player who bought a
66    /// bundle of boosts.
67    #[schemars(title = "За сколько минут до конца бустера предупредить")]
68    pub boost_expiring_lead_minutes: NonZeroU64,
69
70    /// Local hour on the device, not server time. A notification landing inside
71    /// the window is pushed forward to `quiet_hours_end`.
72    #[schemars(title = "Начало тихих часов (час местного времени устройства, 0-23)")]
73    pub quiet_hours_start: u8,
74
75    #[schemars(title = "Конец тихих часов (час местного времени устройства, 0-23)")]
76    pub quiet_hours_end: u8,
77}