0

I am using the high-level stream-rails ROR client for Stream to create a notifications section on my web app, specifically for friend requests.

I understand that when an AR model instance of something like a FriendRequest model is created, it is stored in the feed as an activity. However, I would also like an activity to be added to the feed when that FriendRequest instance is modified (ex. updating an attribute). Is there a way to do this?

1 Answers1

0

Your approach could differ based on what you're updating in the activity. Normally you'd send us a foreign_id and object_id that points at the object in your database. You can certainly send metadata in the activity itself of course. If it's something changing that isn't already in the activity payload then the enrichment should take care of it by pulling your update out of the database later when you fetch the feed.

If it IS metadata within the activity: save the same activity data (with whatever updated metadata you want to track) with the same foreign_id and timestamp (you could also track an updated date in a metadata field if that's important). Our addActivity API call acts as an upsert as long as the foreign_id and timestamp are the same as before and will overwrite your previous activity with any new data.

iandouglas
  • 4,146
  • 2
  • 33
  • 33