Skip to content

Commit b45c3ce

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 f9e56d8 commit b45c3ce

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
@@ -541,8 +541,10 @@ fn process_block(from: &Arc<Session>, whom: UserId) -> MessageResult {
541541
janus_info!("Processing block from {:p} to {}", from.handle, whom);
542542
if let Some(joined) = from.join_state.get() {
543543
let mut switchboard = SWITCHBOARD.write()?;
544-
let event = json!({ "event": "blocked", "by": &joined.user_id });
545-
notify_user(&event, &whom, switchboard.publishers_occupying(&joined.room_id));
544+
if let Some(publisher) = switchboard.get_publisher(&whom) {
545+
let event = json!({ "event": "blocked", "by": &joined.user_id });
546+
notify_user(&event, &whom, &[publisher]);
547+
}
546548
switchboard.establish_block(joined.user_id.clone(), whom);
547549
Ok(MessageResponse::msg(json!({})))
548550
} else {
@@ -557,9 +559,9 @@ fn process_unblock(from: &Arc<Session>, whom: UserId) -> MessageResult {
557559
switchboard.lift_block(&joined.user_id, &whom);
558560
if let Some(publisher) = switchboard.get_publisher(&whom) {
559561
send_fir(&[publisher]);
562+
let event = json!({ "event": "unblocked", "by": &joined.user_id });
563+
notify_user(&event, &whom, &[publisher]);
560564
}
561-
let event = json!({ "event": "unblocked", "by": &joined.user_id });
562-
notify_user(&event, &whom, switchboard.publishers_occupying(&joined.room_id));
563565
Ok(MessageResponse::msg(json!({})))
564566
} else {
565567
Err(From::from("Cannot unblock when not in a room."))

0 commit comments

Comments
 (0)