mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Fixed Slack service throwing error when post is empty
fixes #11694 - if the post contained no body, the `.replace` would throw an error - converted to an if-statement instead of doing `|| ''` because there would be a floating full-stop
This commit is contained in:
parent
4f01bb34f9
commit
8f935fe8ae
1 changed files with 10 additions and 1 deletions
|
@ -28,6 +28,7 @@ function ping(post) {
|
||||||
let message,
|
let message,
|
||||||
title,
|
title,
|
||||||
author,
|
author,
|
||||||
|
description,
|
||||||
slackData = {},
|
slackData = {},
|
||||||
slackSettings = getSlackSettings(),
|
slackSettings = getSlackSettings(),
|
||||||
blogTitle = settingsCache.get('title');
|
blogTitle = settingsCache.get('title');
|
||||||
|
@ -37,6 +38,14 @@ function ping(post) {
|
||||||
message = urlService.getUrlByResourceId(post.id, {absolute: true});
|
message = urlService.getUrlByResourceId(post.id, {absolute: true});
|
||||||
title = post.title ? post.title : null;
|
title = post.title ? post.title : null;
|
||||||
author = post.authors ? post.authors[0] : null;
|
author = post.authors ? post.authors[0] : null;
|
||||||
|
|
||||||
|
if (post.custom_excerpt) {
|
||||||
|
description = post.custom_excerpt;
|
||||||
|
} else if (post.html) {
|
||||||
|
description = `${post.html.replace(/<[^>]+>/g, '').split('.').slice(0, 3).join('.')}.`
|
||||||
|
} else {
|
||||||
|
description = null;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
message = post.message;
|
message = post.message;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +86,7 @@ function ping(post) {
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
title: 'Description',
|
title: 'Description',
|
||||||
value: post.custom_excerpt ? post.custom_excerpt : `${post.html.replace(/<[^>]+>/g, '').split('.').slice(0, 3).join('.')}.`,
|
value: description,
|
||||||
short: false
|
short: false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue