Hi everyone
I am building a social network with a Presence implementation that goes as follows:
Each user has its own user:id and user_presence:id channels. On joining its own user:id channel, the process:
-
Presence.tracks itself on its ownuser_presence:idtopic -
PubSub.subscribes to its contacts’user_presence:idtopics
Users now receives presence updates specifically for their contacts.
Now I’m trying to implement Turn off presence tracking, which means a user no longer receives presence updates from anyone, and no longer sends presence updates to anyone. To do so, I need to:
- Stop tracking current user (solved with
Presence.untrack)
- Unsubscribe current user’s channel process from all its contacts’
user_presence:idsubscriptions
which requires the list of user_presence:ids the user is subscribed to. So far, I only found it here:
iex(21)> Registry.keys(Chata.PubSub, user_channel_pid)
["user_presence:2057978151933313024", "user_presence:2057977985293615104",
"user_presence:2057977985482358784", "user:2057977985293615104"]
I asked on the the GitHub PubSub repo and @chrismccord disrecommended using Registry behind PubSub. However, short of maintaining the list of topics a user is subscribed to in assigns, or separately, (despite that list being available), I can’t think of another way of doing this.
Anyone done something similar before?






















