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.
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
Related
I have a use-case of retrieving content that is created by a particular user. Whenever I try GETng it, I am getting all the data created by different user.
Scenario 1:
I have an admin user. I created a content type of stock-list with name and description field.
I created 5 rows of data as per stock-list content type.
Scenario 2:
I have another user say testA.
I have created 4 rows of stock-list content by logging in as testA.
Now I wanted to retrieve stock list created by userA. Supposing I have a public endpoint for getting GET /stock-lists, how can I GET that ?
Currently when I am firing GET /stock-lists, I am getting all the data created by admin and testA user combined.
Can anyone help ?
does the stock list have a relationship with a user.if not make a relationship of one user having many stocks then you can make a query by finding all the stocks with a specific user.
Let's say I want to build a system where each user has access to a notification feed and an aggregated feed, with the following groups:
user as flat feed
hashtag as flat feed
notification as notification feed
timeline as aggregated feed
We also have the following relations:
user:b follows hashtag:a
user:b follows user:a
Now consider the following situation:
If user A posts with hashtag A, I would like user B to get an activity in its notification feed (thanks to relation 1). But I also would also like all followers of user A to see in their timeline that user A did something. Then, user B will get the activity in its notification feed, and in its timeline (because of relation 2): there is a duplicate.
Is there a way to avoid this situation ?
A naive way would be to manually filter the feed and prune the aggregated activities we do not want to see. But this of course seems non optimal.
Thank you very much!
You can use discard rules to avoid activities matching one of rule from getting added to a follower's feed.
This is usually something you use to avoid own activities from showing up in your notification feed.
Here's the link to the docs on Discard Rules:
https://getstream.io/docs/#discard-rules
In examples on the Get stream Website, I see that they show examples where users are following other users and then they get to see the posts of the user they are following. How can I change this and make it so that users can follow a category(s) instead of a user and then see posts on their feed from the category(s) they are following? Currently, when I make a new post, I add a custom field to capture category id. Not sure what to do next.
I'm using the Get Stream for Laravel.
In Stream a feed can represent anything. So it can be a user, or a timeline (wall) or a category. Simply create a feed for the category and add the activities to it with the TO field. Then your user can follow the category feed.
More information about this can be found on the official docs: https://getstream.io/docs/#targetting
I'm building an activity feed application, where a user can like/comments on each activity feed. I went through GetStream.io documentation and looks like I'll have to send the activity with object ids.
{
id:"ef696c12-69ab-11e4-8080-80003644b625",
actor:"User:1",
object:"Comment:12",
started_at:"2014-11-11T15:06:16+01:00",
target:"Feed:100",
time:"2014-11-11T14:06:30.494",
verb:"add"
}
User:1 and Feed:12 are the objects in my application database? Does it mean that, while retrieving activities, I'll have to hit my database to retrieve the complete feeds?
Say the Feed:12 had few likes and comments earlier from other users. How do I get the complete set of likes/comments on user timeline feed?
What if I want to customize the view, say I want to show all users (image, name, the profile like etc) along with comment with timestamp similar to FB? Do I need to send these attributes as additional parameters for each feed?
Thanks,
Yes, when you fetch a feed from Stream and we give you back these references like user:1 or comment:12, we expect that you'd "enrich" those details from your database.
Typically what our users do is track the name of the model (eg, user) and the user_id (eg, 1). When you get the feed and put it into a hash map, you'll iterate over the activities, pull out all of the actor attributes, and do a single lookup like select * from user where id in (1,3,5,6,9,12) so that you're only hitting your database one time for all user objects or all comment objects or whatever. Then, replace those activities in your hash map so now you'd have actor: <object for User 9> and any other attributes you'd need for your UI presentment.
Then do the same for other references you pass in the activity, and so on.
Things we DON'T recommend are putting in string references for things that could change on your side. For example, if you had actor: "user:ian" instead of my user_id, if I ever change my username later then things probably wouldn't work properly on your side.
User1 follows feed1 and feed2. Activity1 is added to both feeds (image user follows 2 playlists and the same song was added to both playlists at the same time because these are system playlists by genres).
What happens then? Will user1 see two records in his timeline? song1 is added to feed1 and song1 is added to feed2?
uniqueness is determined based on the foreign_id and time field. If you specify both these fields, Stream will understand uniqueness and you'll only see the activity once.
Note this only works if the activity is identical. If you need to group similar activities, aggregated feeds will work well.