| 1 | use chrono::{DateTime, Duration, Utc}; |
| 2 | use store::MessageRecord; |
| 3 | use teams_core::{CallEvent, CallPhase, CallType, Recording}; |
| 4 | |
| 5 | use crate::demo::{DEMO_USER_ID, JONAS_ID, LEA_ID, MARA_ID, PRIYA_ID, TOBIAS_ID, at}; |
| 6 | use crate::demo_recap::DEMO_RECAP_CHAT; |
| 7 | |
| 8 | const CHANNEL: &str = "demo-channel-1-1"; |
| 9 | const CHANNEL_CALL: &str = "demo-channel-meeting"; |
| 10 | const CHANNEL_ROOT: &str = "meet-1"; |
| 11 | const STANDUP_CALL: &str = "demo-standup-recorded"; |
| 12 | const DEMO_RECORDING_URL: &str = "https://demo.sharepoint.example/personal/demo/Recordings"; |
| 13 | |
| 14 | fn event(phase: CallPhase, call_id: &str, initiator: &str, seconds: Option<u64>) -> CallEvent { |
| 15 | CallEvent { |
| 16 | phase, |
| 17 | call_type: CallType::Meeting, |
| 18 | call_id: call_id.to_owned(), |
| 19 | duration_seconds: seconds, |
| 20 | initiator_id: Some(initiator.to_owned()), |
| 21 | initiator_name: None, |
| 22 | participant_ids: Vec::new(), |
| 23 | participant_names: Vec::new(), |
| 24 | recording: None, |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | fn recording(mut event: CallEvent, name: &str, url: Option<&str>, organizer: &str) -> CallEvent { |
| 29 | event.recording = Some(Recording { |
| 30 | name: Some(name.to_owned()), |
| 31 | url: url.map(str::to_owned), |
| 32 | organizer_id: Some(organizer.to_owned()), |
| 33 | }); |
| 34 | event |
| 35 | } |
| 36 | |
| 37 | fn ended(call_id: &str, initiator: &str, seconds: u64, people: &[(&str, &str)]) -> CallEvent { |
| 38 | CallEvent { |
| 39 | participant_ids: people.iter().map(|(id, _)| (*id).to_owned()).collect(), |
| 40 | participant_names: people.iter().map(|(_, name)| (*name).to_owned()).collect(), |
| 41 | ..event(CallPhase::Ended, call_id, initiator, Some(seconds)) |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | fn record( |
| 46 | conversation: &str, |
| 47 | id: &str, |
| 48 | reply_to: Option<&str>, |
| 49 | time: DateTime<Utc>, |
| 50 | event: CallEvent, |
| 51 | ) -> MessageRecord { |
| 52 | MessageRecord { |
| 53 | conversation_id: conversation.to_owned(), |
| 54 | message_id: id.to_owned(), |
| 55 | reply_to_id: reply_to.map(str::to_owned), |
| 56 | created_at: time, |
| 57 | links_json: "[]".to_owned(), |
| 58 | attachments_json: "[]".to_owned(), |
| 59 | reactions_json: "[]".to_owned(), |
| 60 | mentions_json: "[]".to_owned(), |
| 61 | call_event_json: Some(event.to_json()), |
| 62 | ..MessageRecord::default() |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | fn reply(id: &str, sender: (&str, &str), time: DateTime<Utc>, html: &str) -> MessageRecord { |
| 67 | MessageRecord { |
| 68 | conversation_id: CHANNEL.to_owned(), |
| 69 | message_id: id.to_owned(), |
| 70 | reply_to_id: Some(CHANNEL_ROOT.to_owned()), |
| 71 | sender_id: Some(sender.0.to_owned()), |
| 72 | sender_name: Some(sender.1.to_owned()), |
| 73 | created_at: time, |
| 74 | body_html: html.to_owned(), |
| 75 | links_json: "[]".to_owned(), |
| 76 | attachments_json: "[]".to_owned(), |
| 77 | reactions_json: "[]".to_owned(), |
| 78 | mentions_json: "[]".to_owned(), |
| 79 | ..MessageRecord::default() |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | fn channel_meeting() -> Vec<MessageRecord> { |
| 84 | let start = at(0, 10, 30); |
| 85 | let minutes = |count: i64| start + Duration::minutes(count); |
| 86 | let name = "Design review-20261017_103200-Meeting Recording.mp4"; |
| 87 | let url = format!("{DEMO_RECORDING_URL}/design-review.mp4"); |
| 88 | let people = [ |
| 89 | (MARA_ID, "Mara Lindqvist"), |
| 90 | (JONAS_ID, "Jonas Ortega"), |
| 91 | (PRIYA_ID, "Priya Nair"), |
| 92 | (DEMO_USER_ID, "Dana Demo"), |
| 93 | (TOBIAS_ID, "Tobias Klein"), |
| 94 | (LEA_ID, "Lea Schneider"), |
| 95 | ]; |
| 96 | let thread = |id: &str, offset: i64, event: CallEvent| { |
| 97 | record(CHANNEL, id, Some(CHANNEL_ROOT), minutes(offset), event) |
| 98 | }; |
| 99 | vec![ |
| 100 | record( |
| 101 | CHANNEL, |
| 102 | CHANNEL_ROOT, |
| 103 | None, |
| 104 | start, |
| 105 | event(CallPhase::Started, CHANNEL_CALL, MARA_ID, None), |
| 106 | ), |
| 107 | thread( |
| 108 | "meet-1-rec", |
| 109 | 2, |
| 110 | recording( |
| 111 | event(CallPhase::RecordingStarted, CHANNEL_CALL, MARA_ID, Some(0)), |
| 112 | name, |
| 113 | None, |
| 114 | MARA_ID, |
| 115 | ), |
| 116 | ), |
| 117 | thread( |
| 118 | "meet-1-transcript", |
| 119 | 2, |
| 120 | event(CallPhase::TranscriptStarted, CHANNEL_CALL, MARA_ID, None), |
| 121 | ), |
| 122 | thread( |
| 123 | "meet-1-stop", |
| 124 | 34, |
| 125 | recording( |
| 126 | event( |
| 127 | CallPhase::RecordingStopped, |
| 128 | CHANNEL_CALL, |
| 129 | MARA_ID, |
| 130 | Some(1914), |
| 131 | ), |
| 132 | name, |
| 133 | None, |
| 134 | MARA_ID, |
| 135 | ), |
| 136 | ), |
| 137 | thread( |
| 138 | "meet-1-end", |
| 139 | 35, |
| 140 | ended(CHANNEL_CALL, MARA_ID, 2100, &people), |
| 141 | ), |
| 142 | thread( |
| 143 | "meet-1-saved", |
| 144 | 36, |
| 145 | recording( |
| 146 | event(CallPhase::RecordingSaved, CHANNEL_CALL, MARA_ID, Some(1914)), |
| 147 | name, |
| 148 | Some(&url), |
| 149 | MARA_ID, |
| 150 | ), |
| 151 | ), |
| 152 | reply( |
| 153 | "meet-1-r1", |
| 154 | (JONAS_ID, "Jonas Ortega"), |
| 155 | minutes(41), |
| 156 | "<p>Thanks, the recording covers the open questions for Priya.</p>", |
| 157 | ), |
| 158 | ] |
| 159 | } |
| 160 | |
| 161 | fn standup_line(id: &str, time: DateTime<Utc>, event: CallEvent) -> MessageRecord { |
| 162 | record(DEMO_RECAP_CHAT, id, None, time, event) |
| 163 | } |
| 164 | |
| 165 | fn recorded_standup() -> Vec<MessageRecord> { |
| 166 | let start = at(2, 11, 45); |
| 167 | let minutes = |count: i64| start + Duration::minutes(count); |
| 168 | let name = "Daily standup-20261015_114602-Meeting Recording.mp4"; |
| 169 | let url = format!("{DEMO_RECORDING_URL}/standup-1.mp4"); |
| 170 | let people = [ |
| 171 | (JONAS_ID, "Jonas Ortega"), |
| 172 | (DEMO_USER_ID, "Dana Demo"), |
| 173 | (MARA_ID, "Mara Lindqvist"), |
| 174 | ]; |
| 175 | let saved_recording = |phase: CallPhase, seconds: Option<u64>, url: Option<&str>| { |
| 176 | recording( |
| 177 | event(phase, STANDUP_CALL, DEMO_USER_ID, seconds), |
| 178 | name, |
| 179 | url, |
| 180 | MARA_ID, |
| 181 | ) |
| 182 | }; |
| 183 | vec![ |
| 184 | standup_line( |
| 185 | "standup-1-start", |
| 186 | start, |
| 187 | event(CallPhase::Started, STANDUP_CALL, JONAS_ID, None), |
| 188 | ), |
| 189 | standup_line( |
| 190 | "standup-1-rec", |
| 191 | minutes(1), |
| 192 | saved_recording(CallPhase::RecordingStarted, Some(0), None), |
| 193 | ), |
| 194 | standup_line( |
| 195 | "standup-1-transcript", |
| 196 | minutes(1), |
| 197 | event( |
| 198 | CallPhase::TranscriptStarted, |
| 199 | STANDUP_CALL, |
| 200 | DEMO_USER_ID, |
| 201 | None, |
| 202 | ), |
| 203 | ), |
| 204 | standup_line( |
| 205 | "standup-1-stop", |
| 206 | minutes(10), |
| 207 | saved_recording(CallPhase::RecordingStopped, Some(531), None), |
| 208 | ), |
| 209 | standup_line( |
| 210 | "standup-1-end", |
| 211 | minutes(10) + Duration::seconds(40), |
| 212 | ended(STANDUP_CALL, JONAS_ID, 586, &people), |
| 213 | ), |
| 214 | standup_line( |
| 215 | "demo-recap-0", |
| 216 | minutes(10) + Duration::seconds(55), |
| 217 | saved_recording(CallPhase::RecordingSaved, Some(531), Some(&url)), |
| 218 | ), |
| 219 | ] |
| 220 | } |
| 221 | |
| 222 | pub fn meeting_messages() -> Vec<MessageRecord> { |
| 223 | channel_meeting() |
| 224 | .into_iter() |
| 225 | .chain(recorded_standup()) |
| 226 | .collect() |
| 227 | } |