Fixed page actions events stored as posts

- this was due to the fact that we use the same model for pages as we do
  for posts, so the hardcoded `post` key was not accurate
- this commit adds support for providing a function to return the key for the
  action type
This commit is contained in:
Daniel Lockyer 2022-08-18 14:07:04 +02:00
parent 9fda97550d
commit bde9b84221
No known key found for this signature in database
GPG Key ID: D21186F0B47295AD
2 changed files with 10 additions and 2 deletions

View File

@ -23,11 +23,17 @@ module.exports = function (Bookshelf) {
return;
}
let resourceType = this.actionsResourceType;
if (typeof resourceType === 'function') {
resourceType = resourceType.bind(this)();
}
// @TODO: implement context
return {
event: event,
resource_id: this.id || this.previous('id'),
resource_type: this.actionsResourceType,
resource_type: resourceType,
actor_id: actor.id,
actor_type: actor.type
};

View File

@ -39,7 +39,9 @@ Post = ghostBookshelf.Model.extend({
tableName: 'posts',
actionsCollectCRUD: true,
actionsResourceType: 'post',
actionsResourceType: function () {
return this.get('type');
},
/**
* @NOTE