Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store current user in SQLAlchemy session so activity hook can get it
Up until now, the activity stream session extension used the revision property of the session to get the user performing the action. With the revisions gone we need to find an alternative. The `session.revision.user` property was set after a revision was explicitly created in an action, and its `author` property set (by way of [1]): rev = model.repo.new_revision() rev.author = user So it makes sense to attached the user performing an action when the actions happen. But rather than have to call it explicitly on each action that has activities as above, this change adds a unique function in ckan.logic.get_action that uses the value in the `context` object. These can be provided by users but most of the time they are prepolutated with the following defaults: model, model.Session and c.user. The main drawback of this is that if extensions import and call core action functions directly activites will get registered as a Non logged in user. This is discouraged but it was quite common before chained actions were introduced (and is still used now). To support this situation we should add the call to set the user in the session in all actions that have activities, like it was done before with the revisions. [1] https://github.com/ckan/ckan/blob/42596a014a713f9787d4ee9167f4c51afaaefaa6/ckan/model/__init__.py#L436
- Loading branch information
8c02842
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️