Currently, Aphlict notifications are broadcast to logged-in users that are (in some way) subscribed to the subject PHID. It would be useful to be able to broadcast notifications to users who are viewing the subject as well. This is slightly more involved than just "users", because a user looking at `T123` should receive real-time notifications about it, even if they aren't a subscriber/author/etc.
Generally, this will involve:
- Updating broadcast messages to include the PHIDs they should be broadcast to (that is, beyond the user PHIDs pertaining to the author and subscribers).
- Updating the Aphlict client:
- It now sends "listen to" and "stop listening to" messages to the server.
- "listen to" is a list of PHIDs the client cares about.
- "stop listening" is a list of PHIDs the client no longer cares about.
- When the user visits a page, the browser sends "listen to" for the object PHID on the page (if one exists) and the user PHID (if not already listening).
- When the user leaves a page, the browser sends "stop listening" (ideally; not a big deal if not).
- We do some reference counting on the client to keep this not-too-spammy I guess.
- So the server now knows which PHIDs a message is about, and which clients care about those PHIDs. It can broadcast messages to just the relevant clients, and we don't need to do any auth stuff.