BlueGit

ict rusty-teams

Files

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

notices.rs

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