Pierre LEMIERE
Pierre LEMIERE

Reputation: 23

Best way to create private and public feed

I am a novice in getStream.io and I want that every user of my application get a private feed where he will find his activities, and he get a public feed where he will find his activities and friend's activities.

To do it, I created one feed (the private one) for each user in the group user then I added activities to their feed.

After for each user I created a feed (the public ones) in the group timeline and this feed follows the user associated to see his activities in the public feed (like Facebook, Instagram, Twitter...).

I researched a lot on the community to know if it is the best way to do private and public feed for each user but I read it was bad to follow himself in his timeline. I put my code here :`

# Initialize the client with your api key and secret
client = stream.connect('YOUR_API_KEY', 'API_KEY_SECRET')
# For the feed group 'user' and user id 'user1' get the feed
user1_feed = client.feed('user', 'user1') #User1's feed
# Add the activity to the feed
user1_feed.add_activity({'actor': 'user1', 'verb': 'tweet', 'object': "user1a1", 'tweet': 'Hello world It s me user1', 'likes': 0})  #user1a1
user1_feed.add_activity({'actor': 'user1', 'verb': 'watch', 'object': "user1a2", 'youtube_id': 'W9GvhL53nyw', 'likes': 0})        #user1a2

# The same with 'user2'
user2_feed = client.feed('user', 'user2') #User1's feed
user2_feed.add_activity({'actor': 'user2', 'verb': 'tweet', 'object': "user2a1", 'tweet': 'Hello world It s me user2', 'likes': 0})  #user2a1
user2_feed.add_activity({'actor': 'user2', 'verb': 'watch', 'object': "user2a2", 'youtube_id': 'PoxLSUh7pYw', 'likes': 0})        #user2a2

user1_timeline = client.feed('timeline', 'user1') #User1's timeline
user2_timeline = client.feed('timeline', 'user2') #User2's timeline

user1_timeline.follow('user','user1') #user1_timeline follows user1
user1_timeline.follow('user','user2') #user1_timeline follows user2

user2_timeline.follow('user','user2') #user2_timeline follows user2
user2_timeline.follow('user','user1') #user2_timeline follows user1

`

And I don't want to create duplicates, if I understand the Documentation, the group timeline just display.

So I would like to know if my method was the best way to create private and public feed.

Thanks! Pierre.

Upvotes: 2

Views: 521

Answers (1)

Dwight Gunning
Dwight Gunning

Reputation: 2525

Your understanding is spot on and the sample looks correct and will behave as you've described.

The user1 feed will contain only the "personal" activities of User 1. Your application may restrict access, such that only User 1 can if your features and UX calls for it. The activities aren't 'private' as they may have been copied into other users' user_timeline feeds if there is a following relationship.

The user1_timeline feed will combine the activities that User 1 added to their user feed (due to the follow relationship created in your sample) as well as activities from other users' 'user' feeds that have been followed.

Upvotes: 1

Related Questions