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