Code Monkey home page Code Monkey logo

Comments (3)

tbarbugli avatar tbarbugli commented on May 25, 2024

Perhaps it is easier to get the API client from the manager and perform the follow/unfollow directly?

from stream-django.

murdav avatar murdav commented on May 25, 2024

Thanks @tbarbugli for replying! It depends, currently I'm using the above-mentioned workflow and it works like a charm!
For me it would be easier like this, otherwise I should do something like:

        user_feed = feed_manager.get_feed('timeline', instance.user_id)
        user_feed.follow('my_custom_flat_feed', target_unique_id)
        user_feed = feed_manager.get_feed('timeline_aggregated', instance.user_id)
        user_feed.follow('my_custom_flat_feed', target_unique_id)

Basically the same is here https://github.com/GetStream/stream-django/blob/master/stream_django/managers.py#L54

Furthermore https://github.com/GetStream/stream-django/blob/master/stream_django/managers.py#L24 already supports the param.

Am I right?

Thanks once again,

D

from stream-django.

 avatar commented on May 25, 2024

@murdav This may be a potential solution to the concept of following other objects. I came up with this and I think it ultimately achieves at least what I am looking for. Still doing some verification though too. Instead of creating a direct "follow" relationship between two objects, i.e. one user feed follows another, my scenario is more about a feed to one unique object. The problem with letting a user try to follow one object is obviously it is one instance on a greater feed unlike as mentioned for a user those are actually full feeds. Your use case and needs could be different than what I understand, however here's mine:

What I think I'll do for my solution is make a "follow" button where they can hit that on one post. That post id is sent to the API. In the API I'll take that postid and do a lookup using the get_activities method. Once I have that post activity I can then look up the user's timeline that I want the post to live on (be followed on). Once I have that I discovered there's a method to add that object to the user's feed or timeline.

    # Add post they hit "follow" on as post that is in their timeline
    post = stream_client.get_activities(ids=[self.kwargs['postid']])['results'][0]
    user1timeline = stream_client.feed('timeline', str(request.user.pk))
    user1timeline.add_activity(post)

Now I have the post the user wanted to follow or keep track of on their user timeline. I see there is also a remove activity so I suppose if you want to also make an unfollow button somewhere you can also remove it. For my purposes I may ultimately just not have that because since it's on a one object basis eventually it will go out of scope and no longer need to be modified.

from stream-django.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.