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:
Tom Moor
2018-01-13 10:46:29 -08:00
committed by GitHub
parent 33261ba7c7
commit 9d441fc51a
11 changed files with 121 additions and 15 deletions

View File

@ -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() {