This repository has been archived by the owner on Feb 7, 2024. It is now read-only.
[draft] Update the User info in the Presence Channel call #401
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is not fully complete yet because it lacks the essentials tests. I'm having a little bit trouble of how I should test this feature but wanted to create the PR first to see that it will be accepted before I spend too much time on it.
Basically what I've done here is to create an API route to update the current
user_info
in presence channels. This is a highly sought after feature in Pusher but they haven't implemented it yet. You can see it here: https://stackoverflow.com/questions/24874279/how-to-change-member-info-in-pusher and https://stackoverflow.com/questions/29207414/save-to-user-info-on-pusher-presence-channels.Personally I need this because I'm storing data here that I need to keep in sync. The problem I have is if UserA logs in and sets his user_info to
on_call => false
and then when UserB logs in he will get theon_call => false
data for UserA. If now UserA answers a call I send out a client event setting this data (on client side) toon_call => true
for UserA. This all works good but if UserB now reloads his page he will get the initial user_info that was set when UserA authenticated which would beon_call => false
.By having an API to update the user_info state this solves my problem. When UserA accepts a call I update the state on my websocket server meaning that UserB (and every other User's joining) will now have an updated info on UserA where
on_call => true
.Hope you would accept this Pull Request and if you do, maybe give me some pointer of how to write a good test for this functionality. Maybe I need unit test to see that the
updateUserInfo
function works properly or do it by a Controller test like I've started.