BlueGit

ict rusty-teams

Files

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

notices.rs

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