mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-08-12 18:10:43 +09:00
3b509f55ca
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.
20 lines
608 B
Ruby
20 lines
608 B
Ruby
module Message::Broadcasts
|
|
def broadcast_create
|
|
broadcast_append_to room, :messages, target: [ room, :messages ]
|
|
broadcast_unread_room
|
|
end
|
|
|
|
def broadcast_remove
|
|
broadcast_remove_to room, :messages
|
|
end
|
|
|
|
private
|
|
# Fanned out to the room's members rather than published on one global stream, so
|
|
# that the timing of activity in a room only reaches people who are in it.
|
|
def broadcast_unread_room
|
|
room.memberships.pluck(:user_id).each do |user_id|
|
|
ActionCable.server.broadcast UnreadRoomsChannel.stream_name_for(user_id), { roomId: room.id }
|
|
end
|
|
end
|
|
end
|