mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-10-22 06:06:30 +09:00
UnreadRoomsChannel streamed from a hardcoded global name, and every message published its room id to it. Any authenticated user, including one with no memberships at all, could subscribe and watch which rooms were active and exactly when, across every closed room and direct conversation on the account. The browser filters ids it doesn't recognise, but that happens after delivery. Its sibling ReadRoomsChannel is already scoped per user; this mirrors it, and message creation fans the notice out to the room's members instead of broadcasting it to everyone. No message content was exposed either way, only the timing.
13 lines
439 B
Ruby
13 lines
439 B
Ruby
class UnreadRoomsChannel < ApplicationCable::Channel
|
|
# Scoped per user, like ReadRoomsChannel. A single global stream would tell every
|
|
# authenticated connection when any room on the account is active, including closed
|
|
# rooms and direct conversations they're not part of.
|
|
def self.stream_name_for(user_id)
|
|
"user_#{user_id}_unreads"
|
|
end
|
|
|
|
def subscribed
|
|
stream_from self.class.stream_name_for(current_user.id)
|
|
end
|
|
end
|