process_block and process_unblock are using
notify_user(&event, &whom, switchboard.publishers_occupying(&joined.room_id));
so iterating over publishers in the rooms to find the session for the user id whom having notifications:true.
Looking at it for #55 when using multiple rooms, we should iterate in this case over all rooms and all sessions of those rooms to just find the session.
With an old version of the code, iterating over sessions of the room was better than iterating over all the sessions (this was what get_publisher was doing).
But we now have an optimized switchboard and get_publisher(user_id) is just O(1).
I think we can rewrite process_block and process_unblock and notify_user to use get_publisher here.
Note that previously we didn't use the same semantic for publisher, notify_user is searching for a session with notifications:true and in process_join we check for data:true.
I currently don't have the block/unblock feature in my app, so it may be a little bit difficult for me to test any changes, although I could test it in Chrome console and send the request manually.
I may try doing a PR myself in a month for this if I'm going to work on #55.
process_blockandprocess_unblockare usingnotify_user(&event, &whom, switchboard.publishers_occupying(&joined.room_id));so iterating over publishers in the rooms to find the session for the user id
whomhavingnotifications:true.Looking at it for #55 when using multiple rooms, we should iterate in this case over all rooms and all sessions of those rooms to just find the session.
With an old version of the code, iterating over sessions of the room was better than iterating over all the sessions (this was what
get_publisherwas doing).But we now have an optimized switchboard and
get_publisher(user_id)is just O(1).I think we can rewrite
process_blockandprocess_unblockandnotify_userto useget_publisherhere.Note that previously we didn't use the same semantic for publisher,
notify_useris searching for a session withnotifications:trueand inprocess_joinwe check fordata:true.I currently don't have the block/unblock feature in my app, so it may be a little bit difficult for me to test any changes, although I could test it in Chrome console and send the request manually.
I may try doing a PR myself in a month for this if I'm going to work on #55.