Related items in an activity feed

I am creating an activity feed app where user can like / comments for each activity feed. I have looked at the GetStream.io documentation and it looks like I will need to send an 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 this mean that when fetching actions, I have to hit my database to get full feeds?

  • Say you Feed:12

    had multiple comments and comments from other users. How can I get the complete set of comments / comments for a feed in a user's history?

  • What if I want to customize the view, say that I want to show all users (image, name, profile, etc.) along with a comment with a timestamp like FB? Do I need to send these attributes as additional parameters for each feed?

One level of nested comments for each feed activity such as FB

Thank,

+3


source to share


1 answer


Yes, when you get a feed from a Stream and we return those links like user:1

or comment:12

, we expect you to "enrich" that data from your database.

Usually our users keep track of the model name (for example user

) and user_id (for example 1

). When you get a feed and put it into a hashmap, you will iterate over all the actions, pull out all the attributes, actor

and do one search, for example select * from user where id in (1,3,5,6,9,12)

, so that you only hit your database time for all custom objects or all comment objects or whatever. Then replace those actions in your hashmap so that you now have actor: <object for User 9>

any other attributes you need for your UI view.



Then do the same for the other links you pass in this operation, etc.

Things we DO NOT recommend, put inline references for things that might change on your side. For example, if I had actor: "user:ian"

my user_id instead, if I ever change my username later, it probably won't work correctly on your side.

+1


source







All Articles