fix: Slack notification not sent on publish, reported via Spectrum

This commit is contained in:
Tom Moor 2019-08-28 00:22:22 -07:00
parent 5bd2409e39
commit c60295fcca

View File

@ -58,15 +58,23 @@ export default class Slack {
async documentUpdated(event: DocumentEvent) {
// lets not send a notification on every autosave update
if (event.data && event.data.autosave) return;
if (
event.name === 'documents.update' &&
event.data &&
event.data.autosave
) {
return;
}
// lets not send a notification on every CMD+S update
if (event.data && !event.data.done) return;
if (event.name === 'documents.update' && event.data && !event.data.done) {
return;
}
const document = await Document.findByPk(event.documentId);
if (!document) return;
// never send information on draft documents
// never send notifications for draft documents
if (!document.publishedAt) return;
const integration = await Integration.findOne({