Git Product home page Git Product logo

Comments (5)

justquick avatar justquick commented on June 13, 2024

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.

goldan avatar goldan commented on June 13, 2024

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.

justquick avatar justquick commented on June 13, 2024

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.

justquick avatar justquick commented on June 13, 2024

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.

pknowles avatar pknowles commented on June 13, 2024

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)

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.