Skip to content

Commit c310e03

Browse files
committed
Now that get_publisher is optimized, use it instead of iterating over publishers in the room to send the blocked/unblocked event (closes mozilla#80)
1 parent f16c42c commit c310e03

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/lib.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,10 @@ fn process_block(from: &Arc<Session>, whom: UserId) -> MessageResult {
534534
janus_info!("Processing block from {:p} to {}", from.handle, whom);
535535
if let Some(joined) = from.join_state.get() {
536536
let mut switchboard = SWITCHBOARD.write()?;
537-
let event = json!({ "event": "blocked", "by": &joined.user_id });
538-
notify_user(&event, &whom, switchboard.publishers_occupying(&joined.room_id));
537+
if let Some(publisher) = switchboard.get_publisher(&whom) {
538+
let event = json!({ "event": "blocked", "by": &joined.user_id });
539+
notify_user(&event, &whom, &[publisher]);
540+
}
539541
switchboard.establish_block(joined.user_id.clone(), whom);
540542
Ok(MessageResponse::msg(json!({})))
541543
} else {
@@ -550,9 +552,9 @@ fn process_unblock(from: &Arc<Session>, whom: UserId) -> MessageResult {
550552
switchboard.lift_block(&joined.user_id, &whom);
551553
if let Some(publisher) = switchboard.get_publisher(&whom) {
552554
send_fir(&[publisher]);
555+
let event = json!({ "event": "unblocked", "by": &joined.user_id });
556+
notify_user(&event, &whom, &[publisher]);
553557
}
554-
let event = json!({ "event": "unblocked", "by": &joined.user_id });
555-
notify_user(&event, &whom, switchboard.publishers_occupying(&joined.room_id));
556558
Ok(MessageResponse::msg(json!({})))
557559
} else {
558560
Err(From::from("Cannot unblock when not in a room."))

0 commit comments

Comments
 (0)