Closed seifoueddine closed 4 years ago
I found the solution
I send slug_id with the uid, access_token and client for subscribing to the channel and I use it in connection.rb like this
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
def connect
self.current_user = find_verified_user
end
private
def find_verified_user
uid = request.query_parameters[:uid]
token = request.query_parameters[:token]
client_id = request.query_parameters[:client]
slug_id = request.query_parameters[:slug_id]
user = User.where(slug_id: slug_id).find_by_uid(uid) <-------- get all users with the same slug_id :)
if user && user.valid_token?(token, client_id)
user
else
reject_unauthorized_connection
end
end
end
end
I have a basic setup with rails API + devise_token_auth + actionable and angular9 app for the Front.
I basically want to send notifications to a specific group of users not all users.
My code looks like follows:
connections.rb
appointments.rb
ChangeAppointmentsJob
AppointmentChannel
websocket.service.ts
}
All works perfectly, but my code broadcasts all users !!
Is there any way to do it with angular? send specific params for example
Or I want to do something like this in rails code
to send a notification to my Front app but not to all users, just users who had slug_id like the user who created or updated the appointment
any ideas, please!