I’m building an administrated Multi-User Chat with Phoenix Channels. Now I’m facing some problems I’d really appreciate help and insights with.
Each topic will have an admin
user, and I’m building administrative rights for them to administrate the channel.
1. How to unsubscribe (=kick) a user from a topic manually from server-side?
The admin has to be able to kick and ban any user from their own topic. From what I can tell, the terminate
callback is only invoked when the user leaves the channel (invokes channel.leave()
or closes the browser tab at the client side). I need to be able to manually unsubscribe any user from any topic (but not disconnect from channels overall) server-side. So far I have not found a way to do this.
2. How to change socket.assigns
outside of callbacks?
Currently, I’m storing each user’s topic specific privilege (VIP / ADMIN etc.) in the user’s socket.assigns
. I need to be able to have an admin user change any subscribed user’s privilege, basically being able to promote them to VIP, revoke their ADMIN rights etc… So basically, I need to find a way to manually adjust any subscribed user’s socket.assigns server-side.
3. Any ideas on implementing some primitive form of spam prevention?
Phoenix Channels have no built-in spam prevention configurations. I need to build something simple, I’m thinking some form of tracking stored in socket.assigns
and then always updated upon a message sent. Anyone faced a similar problem yet?
I don’t understand Phoenix’s Channels implementation well enough yet to tackle these issues on my own. I hope you could share some advice or ideas regarding these issues!