mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-10-06 23:00:11 +09:00
659f95748a
* Preload only uncached messages and reduce rendering overhead * Keep benchmark summaries without raw JSON results * Use Ruby benchmark drivers and keep generated results out of the repo
22 lines
669 B
Ruby
22 lines
669 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
|
|
payload = ActiveSupport::JSON.encode(roomId: room.id)
|
|
|
|
room.memberships.pluck(:user_id).each do |user_id|
|
|
ActionCable.server.broadcast UnreadRoomsChannel.stream_name_for(user_id), payload, coder: nil
|
|
end
|
|
end
|
|
end
|