I'm working on a blog and the idea is to get real-time notifications as soon as somebody writes a comment to one of my posts (like on Facebook or similar social media). I've tried to do this with ActionCable feature and everything seems working, but the notifications are seen not only by me, but by everybody who is on the blog now.
I've also tried to add this part of code from the official documentation to make the private channel:
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
def connect
self.current_user = find_verfied_user
end
protected
def find_verfied_user
if current_user = env['warden'].user
current_user
else
reject_unauthorized_connection
end
end
end
end
It worked, but when somebody except the administrator is reading the blog, server keeps polling and rejecting the connection every 20 seconds which is an extra load for the server.
I wonder if there's some way to tell ActionCable to broadcast notifications only to specific user (in that case to me as an administrator) and not to be seen by anybody else? Or is there a better way to do that using other features like Faye? Thanks in advance.