-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A method to add activity using the feed manager #23
Comments
can you elaborate more on the data that you have in your activities? the library can handle serialization and enrichment of Django models, other object can be supported by extending the Enricher class. I can give you some concrete help once I know more about that ;) just for my curiosity, why do you need to use the stream client directly? |
I used the stream client directly because I couldn't find a method on the feed manager to add activities. That was my question. Is there a method on the feed manager to add activities?. user_feed = stream_client.feed("user", request.user.id)
user_feed.add_activity({"actor": request.user.username, "verb": "publish",
"object": "Video:{}".format(instance.id),
"title": instance.title}) Since we don't maintain a model for that action, I tried to use the stream client directly to add activities. |
I think you can take advantage of the library and do something like this: from stream_django.activity import create_reference
from stream_django.feed_manager import feed_manager
user_feed = manager.get_user_feed(request.user.id)
obj_ref = create_reference(instance)
actor_ref = create_reference(request.user)
user_feed.add_activity({"actor": actor_ref, "verb": "publish",
"object": obj_ref,
"title": instance.title}) This is assuming that you have a Video model of course, if not please add some more information about your use case. |
Thank you @tbarbugli. That worked. |
To create my activities, I've been using the raw
client.stream_client
to add activities. But for them to be ready for enrichment, I'm afraid they activity data should have a specific format. Is there a method on the feed manager to do it?. I can't see it anywhere.The text was updated successfully, but these errors were encountered: