BlueGit

ict rusty-teams

Files

rusty-teams / crates / calling / src / notices.rs

notices.rs

notices.rs 6.3 KiB Download Raw
1//! Call notice payloads: i18n keys (and optional detail after [`NOTICE_DETAIL_SEP`]).
2pub const NOTICE_DETAIL_SEP: char = '\u{1f}';
3
4pub const CONSENT_FIRST_NOTICE: &str = "calls.notice.consent_first";
5pub const ON_HOLD_NOTICE: &str = "calls.notice.on_hold";
6pub const CHANGE_RUNNING_NOTICE: &str = "calls.notice.change_running";
7pub const VIDEO_FAILED_NOTICE: &str = "calls.notice.video_failed";
8pub const SHARE_QUEUED_NOTICE: &str = "calls.notice.share_queued";
9pub const SHARE_REFUSED_NOTICE: &str = "calls.notice.share_refused";
10pub const NOT_CONNECTED_FOR_VIDEO: &str = "calls.notice.video_starts_once_connected";
11pub const PORTAL_UNAVAILABLE_NOTICE: &str = "calls.notice.portal_unavailable";
12pub const CALL_TRANSFERRED_NOTICE: &str = "calls.notice.call_transferred";
13pub const TRANSFER_FAILED_NOTICE: &str = "calls.notice.transfer_failed";
14pub const RECORDING_JOIN_FAILED_NOTICE: &str = "calls.notice.recording_join_failed";
15pub const CAPTIONS_JOIN_FAILED_NOTICE: &str = "calls.notice.captions_join_failed";
16pub const CAPTION_LANGUAGE_FAILED_NOTICE: &str = "calls.notice.caption_language_failed";
17pub const CAMERA_START_NOTICE: &str = "calls.notice.camera_start";
18pub const CAMERA_RESTART_NOTICE: &str = "calls.notice.camera_restart";
19pub const SHARING_START_NOTICE: &str = "calls.notice.sharing_start";
20pub const RAISE_HAND_FAILED_NOTICE: &str = "calls.notice.raise_hand_failed";
21pub const LOWER_HAND_FAILED_NOTICE: &str = "calls.notice.lower_hand_failed";
22pub const LOWER_THAT_HAND_FAILED_NOTICE: &str = "calls.notice.lower_that_hand_failed";
23pub const LOWER_ALL_HANDS_FAILED_NOTICE: &str = "calls.notice.lower_all_hands_failed";
24pub const CONFIRM_RECORDING_FAILED_NOTICE: &str = "calls.notice.confirm_recording_failed";
25pub const HOLD_FAILED_NOTICE: &str = "calls.notice.hold_failed";
26pub const RESUME_FAILED_NOTICE: &str = "calls.notice.resume_failed";
27pub const TRANSFER_NOT_ALLOWED_NOTICE: &str = "calls.notice.transfer_not_allowed";
28pub const TRANSFER_CALL_FAILED_NOTICE: &str = "calls.notice.transfer_call_failed";
29pub const TRANSFERRING_NOTICE: &str = "calls.notice.transferring";
30pub const WHITEBOARDS_MEETINGS_ONLY_NOTICE: &str = "calls.notice.whiteboards_meetings_only";
31pub const WHITEBOARD_OPEN_FAILED_NOTICE: &str = "calls.notice.whiteboard_open_failed";
32pub const REACTION_FAILED_NOTICE: &str = "calls.notice.reaction_failed";
33pub const RECORDING_NOT_STARTED_NOTICE: &str = "calls.notice.recording_not_started";
34pub const RECORDING_START_FAILED_NOTICE: &str = "calls.notice.recording_start_failed";
35pub const CAPTIONS_START_FAILED_NOTICE: &str = "calls.notice.captions_start_failed";
36pub const HOLD_CHANGE_FAILED_NOTICE: &str = "calls.notice.hold_change_failed";
37pub const RECORDING_STOP_FAILED_NOTICE: &str = "calls.notice.recording_stop_failed";
38pub const BACKGROUND_IMAGE_FAILED_NOTICE: &str = "calls.notice.background_image_failed";
39pub const CAMERA_STOPPED_NOTICE: &str = "calls.notice.camera_stopped";
40pub const SCREEN_SHARE_STOPPED_NOTICE: &str = "calls.notice.screen_share_stopped";
41pub const ADMIT_FAILED_NOTICE: &str = "calls.notice.admit_failed";
42pub const ADMIT_ALL_FAILED_NOTICE: &str = "calls.notice.admit_all_failed";
43pub const DENY_FAILED_NOTICE: &str = "calls.notice.deny_failed";
44pub const REMOVE_PARTICIPANT_FAILED_NOTICE: &str = "calls.notice.remove_participant_failed";
45pub const MUTE_PARTICIPANT_FAILED_NOTICE: &str = "calls.notice.mute_participant_failed";
46pub const MUTE_ALL_FAILED_NOTICE: &str = "calls.notice.mute_all_failed";
47pub const MEETING_LOCK_FAILED_NOTICE: &str = "calls.notice.meeting_lock_failed";
48pub const CHANGE_ROLE_FAILED_NOTICE: &str = "calls.notice.change_role_failed";
49pub const MIC_SETTING_FAILED_NOTICE: &str = "calls.notice.mic_setting_failed";
50pub const CAMERA_SETTING_FAILED_NOTICE: &str = "calls.notice.camera_setting_failed";
51pub const ATTENDEE_SETTINGS_FAILED_NOTICE: &str = "calls.notice.attendee_settings_failed";
52pub const INVITE_PERSON_FAILED_NOTICE: &str = "calls.notice.invite_person_failed";
53pub const SPOTLIGHT_FAILED_NOTICE: &str = "calls.notice.spotlight_failed";
54pub const STOP_SPOTLIGHT_FAILED_NOTICE: &str = "calls.notice.stop_spotlight_failed";
55
56pub fn notice_with_detail(key: &'static str, detail: impl std::fmt::Display) -> String {
57 format!("{key}{NOTICE_DETAIL_SEP}{detail}")
58}
59
60#[cfg(test)]
61mod tests {
62 use super::*;
63
64 #[test]
65 fn notice_id_fixed_keys_match_catalog_paths() {
66 assert_eq!(CONSENT_FIRST_NOTICE, "calls.notice.consent_first");
67 assert_eq!(ON_HOLD_NOTICE, "calls.notice.on_hold");
68 assert_eq!(CHANGE_RUNNING_NOTICE, "calls.notice.change_running");
69 assert_eq!(VIDEO_FAILED_NOTICE, "calls.notice.video_failed");
70 assert_eq!(SHARE_QUEUED_NOTICE, "calls.notice.share_queued");
71 assert_eq!(SHARE_REFUSED_NOTICE, "calls.notice.share_refused");
72 assert_eq!(
73 NOT_CONNECTED_FOR_VIDEO,
74 "calls.notice.video_starts_once_connected"
75 );
76 assert_eq!(PORTAL_UNAVAILABLE_NOTICE, "calls.notice.portal_unavailable");
77 assert_eq!(CALL_TRANSFERRED_NOTICE, "calls.notice.call_transferred");
78 assert_eq!(TRANSFER_FAILED_NOTICE, "calls.notice.transfer_failed");
79 assert_eq!(
80 RECORDING_JOIN_FAILED_NOTICE,
81 "calls.notice.recording_join_failed"
82 );
83 assert_eq!(
84 CAPTIONS_JOIN_FAILED_NOTICE,
85 "calls.notice.captions_join_failed"
86 );
87 assert_eq!(
88 CAPTION_LANGUAGE_FAILED_NOTICE,
89 "calls.notice.caption_language_failed"
90 );
91 assert_eq!(CAMERA_START_NOTICE, "calls.notice.camera_start");
92 assert_eq!(CAMERA_RESTART_NOTICE, "calls.notice.camera_restart");
93 assert_eq!(SHARING_START_NOTICE, "calls.notice.sharing_start");
94 assert_eq!(RAISE_HAND_FAILED_NOTICE, "calls.notice.raise_hand_failed");
95 assert_eq!(TRANSFERRING_NOTICE, "calls.notice.transferring");
96 assert_eq!(ADMIT_FAILED_NOTICE, "calls.notice.admit_failed");
97 assert_eq!(
98 BACKGROUND_IMAGE_FAILED_NOTICE,
99 "calls.notice.background_image_failed"
100 );
101 }
102
103 #[test]
104 fn notice_id_camera_payload_uses_key_and_detail_sep() {
105 let payload = notice_with_detail(CAMERA_START_NOTICE, "device busy");
106 assert!(payload.starts_with("calls.notice.camera_start"));
107 assert!(payload.contains(NOTICE_DETAIL_SEP));
108 assert!(payload.ends_with("device busy"));
109 }
110}