BlueGit

ict rusty-teams

Merge branch 'fix/roster-join-running' into integrate/calls-10

metis Daniel Däschle · pushed by metis

Authored 2026-10-14 · 6 weeks ago

Hash
af5aab51b32d810857485e556777e878f23e43ce
5 files changed +339 −25
crates/calling/examples/live_matrix.rs +31 −14
@@ -26,16 +26,18 @@ struct Arguments {
26 26 link_out: Option<PathBuf>,
27 27 thread_out: Option<PathBuf>,
28 28 recap_thread: Option<String>,
29 join_thread: Option<PathBuf>,
29 30 }
30 31
31 32 fn arguments() -> Arguments {
32 let mut parsed = Arguments { link_out: None, thread_out: None, recap_thread: None };
33 let mut parsed = Arguments { link_out: None, thread_out: None, recap_thread: None, join_thread: None };
33 34 let mut input = std::env::args().skip(1);
34 35 while let Some(flag) = input.next() {
35 36 match flag.as_str() {
36 37 "--link-out" => parsed.link_out = input.next().map(PathBuf::from),
37 38 "--thread-out" => parsed.thread_out = input.next().map(PathBuf::from),
38 39 "--recap" => parsed.recap_thread = input.next(),
40 "--join-thread" => parsed.join_thread = input.next().map(PathBuf::from),
39 41 _ => {}
40 42 }
41 43 }
@@ -364,13 +366,20 @@ async fn run() {
364 366 let me = fetch_self(&session).await.expect("own identity");
365 367 let started = Instant::now();
366 368
367 let body = json!({"meetingType": "MeetNow", "isStreamEnabled": false, "subject": SUBJECT, "unhideChatThread": true});
368 let created = session
369 .request(Method::Post, CREATE_URL, &Scope::new(SPACES, "user_impersonation"), Some(body))
370 .await
371 .expect("create meeting");
372 let thread_id = created.body.pointer("/value/groupContext/threadId").and_then(Value::as_str).expect("meeting thread").to_owned();
373 emit(json!({"event": "created", "status": created.status}));
369 let late_joiner = arguments.join_thread.is_some();
370 let (thread_id, created_body) = match &arguments.join_thread {
371 Some(path) => (std::fs::read_to_string(path).expect("thread file").trim().to_owned(), Value::Null),
372 None => {
373 let body = json!({"meetingType": "MeetNow", "isStreamEnabled": false, "subject": SUBJECT, "unhideChatThread": true});
374 let created = session
375 .request(Method::Post, CREATE_URL, &Scope::new(SPACES, "user_impersonation"), Some(body))
376 .await
377 .expect("create meeting");
378 let thread_id = created.body.pointer("/value/groupContext/threadId").and_then(Value::as_str).expect("meeting thread").to_owned();
379 emit(json!({"event": "created", "status": created.status}));
380 (thread_id, created.body)
381 }
382 };
374 383 if let Some(path) = &arguments.thread_out {
375 384 std::fs::write(path, &thread_id).expect("thread file");
376 385 }
@@ -389,7 +398,7 @@ async fn run() {
389 398 organizer_id: organizer_id.unwrap_or_else(|| me.object_id.clone()),
390 399 meeting_data: None,
391 400 };
392 let join_link = find_text(&created.body, &["joinUrl", "meetingJoinUrl", "joinWebUrl"]).map_or_else(
401 let join_link = find_text(&created_body, &["joinUrl", "meetingJoinUrl", "joinWebUrl"]).map_or_else(
393 402 || {
394 403 let context = json!({"Tid": target.tenant_id, "Oid": target.organizer_id}).to_string();
395 404 format!("https://teams.microsoft.com/l/meetup-join/{}/0?context={}", encoded(&thread_id), encoded(&context))
@@ -402,10 +411,18 @@ async fn run() {
402 411 let config = EngineConfig {
403 412 ringable: false,
404 413 trace: std::env::var_os("LIVE_TRACE").is_some(),
405 instance: InstanceNames {
406 global: "__liveMatrixTrouter".into(),
407 binding: "__liveMatrixRealtime".into(),
408 endpoint_storage_key: "__liveMatrixEpid".into(),
414 instance: if late_joiner {
415 InstanceNames {
416 global: "__lateJoinerTrouter".into(),
417 binding: "__lateJoinerRealtime".into(),
418 endpoint_storage_key: "__lateJoinerEpid".into(),
419 }
420 } else {
421 InstanceNames {
422 global: "__liveMatrixTrouter".into(),
423 binding: "__liveMatrixRealtime".into(),
424 endpoint_storage_key: "__liveMatrixEpid".into(),
425 }
409 426 },
410 427 ..EngineConfig::default()
411 428 };
@@ -538,7 +555,7 @@ async fn run() {
538 555 emit(json!({"event": "ended", "reason": ended}));
539 556 let gone_started = Instant::now();
540 557 let mut gone = false;
541 while gone_started.elapsed() < GONE_LIMIT {
558 while !late_joiner && gone_started.elapsed() < GONE_LIMIT {
542 559 if matches!(fetch_live_meeting(&session, &thread_id).await, Ok(None)) {
543 560 gone = true;
544 561 break;
@@ -26,16 +26,18 @@ struct Arguments {
26 link_out: Option<PathBuf>,
26 link_out: Option<PathBuf>,
27 thread_out: Option<PathBuf>,
27 thread_out: Option<PathBuf>,
28 recap_thread: Option<String>,
28 recap_thread: Option<String>,
29 join_thread: Option<PathBuf>,
29}
30}
30
31
31fn arguments() -> Arguments {
32fn arguments() -> Arguments {
32 let mut parsed = Arguments { link_out: None, thread_out: None, recap_thread: None };
33 let mut parsed = Arguments { link_out: None, thread_out: None, recap_thread: None, join_thread: None };
33 let mut input = std::env::args().skip(1);
34 let mut input = std::env::args().skip(1);
34 while let Some(flag) = input.next() {
35 while let Some(flag) = input.next() {
35 match flag.as_str() {
36 match flag.as_str() {
36 "--link-out" => parsed.link_out = input.next().map(PathBuf::from),
37 "--link-out" => parsed.link_out = input.next().map(PathBuf::from),
37 "--thread-out" => parsed.thread_out = input.next().map(PathBuf::from),
38 "--thread-out" => parsed.thread_out = input.next().map(PathBuf::from),
38 "--recap" => parsed.recap_thread = input.next(),
39 "--recap" => parsed.recap_thread = input.next(),
40 "--join-thread" => parsed.join_thread = input.next().map(PathBuf::from),
39 _ => {}
41 _ => {}
40 }
42 }
41 }
43 }
@@ -364,13 +366,20 @@ async fn run() {
364 let me = fetch_self(&session).await.expect("own identity");
366 let me = fetch_self(&session).await.expect("own identity");
365 let started = Instant::now();
367 let started = Instant::now();
366
368
367 let body = json!({"meetingType": "MeetNow", "isStreamEnabled": false, "subject": SUBJECT, "unhideChatThread": true});
369 let late_joiner = arguments.join_thread.is_some();
368 let created = session
370 let (thread_id, created_body) = match &arguments.join_thread {
369 .request(Method::Post, CREATE_URL, &Scope::new(SPACES, "user_impersonation"), Some(body))
371 Some(path) => (std::fs::read_to_string(path).expect("thread file").trim().to_owned(), Value::Null),
370 .await
372 None => {
371 .expect("create meeting");
373 let body = json!({"meetingType": "MeetNow", "isStreamEnabled": false, "subject": SUBJECT, "unhideChatThread": true});
372 let thread_id = created.body.pointer("/value/groupContext/threadId").and_then(Value::as_str).expect("meeting thread").to_owned();
374 let created = session
373 emit(json!({"event": "created", "status": created.status}));
375 .request(Method::Post, CREATE_URL, &Scope::new(SPACES, "user_impersonation"), Some(body))
376 .await
377 .expect("create meeting");
378 let thread_id = created.body.pointer("/value/groupContext/threadId").and_then(Value::as_str).expect("meeting thread").to_owned();
379 emit(json!({"event": "created", "status": created.status}));
380 (thread_id, created.body)
381 }
382 };
374 if let Some(path) = &arguments.thread_out {
383 if let Some(path) = &arguments.thread_out {
375 std::fs::write(path, &thread_id).expect("thread file");
384 std::fs::write(path, &thread_id).expect("thread file");
376 }
385 }
@@ -389,7 +398,7 @@ async fn run() {
389 organizer_id: organizer_id.unwrap_or_else(|| me.object_id.clone()),
398 organizer_id: organizer_id.unwrap_or_else(|| me.object_id.clone()),
390 meeting_data: None,
399 meeting_data: None,
391 };
400 };
392 let join_link = find_text(&created.body, &["joinUrl", "meetingJoinUrl", "joinWebUrl"]).map_or_else(
401 let join_link = find_text(&created_body, &["joinUrl", "meetingJoinUrl", "joinWebUrl"]).map_or_else(
393 || {
402 || {
394 let context = json!({"Tid": target.tenant_id, "Oid": target.organizer_id}).to_string();
403 let context = json!({"Tid": target.tenant_id, "Oid": target.organizer_id}).to_string();
395 format!("https://teams.microsoft.com/l/meetup-join/{}/0?context={}", encoded(&thread_id), encoded(&context))
404 format!("https://teams.microsoft.com/l/meetup-join/{}/0?context={}", encoded(&thread_id), encoded(&context))
@@ -402,10 +411,18 @@ async fn run() {
402 let config = EngineConfig {
411 let config = EngineConfig {
403 ringable: false,
412 ringable: false,
404 trace: std::env::var_os("LIVE_TRACE").is_some(),
413 trace: std::env::var_os("LIVE_TRACE").is_some(),
405 instance: InstanceNames {
414 instance: if late_joiner {
406 global: "__liveMatrixTrouter".into(),
415 InstanceNames {
407 binding: "__liveMatrixRealtime".into(),
416 global: "__lateJoinerTrouter".into(),
408 endpoint_storage_key: "__liveMatrixEpid".into(),
417 binding: "__lateJoinerRealtime".into(),
418 endpoint_storage_key: "__lateJoinerEpid".into(),
419 }
420 } else {
421 InstanceNames {
422 global: "__liveMatrixTrouter".into(),
423 binding: "__liveMatrixRealtime".into(),
424 endpoint_storage_key: "__liveMatrixEpid".into(),
425 }
409 },
426 },
410 ..EngineConfig::default()
427 ..EngineConfig::default()
411 };
428 };
@@ -538,7 +555,7 @@ async fn run() {
538 emit(json!({"event": "ended", "reason": ended}));
555 emit(json!({"event": "ended", "reason": ended}));
539 let gone_started = Instant::now();
556 let gone_started = Instant::now();
540 let mut gone = false;
557 let mut gone = false;
541 while gone_started.elapsed() < GONE_LIMIT {
558 while !late_joiner && gone_started.elapsed() < GONE_LIMIT {
542 if matches!(fetch_live_meeting(&session, &thread_id).await, Ok(None)) {
559 if matches!(fetch_live_meeting(&session, &thread_id).await, Ok(None)) {
543 gone = true;
560 gone = true;
544 break;
561 break;
crates/calling/src/call.rs +7 −0
@@ -804,6 +804,13 @@ async fn drive(
804 804 let mut reconnect_deadline: Option<Instant> = None;
805 805 let mut next: Option<NextPeer> = None;
806 806 let mut roster = Roster::default();
807 if let Some(snapshot) = &conversation.roster
808 && roster.apply_snapshot(snapshot)
809 {
810 let entries = roster.entries();
811 timeline.record("roster", format!("{} participant(s) from the conversation answer", entries.len()));
812 control.send(CallUpdate::Roster(entries));
813 }
807 814 let mut lobby = false;
808 815 let mut capability = MeetingCapability::default();
809 816 let mut previous_packets = 0u64;
@@ -804,6 +804,13 @@ async fn drive(
804 let mut reconnect_deadline: Option<Instant> = None;
804 let mut reconnect_deadline: Option<Instant> = None;
805 let mut next: Option<NextPeer> = None;
805 let mut next: Option<NextPeer> = None;
806 let mut roster = Roster::default();
806 let mut roster = Roster::default();
807 if let Some(snapshot) = &conversation.roster
808 && roster.apply_snapshot(snapshot)
809 {
810 let entries = roster.entries();
811 timeline.record("roster", format!("{} participant(s) from the conversation answer", entries.len()));
812 control.send(CallUpdate::Roster(entries));
813 }
807 let mut lobby = false;
814 let mut lobby = false;
808 let mut capability = MeetingCapability::default();
815 let mut capability = MeetingCapability::default();
809 let mut previous_packets = 0u64;
816 let mut previous_packets = 0u64;
crates/calling/src/roster.rs +40 −0
@@ -159,6 +159,16 @@ impl Roster {
159 159 *self != before
160 160 }
161 161
162 /// A conversation answer lists everyone present; deltas only ever name who changed.
163 pub fn apply_snapshot(&mut self, snapshot: &Value) -> bool {
164 let before = self.clone();
165 self.apply(snapshot);
166 if let (Some(sequence), Some(listed)) = (snapshot["sequenceNumber"].as_u64(), snapshot["participants"].as_object()) {
167 self.members.retain(|member| listed.contains_key(&member.mri) || member.version > sequence);
168 }
169 *self != before
170 }
171
162 172 pub fn hand_of(&self, mri: &str) -> Option<&RaisedHand> {
163 173 self.members.iter().find(|member| member.mri == mri)?.hand.as_ref()
164 174 }
@@ -646,6 +656,36 @@ mod tests {
646 656 assert!(!roster.caption_bot().unwrap().audio_only);
647 657 }
648 658
659 const JOIN_ANSWER: &str = include_str!("../tests/fixtures/meeting_join_answer.json");
660
661 #[test]
662 fn a_late_joiner_sees_everyone_from_the_join_answer() {
663 let answer: Value = serde_json::from_str(JOIN_ANSWER).unwrap();
664 let mut roster = Roster::default();
665 assert!(roster.apply_snapshot(&answer["roster"]));
666 let mut names: Vec<String> = roster.entries().into_iter().map(|entry| entry.display_name).collect();
667 names.sort();
668 assert_eq!(names, ["Organizer", "Test Guest 1", "Test Guest 2", "Test Guest 3"]);
669 assert_eq!(roster.video_candidates("8:orgid:00000000-0000-0000-0000-00000000000a").len(), 3);
670 let own_delta = delta(json!({"8:orgid:00000000-0000-0000-0000-00000000000a": participant("Organizer", 10, "active", true, 840)}));
671 roster.apply(&own_delta);
672 assert_eq!(roster.members().len(), 4);
673 }
674
675 #[test]
676 fn a_snapshot_drops_people_it_no_longer_lists_unless_a_newer_delta_added_them() {
677 let mut roster = Roster::default();
678 roster.apply(&delta(json!({
679 "8:orgid:gone": participant("Gone", 3, "active", false, 201),
680 "8:orgid:new": participant("New", 12, "active", false, 301),
681 })));
682 let snapshot = json!({"type": "Delta", "sequenceNumber": 9, "participants": {"8:orgid:a": participant("Ana", 4, "active", false, 401)}});
683 assert!(roster.apply_snapshot(&snapshot));
684 let mut mris: Vec<&str> = roster.members().iter().map(|member| member.mri.as_str()).collect();
685 mris.sort();
686 assert_eq!(mris, ["8:orgid:a", "8:orgid:new"]);
687 }
688
649 689 #[test]
650 690 fn caption_speakers_resolve_by_mri_or_object_id() {
651 691 let mut roster = Roster::default();
@@ -159,6 +159,16 @@ impl Roster {
159 *self != before
159 *self != before
160 }
160 }
161
161
162 /// A conversation answer lists everyone present; deltas only ever name who changed.
163 pub fn apply_snapshot(&mut self, snapshot: &Value) -> bool {
164 let before = self.clone();
165 self.apply(snapshot);
166 if let (Some(sequence), Some(listed)) = (snapshot["sequenceNumber"].as_u64(), snapshot["participants"].as_object()) {
167 self.members.retain(|member| listed.contains_key(&member.mri) || member.version > sequence);
168 }
169 *self != before
170 }
171
162 pub fn hand_of(&self, mri: &str) -> Option<&RaisedHand> {
172 pub fn hand_of(&self, mri: &str) -> Option<&RaisedHand> {
163 self.members.iter().find(|member| member.mri == mri)?.hand.as_ref()
173 self.members.iter().find(|member| member.mri == mri)?.hand.as_ref()
164 }
174 }
@@ -646,6 +656,36 @@ mod tests {
646 assert!(!roster.caption_bot().unwrap().audio_only);
656 assert!(!roster.caption_bot().unwrap().audio_only);
647 }
657 }
648
658
659 const JOIN_ANSWER: &str = include_str!("../tests/fixtures/meeting_join_answer.json");
660
661 #[test]
662 fn a_late_joiner_sees_everyone_from_the_join_answer() {
663 let answer: Value = serde_json::from_str(JOIN_ANSWER).unwrap();
664 let mut roster = Roster::default();
665 assert!(roster.apply_snapshot(&answer["roster"]));
666 let mut names: Vec<String> = roster.entries().into_iter().map(|entry| entry.display_name).collect();
667 names.sort();
668 assert_eq!(names, ["Organizer", "Test Guest 1", "Test Guest 2", "Test Guest 3"]);
669 assert_eq!(roster.video_candidates("8:orgid:00000000-0000-0000-0000-00000000000a").len(), 3);
670 let own_delta = delta(json!({"8:orgid:00000000-0000-0000-0000-00000000000a": participant("Organizer", 10, "active", true, 840)}));
671 roster.apply(&own_delta);
672 assert_eq!(roster.members().len(), 4);
673 }
674
675 #[test]
676 fn a_snapshot_drops_people_it_no_longer_lists_unless_a_newer_delta_added_them() {
677 let mut roster = Roster::default();
678 roster.apply(&delta(json!({
679 "8:orgid:gone": participant("Gone", 3, "active", false, 201),
680 "8:orgid:new": participant("New", 12, "active", false, 301),
681 })));
682 let snapshot = json!({"type": "Delta", "sequenceNumber": 9, "participants": {"8:orgid:a": participant("Ana", 4, "active", false, 401)}});
683 assert!(roster.apply_snapshot(&snapshot));
684 let mut mris: Vec<&str> = roster.members().iter().map(|member| member.mri.as_str()).collect();
685 mris.sort();
686 assert_eq!(mris, ["8:orgid:a", "8:orgid:new"]);
687 }
688
649 #[test]
689 #[test]
650 fn caption_speakers_resolve_by_mri_or_object_id() {
690 fn caption_speakers_resolve_by_mri_or_object_id() {
651 let mut roster = Roster::default();
691 let mut roster = Roster::default();
crates/calling/src/signaling.rs +36 −11
@@ -119,6 +119,7 @@ pub struct Conversation {
119 119 pub controller: String,
120 120 pub links: BTreeMap<String, String>,
121 121 pub chat_thread: Option<String>,
122 pub roster: Option<Value>,
122 123 }
123 124
124 125 impl Conversation {
@@ -310,20 +311,12 @@ impl Signaling {
310 311 Ok((target, conversation_from(&response.body)?))
311 312 }
312 313
313 /// Joins with the offer; the answer may restate the conversation links, otherwise the subscribed ones stay.
314 /// A running meeting answers from the conversation that owns it, so its controller and links replace the subscribed ones.
314 315 pub async fn join_meeting(&self, subscribed: &Conversation, invitation: &Invitation<'_>) -> Result<Conversation> {
315 316 let response = self
316 317 .send("POST join", Method::Post, &subscribed.controller, Some(epconv_body(invitation)))
317 318 .await?;
318 let mut links = subscribed.links.clone();
319 if let Ok(joined) = conversation_from(&response.body) {
320 links.extend(joined.links);
321 }
322 Ok(Conversation {
323 controller: subscribed.controller.clone(),
324 links,
325 chat_thread: subscribed.chat_thread.clone(),
326 })
319 Ok(joined_conversation(subscribed, &response.body))
327 320 }
328 321
329 322 pub fn next_endpoint_sequence(&self) -> u32 {
@@ -884,7 +877,22 @@ fn conversation_from(body: &Value) -> Result<Conversation> {
884 877 .collect()
885 878 })
886 879 .unwrap_or_default();
887 Ok(Conversation { controller, links, chat_thread: chat_thread_id(body) })
880 let roster = Some(&body["roster"]).filter(|roster| roster.is_object()).cloned();
881 Ok(Conversation { controller, links, chat_thread: chat_thread_id(body), roster })
882 }
883
884 fn joined_conversation(subscribed: &Conversation, answer: &Value) -> Conversation {
885 let Ok(joined) = conversation_from(answer) else {
886 return subscribed.clone();
887 };
888 let mut links = subscribed.links.clone();
889 links.extend(joined.links);
890 Conversation {
891 controller: joined.controller,
892 links,
893 chat_thread: joined.chat_thread.or_else(|| subscribed.chat_thread.clone()),
894 roster: joined.roster.or_else(|| subscribed.roster.clone()),
895 }
888 896 }
889 897
890 898 #[derive(Debug, Clone, PartialEq, Eq)]
@@ -1227,6 +1235,23 @@ mod tests {
1227 1235 assert!(attached_from(&json!({})).is_err());
1228 1236 }
1229 1237
1238 #[test]
1239 fn a_running_meeting_answers_from_its_owning_conversation_with_the_roster() {
1240 let subscribed = conversation_from(&json!({
1241 "conversationController": "https://conv/subscribed",
1242 "links": {"leave": "https://conv/subscribed/leave", "mute": "https://conv/subscribed/mute"},
1243 }))
1244 .unwrap();
1245 assert_eq!(subscribed.roster, None);
1246 let answer: Value = serde_json::from_str(include_str!("../tests/fixtures/meeting_join_answer.json")).unwrap();
1247 let joined = joined_conversation(&subscribed, &answer);
1248 assert_eq!(joined.controller, "https://conv.example/conv/joined");
1249 assert_eq!(joined.link("leave").unwrap(), "https://conv.example/conv/joined/leave");
1250 assert_eq!(joined.link("mute").unwrap(), "https://conv/subscribed/mute");
1251 assert_eq!(joined.roster.unwrap()["participants"].as_object().unwrap().len(), 4);
1252 assert_eq!(joined_conversation(&subscribed, &json!({})).controller, "https://conv/subscribed");
1253 }
1254
1230 1255 #[test]
1231 1256 fn acceptance_carries_the_answer_and_callback_links() {
1232 1257 let from = from();
@@ -119,6 +119,7 @@ pub struct Conversation {
119 pub controller: String,
119 pub controller: String,
120 pub links: BTreeMap<String, String>,
120 pub links: BTreeMap<String, String>,
121 pub chat_thread: Option<String>,
121 pub chat_thread: Option<String>,
122 pub roster: Option<Value>,
122}
123}
123
124
124impl Conversation {
125impl Conversation {
@@ -310,20 +311,12 @@ impl Signaling {
310 Ok((target, conversation_from(&response.body)?))
311 Ok((target, conversation_from(&response.body)?))
311 }
312 }
312
313
313 /// Joins with the offer; the answer may restate the conversation links, otherwise the subscribed ones stay.
314 /// A running meeting answers from the conversation that owns it, so its controller and links replace the subscribed ones.
314 pub async fn join_meeting(&self, subscribed: &Conversation, invitation: &Invitation<'_>) -> Result<Conversation> {
315 pub async fn join_meeting(&self, subscribed: &Conversation, invitation: &Invitation<'_>) -> Result<Conversation> {
315 let response = self
316 let response = self
316 .send("POST join", Method::Post, &subscribed.controller, Some(epconv_body(invitation)))
317 .send("POST join", Method::Post, &subscribed.controller, Some(epconv_body(invitation)))
317 .await?;
318 .await?;
318 let mut links = subscribed.links.clone();
319 Ok(joined_conversation(subscribed, &response.body))
319 if let Ok(joined) = conversation_from(&response.body) {
320 links.extend(joined.links);
321 }
322 Ok(Conversation {
323 controller: subscribed.controller.clone(),
324 links,
325 chat_thread: subscribed.chat_thread.clone(),
326 })
327 }
320 }
328
321
329 pub fn next_endpoint_sequence(&self) -> u32 {
322 pub fn next_endpoint_sequence(&self) -> u32 {
@@ -884,7 +877,22 @@ fn conversation_from(body: &Value) -> Result<Conversation> {
884 .collect()
877 .collect()
885 })
878 })
886 .unwrap_or_default();
879 .unwrap_or_default();
887 Ok(Conversation { controller, links, chat_thread: chat_thread_id(body) })
880 let roster = Some(&body["roster"]).filter(|roster| roster.is_object()).cloned();
881 Ok(Conversation { controller, links, chat_thread: chat_thread_id(body), roster })
882}
883
884fn joined_conversation(subscribed: &Conversation, answer: &Value) -> Conversation {
885 let Ok(joined) = conversation_from(answer) else {
886 return subscribed.clone();
887 };
888 let mut links = subscribed.links.clone();
889 links.extend(joined.links);
890 Conversation {
891 controller: joined.controller,
892 links,
893 chat_thread: joined.chat_thread.or_else(|| subscribed.chat_thread.clone()),
894 roster: joined.roster.or_else(|| subscribed.roster.clone()),
895 }
888}
896}
889
897
890#[derive(Debug, Clone, PartialEq, Eq)]
898#[derive(Debug, Clone, PartialEq, Eq)]
@@ -1227,6 +1235,23 @@ mod tests {
1227 assert!(attached_from(&json!({})).is_err());
1235 assert!(attached_from(&json!({})).is_err());
1228 }
1236 }
1229
1237
1238 #[test]
1239 fn a_running_meeting_answers_from_its_owning_conversation_with_the_roster() {
1240 let subscribed = conversation_from(&json!({
1241 "conversationController": "https://conv/subscribed",
1242 "links": {"leave": "https://conv/subscribed/leave", "mute": "https://conv/subscribed/mute"},
1243 }))
1244 .unwrap();
1245 assert_eq!(subscribed.roster, None);
1246 let answer: Value = serde_json::from_str(include_str!("../tests/fixtures/meeting_join_answer.json")).unwrap();
1247 let joined = joined_conversation(&subscribed, &answer);
1248 assert_eq!(joined.controller, "https://conv.example/conv/joined");
1249 assert_eq!(joined.link("leave").unwrap(), "https://conv.example/conv/joined/leave");
1250 assert_eq!(joined.link("mute").unwrap(), "https://conv/subscribed/mute");
1251 assert_eq!(joined.roster.unwrap()["participants"].as_object().unwrap().len(), 4);
1252 assert_eq!(joined_conversation(&subscribed, &json!({})).controller, "https://conv/subscribed");
1253 }
1254
1230 #[test]
1255 #[test]
1231 fn acceptance_carries_the_answer_and_callback_links() {
1256 fn acceptance_carries_the_answer_and_callback_links() {
1232 let from = from();
1257 let from = from();
crates/calling/tests/fixtures/meeting_join_answer.json added +225 −0
@@ -0,0 +1,225 @@
1 {
2 "conversationController": "https://conv.example/conv/joined",
3 "links": {
4 "leave": "https://conv.example/conv/joined/leave"
5 },
6 "roster": {
7 "participantCounts": {
8 "lobbyParticipants": 0,
9 "overflowAttendeeCount": 0,
10 "preheatedParticipants": 0,
11 "requestingAttentionAttendees": 0,
12 "requestingAttentionInterpreters": 0,
13 "requestingAttentionPresenters": 0,
14 "streamingClients": 0,
15 "totalAttendees": 0,
16 "totalInterpreters": 0,
17 "totalOrganizers": 1,
18 "totalParticipants": 4,
19 "totalPresenters": 4,
20 "totalUnverifiedUsers": 3
21 },
22 "participants": {
23 "8:orgid:00000000-0000-0000-0000-00000000000a": {
24 "meetingRole": "organizer",
25 "role": "admin",
26 "state": "active",
27 "version": 3,
28 "details": {
29 "id": "8:orgid:00000000-0000-0000-0000-00000000000a",
30 "displayName": "Organizer",
31 "participantType": "inTenant"
32 },
33 "endpoints": {
34 "00000000-0000-0000-0000-000000000000": {
35 "call": {
36 "mediaStreams": [
37 {
38 "direction": "sendrecv",
39 "label": "main-audio",
40 "serverMuted": false,
41 "sourceId": 201,
42 "type": "audio"
43 },
44 {
45 "direction": "recvonly",
46 "label": "main-video",
47 "serverMuted": false,
48 "sourceId": 202,
49 "type": "video"
50 },
51 {
52 "direction": "recvonly",
53 "label": "applicationsharing-video",
54 "serverMuted": false,
55 "sourceId": 212,
56 "type": "applicationsharing-video"
57 },
58 {
59 "direction": "sendrecv",
60 "label": "data",
61 "serverMuted": false,
62 "sourceId": 213,
63 "type": "data"
64 }
65 ]
66 },
67 "endpointState": {
68 "endpointStateSequenceNumber": 3,
69 "state": {
70 "isMuted": true
71 }
72 },
73 "modalityJoined": "Call"
74 }
75 }
76 },
77 "8:teamsvisitor:00000000000000000000000000000001": {
78 "meetingRole": "presenter",
79 "role": "guest",
80 "state": "active",
81 "version": 7,
82 "details": {
83 "id": "8:teamsvisitor:00000000000000000000000000000001",
84 "displayName": "Test Guest 1",
85 "participantType": "anonymous"
86 },
87 "endpoints": {
88 "00000001-0000-0000-0000-000000000000": {
89 "call": {
90 "mediaStreams": [
91 {
92 "direction": "sendrecv",
93 "label": "main-audio",
94 "serverMuted": false,
95 "sourceId": 414,
96 "type": "audio"
97 },
98 {
99 "direction": "sendrecv",
100 "label": "main-video",
101 "serverMuted": false,
102 "sourceId": 415,
103 "type": "video"
104 },
105 {
106 "direction": "recvonly",
107 "label": "applicationsharing-video",
108 "serverMuted": false,
109 "sourceId": 425,
110 "type": "applicationsharing-video"
111 },
112 {
113 "direction": "sendrecv",
114 "label": "data",
115 "serverMuted": false,
116 "sourceId": 426,
117 "type": "data"
118 }
119 ]
120 },
121 "modalityJoined": "Lobby,Call"
122 }
123 }
124 },
125 "8:teamsvisitor:00000000000000000000000000000002": {
126 "meetingRole": "presenter",
127 "role": "guest",
128 "state": "active",
129 "version": 9,
130 "details": {
131 "id": "8:teamsvisitor:00000000000000000000000000000002",
132 "displayName": "Test Guest 2",
133 "participantType": "anonymous"
134 },
135 "endpoints": {
136 "00000002-0000-0000-0000-000000000000": {
137 "call": {
138 "mediaStreams": [
139 {
140 "direction": "sendrecv",
141 "label": "main-audio",
142 "serverMuted": false,
143 "sourceId": 627,
144 "type": "audio"
145 },
146 {
147 "direction": "sendrecv",
148 "label": "main-video",
149 "serverMuted": false,
150 "sourceId": 628,
151 "type": "video"
152 },
153 {
154 "direction": "recvonly",
155 "label": "applicationsharing-video",
156 "serverMuted": false,
157 "sourceId": 638,
158 "type": "applicationsharing-video"
159 },
160 {
161 "direction": "sendrecv",
162 "label": "data",
163 "serverMuted": false,
164 "sourceId": 639,
165 "type": "data"
166 }
167 ]
168 },
169 "modalityJoined": "Lobby,Call"
170 }
171 }
172 },
173 "8:teamsvisitor:00000000000000000000000000000003": {
174 "meetingRole": "presenter",
175 "role": "guest",
176 "state": "active",
177 "version": 8,
178 "details": {
179 "id": "8:teamsvisitor:00000000000000000000000000000003",
180 "displayName": "Test Guest 3",
181 "participantType": "anonymous"
182 },
183 "endpoints": {
184 "00000003-0000-0000-0000-000000000000": {
185 "call": {
186 "mediaStreams": [
187 {
188 "direction": "sendrecv",
189 "label": "main-audio",
190 "serverMuted": false,
191 "sourceId": 840,
192 "type": "audio"
193 },
194 {
195 "direction": "sendrecv",
196 "label": "main-video",
197 "serverMuted": false,
198 "sourceId": 841,
199 "type": "video"
200 },
201 {
202 "direction": "recvonly",
203 "label": "applicationsharing-video",
204 "serverMuted": false,
205 "sourceId": 851,
206 "type": "applicationsharing-video"
207 },
208 {
209 "direction": "sendrecv",
210 "label": "data",
211 "serverMuted": false,
212 "sourceId": 852,
213 "type": "data"
214 }
215 ]
216 },
217 "modalityJoined": "Lobby,Call"
218 }
219 }
220 }
221 },
222 "sequenceNumber": 9,
223 "type": "Delta"
224 }
225 }
@@ -0,0 +1,225 @@
1{
2 "conversationController": "https://conv.example/conv/joined",
3 "links": {
4 "leave": "https://conv.example/conv/joined/leave"
5 },
6 "roster": {
7 "participantCounts": {
8 "lobbyParticipants": 0,
9 "overflowAttendeeCount": 0,
10 "preheatedParticipants": 0,
11 "requestingAttentionAttendees": 0,
12 "requestingAttentionInterpreters": 0,
13 "requestingAttentionPresenters": 0,
14 "streamingClients": 0,
15 "totalAttendees": 0,
16 "totalInterpreters": 0,
17 "totalOrganizers": 1,
18 "totalParticipants": 4,
19 "totalPresenters": 4,
20 "totalUnverifiedUsers": 3
21 },
22 "participants": {
23 "8:orgid:00000000-0000-0000-0000-00000000000a": {
24 "meetingRole": "organizer",
25 "role": "admin",
26 "state": "active",
27 "version": 3,
28 "details": {
29 "id": "8:orgid:00000000-0000-0000-0000-00000000000a",
30 "displayName": "Organizer",
31 "participantType": "inTenant"
32 },
33 "endpoints": {
34 "00000000-0000-0000-0000-000000000000": {
35 "call": {
36 "mediaStreams": [
37 {
38 "direction": "sendrecv",
39 "label": "main-audio",
40 "serverMuted": false,
41 "sourceId": 201,
42 "type": "audio"
43 },
44 {
45 "direction": "recvonly",
46 "label": "main-video",
47 "serverMuted": false,
48 "sourceId": 202,
49 "type": "video"
50 },
51 {
52 "direction": "recvonly",
53 "label": "applicationsharing-video",
54 "serverMuted": false,
55 "sourceId": 212,
56 "type": "applicationsharing-video"
57 },
58 {
59 "direction": "sendrecv",
60 "label": "data",
61 "serverMuted": false,
62 "sourceId": 213,
63 "type": "data"
64 }
65 ]
66 },
67 "endpointState": {
68 "endpointStateSequenceNumber": 3,
69 "state": {
70 "isMuted": true
71 }
72 },
73 "modalityJoined": "Call"
74 }
75 }
76 },
77 "8:teamsvisitor:00000000000000000000000000000001": {
78 "meetingRole": "presenter",
79 "role": "guest",
80 "state": "active",
81 "version": 7,
82 "details": {
83 "id": "8:teamsvisitor:00000000000000000000000000000001",
84 "displayName": "Test Guest 1",
85 "participantType": "anonymous"
86 },
87 "endpoints": {
88 "00000001-0000-0000-0000-000000000000": {
89 "call": {
90 "mediaStreams": [
91 {
92 "direction": "sendrecv",
93 "label": "main-audio",
94 "serverMuted": false,
95 "sourceId": 414,
96 "type": "audio"
97 },
98 {
99 "direction": "sendrecv",
100 "label": "main-video",
101 "serverMuted": false,
102 "sourceId": 415,
103 "type": "video"
104 },
105 {
106 "direction": "recvonly",
107 "label": "applicationsharing-video",
108 "serverMuted": false,
109 "sourceId": 425,
110 "type": "applicationsharing-video"
111 },
112 {
113 "direction": "sendrecv",
114 "label": "data",
115 "serverMuted": false,
116 "sourceId": 426,
117 "type": "data"
118 }
119 ]
120 },
121 "modalityJoined": "Lobby,Call"
122 }
123 }
124 },
125 "8:teamsvisitor:00000000000000000000000000000002": {
126 "meetingRole": "presenter",
127 "role": "guest",
128 "state": "active",
129 "version": 9,
130 "details": {
131 "id": "8:teamsvisitor:00000000000000000000000000000002",
132 "displayName": "Test Guest 2",
133 "participantType": "anonymous"
134 },
135 "endpoints": {
136 "00000002-0000-0000-0000-000000000000": {
137 "call": {
138 "mediaStreams": [
139 {
140 "direction": "sendrecv",
141 "label": "main-audio",
142 "serverMuted": false,
143 "sourceId": 627,
144 "type": "audio"
145 },
146 {
147 "direction": "sendrecv",
148 "label": "main-video",
149 "serverMuted": false,
150 "sourceId": 628,
151 "type": "video"
152 },
153 {
154 "direction": "recvonly",
155 "label": "applicationsharing-video",
156 "serverMuted": false,
157 "sourceId": 638,
158 "type": "applicationsharing-video"
159 },
160 {
161 "direction": "sendrecv",
162 "label": "data",
163 "serverMuted": false,
164 "sourceId": 639,
165 "type": "data"
166 }
167 ]
168 },
169 "modalityJoined": "Lobby,Call"
170 }
171 }
172 },
173 "8:teamsvisitor:00000000000000000000000000000003": {
174 "meetingRole": "presenter",
175 "role": "guest",
176 "state": "active",
177 "version": 8,
178 "details": {
179 "id": "8:teamsvisitor:00000000000000000000000000000003",
180 "displayName": "Test Guest 3",
181 "participantType": "anonymous"
182 },
183 "endpoints": {
184 "00000003-0000-0000-0000-000000000000": {
185 "call": {
186 "mediaStreams": [
187 {
188 "direction": "sendrecv",
189 "label": "main-audio",
190 "serverMuted": false,
191 "sourceId": 840,
192 "type": "audio"
193 },
194 {
195 "direction": "sendrecv",
196 "label": "main-video",
197 "serverMuted": false,
198 "sourceId": 841,
199 "type": "video"
200 },
201 {
202 "direction": "recvonly",
203 "label": "applicationsharing-video",
204 "serverMuted": false,
205 "sourceId": 851,
206 "type": "applicationsharing-video"
207 },
208 {
209 "direction": "sendrecv",
210 "label": "data",
211 "serverMuted": false,
212 "sourceId": 852,
213 "type": "data"
214 }
215 ]
216 },
217 "modalityJoined": "Lobby,Call"
218 }
219 }
220 }
221 },
222 "sequenceNumber": 9,
223 "type": "Delta"
224 }
225}