问题
Say I have user who follows a football team. That user posts a message on that teams forum, which creates an activity on the teams feed. Since the user follows the team he also gets an activity in his own feed, about his own post.
Is there any way (other than filtering on the client side) to avoid user initiated activities on other feeds bouncing back on their own feeds?
The user has two feeds, his activity feed, which other users follow, and his notifications feed, which he uses to follow other feeds, such as the football teams.
As he posts on the forum the activity is added to the teams feed and his activity feed, but since the users notification feed also follows the teams feed, the user gets his own activity on his notification feed - this is what I want to avoid.
回答1:
The best way to address this is to make your activities unique, once you got that right even if the same activity lands on a feed twice, it will only appear once.
To achieve that, you only need to pass time
and foreign_id
fields when creating activities. For instance, you can set the time
field to the creation time of the activity and the foreign_id
to the ID of the object the activity refers to in your database.
You can find more information about this functionality in the documentation here: http://getstream.io/docs/#uniqueness
Note that if you use any of the framework integration (RoR, Django, Laravel, ...) you get this out of the box.
EDIT: Stream recently introduce configurable discard rules that allow you to ignore certain updates (eg. activities coming "back" to its author feed via a follow relationship). More information is available on the documentation: we just added something called update discard rules, https://getstream.io/docs/#discard-rules
来源:https://stackoverflow.com/questions/35375436/getstream-io-is-there-a-way-to-prevent-activities-from-bouncing-back-to-a-user