mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 21:40:39 +03:00
Added added and deleted events to member model
no-issue These can be used to trigger webhooks
This commit is contained in:
parent
df8a67a9ca
commit
94b261759e
@ -1,7 +1,24 @@
|
||||
const ghostBookshelf = require('./base');
|
||||
|
||||
const Member = ghostBookshelf.Model.extend({
|
||||
tableName: 'members'
|
||||
tableName: 'members',
|
||||
|
||||
emitChange: function emitChange(event, options) {
|
||||
const eventToTrigger = 'member' + '.' + event;
|
||||
ghostBookshelf.Model.prototype.emitChange.bind(this)(this, eventToTrigger, options);
|
||||
},
|
||||
|
||||
onCreated: function onCreated(model, attrs, options) {
|
||||
ghostBookshelf.Model.prototype.onCreated.apply(this, arguments);
|
||||
|
||||
model.emitChange('added', options);
|
||||
},
|
||||
|
||||
onDestroyed: function onDestroyed(model, options) {
|
||||
ghostBookshelf.Model.prototype.onDestroyed.apply(this, arguments);
|
||||
|
||||
model.emitChange('deleted', options);
|
||||
}
|
||||
});
|
||||
|
||||
const Members = ghostBookshelf.Collection.extend({
|
||||
|
Loading…
Reference in New Issue
Block a user