Search code examples
getstream-io

GetStream: Prevent adding the same activity in flat-feed


I'm using a flat-feed, to be able to follow and unfollow other profiles. But as i see it, i want to group the verbs as it is possible in the aggregated-feed.

Because i want to aggregate likes to the same activity.

user2 and user3, likes image1.

user1 follow user2 and user3.

Meaning that user1 now have two activities, of users liking the same image and i want it to be displayed as one activity.

Should i handle this myself by sorting it with the foreign key and then collect the activities into one? Or can i somehow blend the flat-feed with aggregated-feed?

This How to build a news feed with aggregate and flat types? is similar, but i need to be able to follow and unfollow.


Solution

  • After finding out that i could combine flat-feed and aggregated-feed i came up with this setup:

    In this example beneath, User2 is publishing an artwork, meaning that User2-feed now includes an activity that shows his artworks. Shortly after User3 likes his newly posted artwork, meaning that User3-feed now include an activity that shows his like of the artwork. User1 is following User2-feed and User3-feed which create User1-aggregatedfeed that include all activities from the two feeds, that User1 is currently following. It means that User1’s own activity will not being shown in his own User1-aggregatedfeed unless he is following his own feed, which isn’t possible. The same artwork that is added to User2-feed is also added to Artist1-feed because the artist of the artwork is Artist1. Meaning that the same artwork is now added to two feeds that User1 is following. But activity will only be added to User1-aggregatedfeed once, because we store the “artwork publish” activity with the same foreign key.

    Flat-feed combined with aggregated-feed example