Search code examples
pythondjangodjango-notificationactivity-streams

Anonymous actors in activity streams


I'm working with a system that has a number of notifications around the creation of items within groups and am trying to model anonymous actors in notifications.

Consider the contrived example:

A Book belongs to a Library, and I am a user of the library interested in books in a particular topic. The library keeps me informed of when books of a certain topic are checked out, but for security reasons doesn't let me know who checked it out.

The activity stream for this would be:

A patron (actor) checked out (verb) the book "Learning Python, 5th Edition" (object) in the subject "Computer books" (target).

The problem here is that "A patron" isn't an entity in my database, particularly in my case, Django-notifications requires an actor, and that that actor be a instance of a model. But in this case there is no "actor" as such.

Is there a better way to write this activity stream? Is there a way to write it that doesn't involve putting a fake actor into the database?


Solution

  • You decide how to represent the notifications. You could save these type of notifications like that:

    "Learning Python, 5th Edition" (actor) was checked out (verb) by a patron in the subject "Computer books" (target)

    If you see closer - in that way, your patron becomes an action object if it was a real entity. But saving it in this way it doesn't mean that it should be represented in that way. You could render this in the template as you want.

    One note from the docs where if you replace query with render you will get my point:

    Actions are generated in a manner independent of how you wish to query them so they can be queried later to generate different streams based on all possible associations.