There are two ways to get closer to the news feed:
- disable recording
- disable viewing
You are using a write-based fan. In this case, you create a new individual activity for each relevant user.
This approach can explode very quickly, especially if you allow users an unlimited number of subscribers. Whenever there is an action that is frequent, you need to save a new record for every 1000+ followers in the database.
It gets harder when you add groups and different types of audiences. What if now you want to transfer information only to people from group A, but not to group B (for example, you create a status and want to restrict viewing)? What happens when you want to broadcast group A and group B, but are there users in A and B that you do not want to receive the same action twice? What if you want to change the visibility of an activity after creating it?
In fact, this is not possible if the fan is working on a recording basis or at least very difficult. That's why I prefer the latter - a reading-based fan.
Consider this:
The user has a set of news feeds associated with their identifier. These channels are of the form {{ object_name}}:{{ object_id }} . You can have separate sets for news and notifications, so you can cancel notifications on one object without removing it from your news feed.
When a user registers to receive updates from an object, he adds the channel associated with the object to his channel list. You can use a simple set of Redis. For example, if I join event # 1, I add event:1 to the channel list.
When an attribute changes to event # 1, a new action is created only once. This action has a field called an βobserver,β which is the name of the channel on which it is seen. In this case, the observer is "event: 1".
When a user retrieves their activity feed, they first get a list of their subscription channels. Then they retrieve all the elements of the activity feed where the observer is in the channel list.
also
I'm just not sure how to turn this into a notification system. Using the βturn off the fanβ method, I have a set of channels for notifications, as described above. When the attribute of an object changes, I write a new notification to the database, which all subscribers sign. The only problem is this: how would I read the notifications for each user? I still do not understand this part.