Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How we can implement hashtag like feature using getstream

Tags:

getstream-io

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.

like image 752
Ankesh Kumar Avatar asked Feb 07 '23 11:02

Ankesh Kumar


1 Answers

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.

like image 106
Matthisk Avatar answered Jun 11 '23 02:06

Matthisk