Reputation: 11
Using Laravel and getStream.
Current structure:
A User has a feed on their dashboard which is a merge of FeedManager::getNewsFeeds($request->user()->id)['timeline’];
&& FeedManager::getUserFeed($request->user()->id);
This works fine however ‘double ups’ of activities occur when we’re trying to do a ‘became friends’ activity.
If Joe follows Jane he will see
Jane is now friends with Joe
Joe is now friends with Jane
Ideally: We'd just have Joe is now friends with Jane
and if the current user is Joe adjust it to You are now friends with Jane
Same also happens if Joe follows Sam and Peter, and they then become friends.
Joe’s feed:
Sam is now friends with Peter
Peter is now friends with Sam
Ideally: We'd get Sam and Peter are now friends
(order doesn't really matter)
What is the best way to do this kind of tracking (or filtering) with getStream?
(Is their a singular Activity that references to both users?)
Upvotes: 0
Views: 87
Reputation: 4326
Since you're pulling each feed separately, and since we don't have an understanding of what your actor/verb/object means, it isn't possible for Stream to de-duplicate or rename these events since you're already merging them together. You'd likely be sending us a unique id for 'Joe' already, so you'd need a logic check on your side to say something like (pseudo-code):
$bits = $activity->actor.split(":");
$activity_user = get_user_details($bits[1]);
$actor_is = $activity_user->name . " is";
if ($user->id == $activity_user->id) {
$actor_is = "You are";
}
$output = $actor_is . " now following ...";
We don't allow filtering on activity data when fetching a feed's activities. Our filtering rules are more about pagination.
Upvotes: 2