I want to create functionality similar to hashtags on Twitter with the Getstream.io API. Users will post messages to their own flat feeds with certain hashtags. Then I want to be able to filter all activities based on a certain hashtag.
You have to think of a hashtag as a separate feed. Every hashtag is a topic feed with all activities posted with that specific identifier in their object. Thus to achieve this behavior with Getstream we need to create a feed group that can store feeds for all hashtags (or topics). Often such a feed group is called topic
but you could also name it hashtag
(create new feed groups on the getstream.io dashboard). Now we need to be able to send activities to their corresponding topic feeds when posted to a users' flat feed. For this we can use the to field of activities. When a user posts an activity with hashtag computers
in the message we will create the following activity on the users flat feed:
{
"actor": "user:1",
"object": "I love #computers ^^"
"verb": "tweet",
"to": ["topic:computers"]
}
The to
field will make sure the activity is also added to the topic feed and distributed to all the followers of this topic feed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With