Comments (5)
hey, great use case. activity-stream should allow this but im not sure how. actor, target and action_object are all generic foreign keys meaning that what they reference must be defined in the db someplace. if the actor is anonymous you'd still have to create some intermediate model (maybe based on ip or uuid) to reference in the Action. in that case it is probably best to just go ahead and create a proper User object for anonymous users when they create an action. maybe activity-stream should implement this option?
from django-activity-stream.
As far as I see, target and action_object can be blank, though they are generic foreign keys. So a simple solution (without storing IPs) would be to just allow actor_content_type and actor_object_id be blank, implying "None = anonymous" for actor. This would eliminate errors when I pass request.user to action.send and it fails because the user is anonymous (and does not contain _meta, needed in get_for_model function). I've created a patch here: https://bitbucket.org/goldan/django-activity-stream/changeset/bfadb06f7778 (sorry for the blank lines, they're modified automatically by my editor).
As for IPs, I don't think that activity-stream should create any User objects, since it's rather a generic app, not bound to User model. I think there should exist a separate app for managing anonymous users (I believe it does), so using such an app, one would just pass an CustomAnonymousUser or whatever object to activity-stream and store his actions without any problem.
from django-activity-stream.
thats fine for actions where the target or action objects are anonymous but what about when an anonymous user is the actor (eg 'anonymous user liked your blog')? actor is required and therefore has to be a model someplace to complete the generic foreign key relationship. your patch just fails silently in this case
from django-activity-stream.
after a lot of thinking ive decided that the activity streams only apply to registered users (User instances). If you wish to track anonymous users' actions then consider making temporary User instances or something like django-social-auth
from django-activity-stream.
Is there anything wrong with just allowing a null actor? For example,
#in action_handler (pls excuse compact code)
if actor is None and not settings.ALLOW_NULL_ACTOR:
raise Exception(...)
...
actor_content_type = ContentType.objects.get_for_model(actor) if actor is not None else None,
actor_object_id = actor.pk if actor is not None else 0,
from django-activity-stream.
Related Issues (20)
- Verb examples do not match spec
- django 4.0 support HOT 5
- django-activity-stream and django-comments-xtd HOT 2
- Activity Stream 2 JSON Feeds HOT 2
- AS2 paging
- DRF support HOT 3
- Use pluggy for customization report
- Installation breaks with pip -r HOT 2
- Django -activity stream HOT 1
- Missing migration when moving from Django 2.2 to 3.2 HOT 1
- Not working with Django 4.1 HOT 9
- Release new version HOT 1
- Filter user feed with distinct('action_object') HOT 1
- [Feature proposal] Delete Follow objects when the followed object is deleted? HOT 1
- Remove usage of `datetime_safe` HOT 4
- Field 'actor' does not generate an automatic reverse relation and therefore cannot be used for reverse querying. If it is a GenericForeignKey, consider adding a GenericRelation. HOT 4
- [Feature request ] Soft delete for action
- Registering models from third-party apps HOT 1
- Make a 2.0 release and publish to PyPI HOT 4
- Add multidatabase support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-activity-stream.