3

I am sending user id(stored in our own DB) as actor while posting activity on getstream. In object field I am sending other info of user such as name/dob etc. which are in our database too.

Suppose some one updates the user info e.g. name in our application, the object will still have old information in the post. How can this scenario be handled in best possible way?

Ankesh Kumar
  • 515
  • 2
  • 17

1 Answers1

1

All activities stored in Getstream are normalized, thus there is no way for you to update usernames stored within activities. Best practice is to not store data directly in the Getstream activity but store a reference to the data inside your own database (as you are doing right now for the actor field).

{
    "actor": "user:$USER_ID"
    "object": "post:$POST_ID"
}

Where $USER_ID is the id of the user in you local database and $POST_ID is the id of the post (this can be any sort of data e.g. comment, post, like) in your local database). You are also allowed to store extra (custom) fields on the Getstream API.

When you use one of Getstream's integration packages you get this functionality for free. You could have a look at these packages to see how they handle this.

Matthisk
  • 1,501
  • 10
  • 20
  • May be I am wrong, but if 100 of activitis of different user are there and we have to show user name alog with activity data, this will require 100 calls to get user info. I am sure getstream have solution for this... – Ankesh Kumar Feb 17 '16 at 09:51
  • After retrieving 100 activities from the Getstream api you could detect all the user ids present on the activities actor fields. With these ids you would create a single DB query to fetch the corresponding users from your local database. Which client are you using? – Matthisk Feb 17 '16 at 15:18
  • I am using Larvel to build the api for my app. – Ankesh Kumar Feb 18 '16 at 04:40
  • @AnkeshKumar Laravel integration does what Matthisk describes out the box, you only need to use the Eloquent activity trait and pretty much everything happens automatically ;) – Tommaso Barbugli Feb 19 '16 at 21:09