🐛 Fixed unable to publish a post after slack hook import

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
This commit is contained in:
kirrg001 2018-06-11 11:08:08 +02:00
parent e4807a779c
commit f943acea58
3 changed files with 4 additions and 3 deletions

View File

@ -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: ''}]);
}
});

View File

@ -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;

View File

@ -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":""}]');
});
});