From f943acea58b1840f04081f3ba062bc762b5b744a Mon Sep 17 00:00:00 2001 From: kirrg001 <katharina.irrgang@googlemail.com> Date: Mon, 11 Jun 2018 11:08:08 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20unable=20to=20publish=20?= =?UTF-8?q?a=20post=20after=20slack=20hook=20import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no issue - reported here: https://forum.ghost.org/t/issues-with-unconfigured-slack-new-post-fails-with-can-not-find-property-url-of-undefined/1569 - the value of the slack settings was incorrect - introduced in 1.24.1 - this adds a protection for invalid slack settings values - this adds the correct code - furthermore: in the next minor we will add a small migration script to correct any affected incorrect slack settings values --- core/server/data/importer/importers/data/settings.js | 2 +- core/server/services/slack.js | 3 ++- core/test/integration/data/importer/importers/data_spec.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/server/data/importer/importers/data/settings.js b/core/server/data/importer/importers/data/settings.js index d9c068146b..4565c47ff9 100644 --- a/core/server/data/importer/importers/data/settings.js +++ b/core/server/data/importer/importers/data/settings.js @@ -62,7 +62,7 @@ class SettingsImporter extends BaseImporter { // CASE: we do not import slack hooks, otherwise it can happen very fast that you are pinging someone's slack channel if (obj.key === 'slack') { - obj.value = ''; + obj.value = JSON.stringify([{url: ''}]); } }); diff --git a/core/server/services/slack.js b/core/server/services/slack.js index e91b47b43d..d4653046d4 100644 --- a/core/server/services/slack.js +++ b/core/server/services/slack.js @@ -32,8 +32,9 @@ function ping(post) { } else { message = post.message; } + // Quit here if slack integration is not activated - if (slackSettings.url && slackSettings.url !== '') { + if (slackSettings && slackSettings.url && slackSettings.url !== '') { // Only ping when not a page if (post.page) { return; diff --git a/core/test/integration/data/importer/importers/data_spec.js b/core/test/integration/data/importer/importers/data_spec.js index 1e95826866..619ab08914 100644 --- a/core/test/integration/data/importer/importers/data_spec.js +++ b/core/test/integration/data/importer/importers/data_spec.js @@ -1891,7 +1891,7 @@ describe('Import (new test structure)', function () { it('does not import slack hook', function () { return models.Settings.findOne(_.merge({key: 'slack'}, testUtils.context.internal)) .then(function (response) { - response.attributes.value.should.eql(''); + response.attributes.value.should.eql('[{"url":""}]'); }); });