Webhook / Integration Event bus (#499)
* First bash at an event bus for webhooks and integrations * Refactoring * poc * Revert too wide ranging changes Move to two-queues
This commit is contained in:
@ -7,6 +7,7 @@ import Plain from 'slate-plain-serializer';
|
||||
|
||||
import isUUID from 'validator/lib/isUUID';
|
||||
import { DataTypes, sequelize } from '../sequelize';
|
||||
import events from '../events';
|
||||
import parseTitle from '../../shared/utils/parseTitle';
|
||||
import Revision from './Revision';
|
||||
|
||||
@ -204,6 +205,20 @@ Document.searchForUser = async (
|
||||
return _.sortBy(documents, doc => ids.indexOf(doc.id));
|
||||
};
|
||||
|
||||
// Hooks
|
||||
|
||||
Document.addHook('afterCreate', model =>
|
||||
events.add({ name: 'documents.create', model })
|
||||
);
|
||||
|
||||
Document.addHook('afterDestroy', model =>
|
||||
events.add({ name: 'documents.delete', model })
|
||||
);
|
||||
|
||||
Document.addHook('afterUpdate', model =>
|
||||
events.add({ name: 'documents.update', model })
|
||||
);
|
||||
|
||||
// Instance methods
|
||||
|
||||
Document.prototype.getSummary = function() {
|
||||
|
Reference in New Issue
Block a user