fix(calls): admit all, mute all, attendee release and lost callbacks found in live meeting tests
- Trouter request ids can be negative; the u64 decode dropped those callbacks (roster deltas, acceptance). Now i64. - Admit all admits each waiting person; the service's admitAll answered 202 and left anonymous guests waiting. - Mute all sends the full list as `specified`; scope `all` answered 202 and muted nobody. - Attendee restrictions arrive as `DisableAv` for mic and camera together; it was read as unrestricted, so a per-person release sent nothing. - A recording stop answered 409 while the recorder settles is retried every 5 s, up to 6 times, without blocking the call loop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -1445,7 +1445,13 @@ async fn drive(
1445
1445
report_organizer_result(result, "admit", "Could not admit that person", control, timeline);
1446
1446
}
1447
1447
Some(CallCommand::AdmitAll) => {
1448
let result = remote.signaling.admit_all(&remote.conversation, &remote.participant, &links).await;
1448
let mut result = Ok(202);
1449
for mri in roster.lobby_mris() {
1450
result = remote.signaling.admit(&remote.conversation, &remote.participant, target_of(&roster, &mri), &links).await;
1451
if result.is_err() {
1452
break;
1453
}
1454
}
1449
1455
report_organizer_result(result, "admit all", "Could not admit everyone", control, timeline);
1450
1456
}
1451
1457
Some(CallCommand::Deny { mri }) => {
@@ -2142,6 +2148,14 @@ fn target_of<'a>(roster: &'a Roster, mri: &'a str) -> Target<'a> {
2142
2148
Target { mri, display_name }
2143
2149
}
2144
2150
2151
const RECORDING_STOP_RETRIES: usize = 6;
2152
const RECORDING_STOP_RETRY_WAIT: Duration = Duration::from_secs(5);
2153
2154
/// The recorder answers 409 to a stop sent while its start is still settling.
2155
fn recorder_busy(error: &Error) -> bool {
2156
matches!(error, Error::Signaling(reason) if reason.contains("HTTP 409"))
2157
}
2158
2145
2159
fn report_organizer_result(result: Result<u16>, label: &str, notice: &str, control: &CallControl, timeline: &Timeline) {
2146
2160
if let Err(error) = &result {
2147
2161
timeline.record(format!("{label} failed"), error.to_string());
@@ -2246,8 +2260,23 @@ async fn run_bot_steps(
2246
2260
}
2247
2261
}
2248
2262
BotJob::Recording => {
2249
let stopped = remote.signaling.recording_command(&url, plan.stop(), &remote.participant, &plan.title).await;
2250
report_organizer_result(stopped, "recording stop", "The recording could not be stopped", control, timeline);
2263
let remote = remote.clone();
2264
let updates = control.updates();
2265
let (command, title) = (plan.stop(), plan.title.clone());
2266
tokio::spawn(async move {
2267
let mut stopped = remote.signaling.recording_command(&url, command, &remote.participant, &title).await;
2268
for _ in 0..RECORDING_STOP_RETRIES {
2269
if !stopped.as_ref().is_err_and(recorder_busy) {
2270
break;
2271
}
2272
tokio::time::sleep(RECORDING_STOP_RETRY_WAIT).await;
2273
stopped = remote.signaling.recording_command(&url, command, &remote.participant, &title).await;
2274
}
2275
if stopped.is_err() {
2276
let _ = updates.send(CallUpdate::Notice("The recording could not be stopped".into()));
2277
}
2278
let _ = updates.send(CallUpdate::Organizer { action: "recording stop".into(), outcome: stopped.map_err(|error| error.to_string()) });
2279
});
2251
2280
}
2252
2281
}
2253
2282
}
@@ -2632,6 +2661,13 @@ async fn collect_stats(peer: &PeerConnection) -> StatsSnapshot {
2632
2661
mod tests {
2633
2662
use super::*;
2634
2663
2664
#[test]
2665
fn only_a_conflict_answer_retries_a_recording_stop() {
2666
assert!(recorder_busy(&Error::Signaling("recording command answered HTTP 409 no answer".into())));
2667
assert!(!recorder_busy(&Error::Signaling("recording command answered HTTP 500 no answer".into())));
2668
assert!(!recorder_busy(&Error::Cancelled));
2669
}
2670
2635
2671
#[test]
2636
2672
fn video_is_possible_once_connected_and_not_waiting_on_a_mixer_escalation() {
2637
2673
assert!(video_possible(true, Layout::OneToOne, MediaPath::Direct));
@@ -1445,7 +1445,13 @@ async fn drive(1445
report_organizer_result(result, "admit", "Could not admit that person", control, timeline);1445
report_organizer_result(result, "admit", "Could not admit that person", control, timeline);1446
}1446
}1447
Some(CallCommand::AdmitAll) => {1447
Some(CallCommand::AdmitAll) => {1448
let result = remote.signaling.admit_all(&remote.conversation, &remote.participant, &links).await;1448
let mut result = Ok(202);1449
for mri in roster.lobby_mris() {1450
result = remote.signaling.admit(&remote.conversation, &remote.participant, target_of(&roster, &mri), &links).await;1451
if result.is_err() {1452
break;1453
}1454
}1449
report_organizer_result(result, "admit all", "Could not admit everyone", control, timeline);1455
report_organizer_result(result, "admit all", "Could not admit everyone", control, timeline);1450
}1456
}1451
Some(CallCommand::Deny { mri }) => {1457
Some(CallCommand::Deny { mri }) => {@@ -2142,6 +2148,14 @@ fn target_of<'a>(roster: &'a Roster, mri: &'a str) -> Target<'a> {2142
Target { mri, display_name }2148
Target { mri, display_name }2143
}2149
}2144
2150
2151
const RECORDING_STOP_RETRIES: usize = 6;2152
const RECORDING_STOP_RETRY_WAIT: Duration = Duration::from_secs(5);2153
2154
/// The recorder answers 409 to a stop sent while its start is still settling.2155
fn recorder_busy(error: &Error) -> bool {2156
matches!(error, Error::Signaling(reason) if reason.contains("HTTP 409"))2157
}2158
2145
fn report_organizer_result(result: Result<u16>, label: &str, notice: &str, control: &CallControl, timeline: &Timeline) {2159
fn report_organizer_result(result: Result<u16>, label: &str, notice: &str, control: &CallControl, timeline: &Timeline) {2146
if let Err(error) = &result {2160
if let Err(error) = &result {2147
timeline.record(format!("{label} failed"), error.to_string());2161
timeline.record(format!("{label} failed"), error.to_string());@@ -2246,8 +2260,23 @@ async fn run_bot_steps(2246
}2260
}2247
}2261
}2248
BotJob::Recording => {2262
BotJob::Recording => {2249
let stopped = remote.signaling.recording_command(&url, plan.stop(), &remote.participant, &plan.title).await;2263
let remote = remote.clone();2250
report_organizer_result(stopped, "recording stop", "The recording could not be stopped", control, timeline);2264
let updates = control.updates();2265
let (command, title) = (plan.stop(), plan.title.clone());2266
tokio::spawn(async move {2267
let mut stopped = remote.signaling.recording_command(&url, command, &remote.participant, &title).await;2268
for _ in 0..RECORDING_STOP_RETRIES {2269
if !stopped.as_ref().is_err_and(recorder_busy) {2270
break;2271
}2272
tokio::time::sleep(RECORDING_STOP_RETRY_WAIT).await;2273
stopped = remote.signaling.recording_command(&url, command, &remote.participant, &title).await;2274
}2275
if stopped.is_err() {2276
let _ = updates.send(CallUpdate::Notice("The recording could not be stopped".into()));2277
}2278
let _ = updates.send(CallUpdate::Organizer { action: "recording stop".into(), outcome: stopped.map_err(|error| error.to_string()) });2279
});2251
}2280
}2252
}2281
}2253
}2282
}@@ -2632,6 +2661,13 @@ async fn collect_stats(peer: &PeerConnection) -> StatsSnapshot {2632
mod tests {2661
mod tests {2633
use super::*;2662
use super::*;2634
2663
2664
#[test]2665
fn only_a_conflict_answer_retries_a_recording_stop() {2666
assert!(recorder_busy(&Error::Signaling("recording command answered HTTP 409 no answer".into())));2667
assert!(!recorder_busy(&Error::Signaling("recording command answered HTTP 500 no answer".into())));2668
assert!(!recorder_busy(&Error::Cancelled));2669
}2670
2635
#[test]2671
#[test]2636
fn video_is_possible_once_connected_and_not_waiting_on_a_mixer_escalation() {2672
fn video_is_possible_once_connected_and_not_waiting_on_a_mixer_escalation() {2637
assert!(video_possible(true, Layout::OneToOne, MediaPath::Direct));2673
assert!(video_possible(true, Layout::OneToOne, MediaPath::Direct));@@ -7,10 +7,10 @@ use crate::trouter_events::{CallbackLinks, find_key};
7
7
const SPOTLIGHT: &str = "spotlight";
8
8
const AUDIO: &str = "audio";
9
9
const SPECIFIED: &str = "specified";
10
const EVERYONE: &str = "all";
11
10
const PRESENTER: &str = "presenter";
12
11
const DISABLE_AUDIO: &str = "DisableAudio";
13
12
const DISABLE_VIDEO: &str = "DisableVideo";
13
const DISABLE_AUDIO_AND_VIDEO: &str = "DisableAv";
14
14
const UNRESTRICTED: &str = "UnRestricted";
15
15
16
16
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
@@ -30,8 +30,9 @@ impl MeetingCapability {
30
30
self.locked = locked;
31
31
}
32
32
if let Some(restrictions) = capability["attendeeRestrictions"].as_str() {
33
self.attendee_mic_off = restrictions.contains(DISABLE_AUDIO);
34
self.attendee_camera_off = restrictions.contains(DISABLE_VIDEO);
33
let both = restrictions.contains(DISABLE_AUDIO_AND_VIDEO);
34
self.attendee_mic_off = both || restrictions.contains(DISABLE_AUDIO);
35
self.attendee_camera_off = both || restrictions.contains(DISABLE_VIDEO);
35
36
}
36
37
*self != before
37
38
}
@@ -148,15 +149,6 @@ pub fn admit_body(from: Value, target: Target<'_>, callbacks: &CallbackLinks, ca
148
149
})
149
150
}
150
151
151
pub fn admit_all_body(from: Value, callbacks: &CallbackLinks, operation_id: &str) -> Value {
152
json!({
153
"participants": {"from": from},
154
"links": {"admitAllStatus": callbacks.conversation("admitAllStatus")},
155
"operationId": operation_id,
156
"debugContent": {"causeId": operation_id},
157
})
158
}
159
160
152
pub fn remove_participant_body(from: Value, target: Target<'_>, callbacks: &CallbackLinks) -> Value {
161
153
json!({
162
154
"participants": {"from": from, "to": [target.wire()]},
@@ -171,8 +163,9 @@ pub fn mute_participants_body(from: Value, mris: &[String]) -> Value {
171
163
mute_body(from, SPECIFIED, mris)
172
164
}
173
165
166
/// Scope `all` answers 202 but mutes nobody live; `specified` with everyone listed works.
174
167
pub fn mute_everyone_body(from: Value, others: &[String]) -> Value {
175
mute_body(from, EVERYONE, others)
168
mute_body(from, SPECIFIED, others)
176
169
}
177
170
178
171
fn mute_body(from: Value, scope: &str, mris: &[String]) -> Value {
@@ -306,14 +299,6 @@ mod tests {
306
299
assert_eq!(body["debugContent"]["causeId"], "cause-1");
307
300
}
308
301
309
#[test]
310
fn admitting_everyone_has_no_recipients() {
311
let body = admit_all_body(from(), &callbacks(), "op-1");
312
assert!(body["participants"].get("to").is_none());
313
assert_eq!(body["operationId"], "op-1");
314
assert!(body["links"]["admitAllStatus"].as_str().unwrap().contains("/conversation/admitAllStatus/"));
315
}
316
317
302
#[test]
318
303
fn denying_and_removing_use_the_remove_body() {
319
304
let body = remove_participant_body(from(), ana(), &callbacks());
@@ -323,13 +308,13 @@ mod tests {
323
308
}
324
309
325
310
#[test]
326
fn muting_one_or_all_only_changes_the_scope() {
311
fn muting_one_or_all_names_everyone_as_specified() {
327
312
let one = mute_participants_body(from(), &["8:orgid:ana".to_owned()]);
328
313
assert_eq!(one["scope"], "specified");
329
314
assert_eq!(one["muteParticipants"], json!([{"id": "8:orgid:ana"}]));
330
315
assert_eq!(one["mediaTypes"], json!(["audio"]));
331
316
let everyone = mute_everyone_body(from(), &["8:orgid:ana".to_owned(), "8:orgid:bo".to_owned()]);
332
assert_eq!(everyone["scope"], "all");
317
assert_eq!(everyone["scope"], "specified");
333
318
assert_eq!(everyone["muteParticipants"].as_array().unwrap().len(), 2);
334
319
}
335
320
@@ -431,6 +416,13 @@ mod tests {
431
416
assert_eq!(state, MeetingCapability::default());
432
417
}
433
418
419
#[test]
420
fn the_live_service_reports_mic_and_camera_off_as_one_value() {
421
let mut state = MeetingCapability::default();
422
assert!(state.apply(&json!({"meetingCapability": {"attendeeRestrictions": "DisableAv"}})));
423
assert!(state.attendee_mic_off && state.attendee_camera_off);
424
}
425
434
426
#[test]
435
427
fn a_mic_is_allowed_unless_blocked_or_the_meeting_blocks_everyone() {
436
428
let none = AttendeeLimits::default();
@@ -7,10 +7,10 @@ use crate::trouter_events::{CallbackLinks, find_key};7
const SPOTLIGHT: &str = "spotlight";7
const SPOTLIGHT: &str = "spotlight";8
const AUDIO: &str = "audio";8
const AUDIO: &str = "audio";9
const SPECIFIED: &str = "specified";9
const SPECIFIED: &str = "specified";10
const EVERYONE: &str = "all";11
const PRESENTER: &str = "presenter";10
const PRESENTER: &str = "presenter";12
const DISABLE_AUDIO: &str = "DisableAudio";11
const DISABLE_AUDIO: &str = "DisableAudio";13
const DISABLE_VIDEO: &str = "DisableVideo";12
const DISABLE_VIDEO: &str = "DisableVideo";13
const DISABLE_AUDIO_AND_VIDEO: &str = "DisableAv";14
const UNRESTRICTED: &str = "UnRestricted";14
const UNRESTRICTED: &str = "UnRestricted";15
15
16
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]16
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]@@ -30,8 +30,9 @@ impl MeetingCapability {30
self.locked = locked;30
self.locked = locked;31
}31
}32
if let Some(restrictions) = capability["attendeeRestrictions"].as_str() {32
if let Some(restrictions) = capability["attendeeRestrictions"].as_str() {33
self.attendee_mic_off = restrictions.contains(DISABLE_AUDIO);33
let both = restrictions.contains(DISABLE_AUDIO_AND_VIDEO);34
self.attendee_camera_off = restrictions.contains(DISABLE_VIDEO);34
self.attendee_mic_off = both || restrictions.contains(DISABLE_AUDIO);35
self.attendee_camera_off = both || restrictions.contains(DISABLE_VIDEO);35
}36
}36
*self != before37
*self != before37
}38
}@@ -148,15 +149,6 @@ pub fn admit_body(from: Value, target: Target<'_>, callbacks: &CallbackLinks, ca148
})149
})149
}150
}150
151
151
pub fn admit_all_body(from: Value, callbacks: &CallbackLinks, operation_id: &str) -> Value {152
json!({153
"participants": {"from": from},154
"links": {"admitAllStatus": callbacks.conversation("admitAllStatus")},155
"operationId": operation_id,156
"debugContent": {"causeId": operation_id},157
})158
}159
160
pub fn remove_participant_body(from: Value, target: Target<'_>, callbacks: &CallbackLinks) -> Value {152
pub fn remove_participant_body(from: Value, target: Target<'_>, callbacks: &CallbackLinks) -> Value {161
json!({153
json!({162
"participants": {"from": from, "to": [target.wire()]},154
"participants": {"from": from, "to": [target.wire()]},@@ -171,8 +163,9 @@ pub fn mute_participants_body(from: Value, mris: &[String]) -> Value {171
mute_body(from, SPECIFIED, mris)163
mute_body(from, SPECIFIED, mris)172
}164
}173
165
166
/// Scope `all` answers 202 but mutes nobody live; `specified` with everyone listed works.174
pub fn mute_everyone_body(from: Value, others: &[String]) -> Value {167
pub fn mute_everyone_body(from: Value, others: &[String]) -> Value {175
mute_body(from, EVERYONE, others)168
mute_body(from, SPECIFIED, others)176
}169
}177
170
178
fn mute_body(from: Value, scope: &str, mris: &[String]) -> Value {171
fn mute_body(from: Value, scope: &str, mris: &[String]) -> Value {@@ -306,14 +299,6 @@ mod tests {306
assert_eq!(body["debugContent"]["causeId"], "cause-1");299
assert_eq!(body["debugContent"]["causeId"], "cause-1");307
}300
}308
301
309
#[test]310
fn admitting_everyone_has_no_recipients() {311
let body = admit_all_body(from(), &callbacks(), "op-1");312
assert!(body["participants"].get("to").is_none());313
assert_eq!(body["operationId"], "op-1");314
assert!(body["links"]["admitAllStatus"].as_str().unwrap().contains("/conversation/admitAllStatus/"));315
}316
317
#[test]302
#[test]318
fn denying_and_removing_use_the_remove_body() {303
fn denying_and_removing_use_the_remove_body() {319
let body = remove_participant_body(from(), ana(), &callbacks());304
let body = remove_participant_body(from(), ana(), &callbacks());@@ -323,13 +308,13 @@ mod tests {323
}308
}324
309
325
#[test]310
#[test]326
fn muting_one_or_all_only_changes_the_scope() {311
fn muting_one_or_all_names_everyone_as_specified() {327
let one = mute_participants_body(from(), &["8:orgid:ana".to_owned()]);312
let one = mute_participants_body(from(), &["8:orgid:ana".to_owned()]);328
assert_eq!(one["scope"], "specified");313
assert_eq!(one["scope"], "specified");329
assert_eq!(one["muteParticipants"], json!([{"id": "8:orgid:ana"}]));314
assert_eq!(one["muteParticipants"], json!([{"id": "8:orgid:ana"}]));330
assert_eq!(one["mediaTypes"], json!(["audio"]));315
assert_eq!(one["mediaTypes"], json!(["audio"]));331
let everyone = mute_everyone_body(from(), &["8:orgid:ana".to_owned(), "8:orgid:bo".to_owned()]);316
let everyone = mute_everyone_body(from(), &["8:orgid:ana".to_owned(), "8:orgid:bo".to_owned()]);332
assert_eq!(everyone["scope"], "all");317
assert_eq!(everyone["scope"], "specified");333
assert_eq!(everyone["muteParticipants"].as_array().unwrap().len(), 2);318
assert_eq!(everyone["muteParticipants"].as_array().unwrap().len(), 2);334
}319
}335
320
@@ -431,6 +416,13 @@ mod tests {431
assert_eq!(state, MeetingCapability::default());416
assert_eq!(state, MeetingCapability::default());432
}417
}433
418
419
#[test]420
fn the_live_service_reports_mic_and_camera_off_as_one_value() {421
let mut state = MeetingCapability::default();422
assert!(state.apply(&json!({"meetingCapability": {"attendeeRestrictions": "DisableAv"}})));423
assert!(state.attendee_mic_off && state.attendee_camera_off);424
}425
434
#[test]426
#[test]435
fn a_mic_is_allowed_unless_blocked_or_the_meeting_blocks_everyone() {427
fn a_mic_is_allowed_unless_blocked_or_the_meeting_blocks_everyone() {436
let none = AttendeeLimits::default();428
let none = AttendeeLimits::default();@@ -184,6 +184,11 @@ impl Roster {
184
184
self.members.iter().any(|member| member.mri == mri && member.organizer)
185
185
}
186
186
187
/// Teams web admits everyone by listing them: the server's `admitAll` leaves anonymous guests waiting.
188
pub fn lobby_mris(&self) -> Vec<String> {
189
self.members.iter().filter(|member| member.in_lobby).map(|member| member.mri.clone()).collect()
190
}
191
187
192
pub fn is_in_lobby(&self, mri: &str) -> Option<bool> {
188
193
self.members.iter().find(|member| member.mri == mri).map(|member| member.in_lobby)
189
194
}
@@ -411,6 +416,20 @@ mod tests {
411
416
assert_eq!(roster.is_in_lobby("8:orgid:nobody"), None);
412
417
}
413
418
419
#[test]
420
fn lobby_mris_lists_only_people_waiting() {
421
let mut roster = Roster::default();
422
let waiting = |name: &str| json!({"version": 1, "state": "active", "details": {"displayName": name}, "endpoints": {"ep": {"lobby": {"mediaStreams": []}}}});
423
roster.apply(&delta(json!({
424
"8:teamsvisitor:one": waiting("One"),
425
"8:orgid:me": participant("Me", 1, "active", true, 201),
426
"8:teamsvisitor:two": waiting("Two"),
427
})));
428
let mut waiting_mris = roster.lobby_mris();
429
waiting_mris.sort();
430
assert_eq!(waiting_mris, vec!["8:teamsvisitor:one".to_owned(), "8:teamsvisitor:two".to_owned()]);
431
}
432
414
433
#[test]
415
434
fn lobby_counts_come_from_participant_counts() {
416
435
let mut roster = Roster::default();
@@ -184,6 +184,11 @@ impl Roster {184
self.members.iter().any(|member| member.mri == mri && member.organizer)184
self.members.iter().any(|member| member.mri == mri && member.organizer)185
}185
}186
186
187
/// Teams web admits everyone by listing them: the server's `admitAll` leaves anonymous guests waiting.188
pub fn lobby_mris(&self) -> Vec<String> {189
self.members.iter().filter(|member| member.in_lobby).map(|member| member.mri.clone()).collect()190
}191
187
pub fn is_in_lobby(&self, mri: &str) -> Option<bool> {192
pub fn is_in_lobby(&self, mri: &str) -> Option<bool> {188
self.members.iter().find(|member| member.mri == mri).map(|member| member.in_lobby)193
self.members.iter().find(|member| member.mri == mri).map(|member| member.in_lobby)189
}194
}@@ -411,6 +416,20 @@ mod tests {411
assert_eq!(roster.is_in_lobby("8:orgid:nobody"), None);416
assert_eq!(roster.is_in_lobby("8:orgid:nobody"), None);412
}417
}413
418
419
#[test]420
fn lobby_mris_lists_only_people_waiting() {421
let mut roster = Roster::default();422
let waiting = |name: &str| json!({"version": 1, "state": "active", "details": {"displayName": name}, "endpoints": {"ep": {"lobby": {"mediaStreams": []}}}});423
roster.apply(&delta(json!({424
"8:teamsvisitor:one": waiting("One"),425
"8:orgid:me": participant("Me", 1, "active", true, 201),426
"8:teamsvisitor:two": waiting("Two"),427
})));428
let mut waiting_mris = roster.lobby_mris();429
waiting_mris.sort();430
assert_eq!(waiting_mris, vec!["8:teamsvisitor:one".to_owned(), "8:teamsvisitor:two".to_owned()]);431
}432
414
#[test]433
#[test]415
fn lobby_counts_come_from_participant_counts() {434
fn lobby_counts_come_from_participant_counts() {416
let mut roster = Roster::default();435
let mut roster = Roster::default();@@ -425,11 +425,6 @@ impl Signaling {
425
425
self.send("POST admit", Method::Post, conversation.link("admit")?, Some(body)).await.map(|response| response.status)
426
426
}
427
427
428
pub async fn admit_all(&self, conversation: &Conversation, from: &Participant, callbacks: &CallbackLinks) -> Result<u16> {
429
let body = organizer::admit_all_body(from.wire(), callbacks, &uuid::Uuid::new_v4().to_string());
430
self.send("POST admitAll", Method::Post, conversation.link("admitAll")?, Some(body)).await.map(|response| response.status)
431
}
432
433
428
pub async fn remove_participant(&self, conversation: &Conversation, from: &Participant, target: Target<'_>, callbacks: &CallbackLinks) -> Result<u16> {
434
429
let body = organizer::remove_participant_body(from.wire(), target, callbacks);
435
430
self.send("POST removeParticipant", Method::Post, conversation.link("removeParticipant")?, Some(body)).await.map(|response| response.status)
@@ -425,11 +425,6 @@ impl Signaling {425
self.send("POST admit", Method::Post, conversation.link("admit")?, Some(body)).await.map(|response| response.status)425
self.send("POST admit", Method::Post, conversation.link("admit")?, Some(body)).await.map(|response| response.status)426
}426
}427
427
428
pub async fn admit_all(&self, conversation: &Conversation, from: &Participant, callbacks: &CallbackLinks) -> Result<u16> {429
let body = organizer::admit_all_body(from.wire(), callbacks, &uuid::Uuid::new_v4().to_string());430
self.send("POST admitAll", Method::Post, conversation.link("admitAll")?, Some(body)).await.map(|response| response.status)431
}432
433
pub async fn remove_participant(&self, conversation: &Conversation, from: &Participant, target: Target<'_>, callbacks: &CallbackLinks) -> Result<u16> {428
pub async fn remove_participant(&self, conversation: &Conversation, from: &Participant, target: Target<'_>, callbacks: &CallbackLinks) -> Result<u16> {434
let body = organizer::remove_participant_body(from.wire(), target, callbacks);429
let body = organizer::remove_participant_body(from.wire(), target, callbacks);435
self.send("POST removeParticipant", Method::Post, conversation.link("removeParticipant")?, Some(body)).await.map(|response| response.status)430
self.send("POST removeParticipant", Method::Post, conversation.link("removeParticipant")?, Some(body)).await.map(|response| response.status)@@ -7,7 +7,7 @@ const MAX_CALLBACK_BODY: usize = 4 * 1024 * 1024;
7
7
/// A Trouter request for a callback URL the client handed out (`<surl>callAgent/...`), held open until replied.
8
8
#[derive(Debug, Clone, PartialEq, Eq)]
9
9
pub struct TrouterCallback {
10
pub request_id: u64,
10
pub request_id: i64,
11
11
pub path: String,
12
12
pub content_encoding: Option<String>,
13
13
pub body: String,
@@ -15,7 +15,7 @@ pub struct TrouterCallback {
15
15
16
16
#[derive(Debug, Clone, PartialEq, Eq)]
17
17
pub(super) struct CallbackReply {
18
pub request_id: u64,
18
pub request_id: i64,
19
19
pub status: u16,
20
20
pub body: String,
21
21
}
@@ -27,7 +27,7 @@ pub struct CallbackReplier {
27
27
}
28
28
29
29
impl CallbackReplier {
30
pub fn reply(&self, request_id: u64, status: u16, body: impl Into<String>) {
30
pub fn reply(&self, request_id: i64, status: u16, body: impl Into<String>) {
31
31
let _ = self.sender.send(CallbackReply {
32
32
request_id,
33
33
status,
@@ -40,7 +40,7 @@ impl CallbackReplier {
40
40
struct WireCallback {
41
41
channel: String,
42
42
#[serde(rename = "requestId")]
43
request_id: u64,
43
request_id: i64,
44
44
path: String,
45
45
#[serde(rename = "contentEncoding", default)]
46
46
content_encoding: Option<String>,
@@ -87,6 +87,12 @@ mod tests {
87
87
assert_eq!(callback.body, "H4sI");
88
88
}
89
89
90
#[test]
91
fn negative_request_ids_are_callbacks_too() {
92
let payload = r#"{"channel":"callback","requestId":-2,"path":"callAgent/a/b/conversation/rosterUpdate/","body":"{}"}"#;
93
assert_eq!(decode_callback(payload).unwrap().request_id, -2);
94
}
95
90
96
#[test]
91
97
fn other_channels_are_not_callbacks() {
92
98
assert!(decode_callback(r#"{"channel":"status","kind":"connected"}"#).is_none());
@@ -7,7 +7,7 @@ const MAX_CALLBACK_BODY: usize = 4 * 1024 * 1024;7
/// A Trouter request for a callback URL the client handed out (`<surl>callAgent/...`), held open until replied.7
/// A Trouter request for a callback URL the client handed out (`<surl>callAgent/...`), held open until replied.8
#[derive(Debug, Clone, PartialEq, Eq)]8
#[derive(Debug, Clone, PartialEq, Eq)]9
pub struct TrouterCallback {9
pub struct TrouterCallback {10
pub request_id: u64,10
pub request_id: i64,11
pub path: String,11
pub path: String,12
pub content_encoding: Option<String>,12
pub content_encoding: Option<String>,13
pub body: String,13
pub body: String,@@ -15,7 +15,7 @@ pub struct TrouterCallback {15
15
16
#[derive(Debug, Clone, PartialEq, Eq)]16
#[derive(Debug, Clone, PartialEq, Eq)]17
pub(super) struct CallbackReply {17
pub(super) struct CallbackReply {18
pub request_id: u64,18
pub request_id: i64,19
pub status: u16,19
pub status: u16,20
pub body: String,20
pub body: String,21
}21
}@@ -27,7 +27,7 @@ pub struct CallbackReplier {27
}27
}28
28
29
impl CallbackReplier {29
impl CallbackReplier {30
pub fn reply(&self, request_id: u64, status: u16, body: impl Into<String>) {30
pub fn reply(&self, request_id: i64, status: u16, body: impl Into<String>) {31
let _ = self.sender.send(CallbackReply {31
let _ = self.sender.send(CallbackReply {32
request_id,32
request_id,33
status,33
status,@@ -40,7 +40,7 @@ impl CallbackReplier {40
struct WireCallback {40
struct WireCallback {41
channel: String,41
channel: String,42
#[serde(rename = "requestId")]42
#[serde(rename = "requestId")]43
request_id: u64,43
request_id: i64,44
path: String,44
path: String,45
#[serde(rename = "contentEncoding", default)]45
#[serde(rename = "contentEncoding", default)]46
content_encoding: Option<String>,46
content_encoding: Option<String>,@@ -87,6 +87,12 @@ mod tests {87
assert_eq!(callback.body, "H4sI");87
assert_eq!(callback.body, "H4sI");88
}88
}89
89
90
#[test]91
fn negative_request_ids_are_callbacks_too() {92
let payload = r#"{"channel":"callback","requestId":-2,"path":"callAgent/a/b/conversation/rosterUpdate/","body":"{}"}"#;93
assert_eq!(decode_callback(payload).unwrap().request_id, -2);94
}95
90
#[test]96
#[test]91
fn other_channels_are_not_callbacks() {97
fn other_channels_are_not_callbacks() {92
assert!(decode_callback(r#"{"channel":"status","kind":"connected"}"#).is_none());98
assert!(decode_callback(r#"{"channel":"status","kind":"connected"}"#).is_none());