GetStream / stream-django

Django Client - Build Activity Feeds & Streams with GetStream.io
https://getstream.io
BSD 3-Clause "New" or "Revised" License
452 stars 80 forks source link

Is there a plan to add reactions? #91

Closed ghost closed 5 years ago

ghost commented 5 years ago

I'm unable to find how to use reactions. Seems like it was forgotten and not added when it was added to stream-python.

tbarbugli commented 5 years ago

You can use the Stream client within Django as well; is there anything you miss on Django for reactions?

ghost commented 5 years ago

Thanks for responding Tom. I saw the example for retrieving a feed with reactions with the py client:

read bob's timeline and include most recent reactions to all activities and their total count client.feed("timeline", "bob").get(reactions={"recent": True, "counts": True})

read bob's timeline and include most recent reactions to all activities and her own reactions client.feed("timeline", "bob").get( reactions={"own": True, "recent": True, "counts": True}, user_id="bob" )

https://getstream.io/docs/python/#reactions_read-feeds

It would appear reactions={} is more just used for optional parameters and reactions should be returned without asking specifically though? I'd think that'd make sense and be a seamless way to get them under their activities.

I'm using the client within django to add them to an activity like:

    stream_client.reactions.add(
        "comment", self.kwargs['postid'], user_id=str(request.user.pk), data={"body": request.data['body']}
    )

but in order to retrieve I was needing:

    feeds = feed_manager.get_feed('cityposts', generate_sub_feed(city, topic))
    activities = feeds.get(reactions={"recent": True, "counts": True})['results']
    enricher = Enrich()
    enriched_activities = enricher.enrich_activities(activities)
    posts = self.serialize_activities(enriched_activities, request)

Something along those lines. Which is not using the client so I was wondering if that was something that would work? I'm still trying to see if it works but so far I haven't found the reactions. I'm still trying to make Stream work with REST as I still have that Django REST backend and the Vue.js front end. I can't just use the python client in Django because eventually the objects have to be serialized and returned from the API. Did I miss something though? I want the whole feed not just the reactions from a feed, so I want my posts and the comments (reactions). I will gladly close this issue if I do find them.

ghost commented 5 years ago

I think I found them doing it the way above... I made a stupid mistake. This one is on me it still got the reactions the same way. Question though I see these parameters are optional but if I don't include reactions={} it gives me nothing. Is there a way to always get all the reactions for each activity? Looks like recent=True only gives 10 per the docs? I thought maybe just giving say count=True so it has that parameter will work, but only if recent=True does it seem to give it to me. Probably just have to read more maybe it's somewhere.