mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 20:03:12 +03:00
🎨 Allow any Slack-compatible webhook URLs in Slack app
closes https://github.com/TryGhost/Ghost/issues/9246, closes https://github.com/TryGhost/Ghost/issues/7856 - allow any valid URL in the slack webhook input - update slack app description to mention Slack-compatible services including Discord and Mattermost
This commit is contained in:
parent
5b932c5c58
commit
d028b5a5b9
@ -34,7 +34,7 @@
|
||||
<div class="gh-setting">
|
||||
<div class="gh-setting-content">
|
||||
<div class="gh-setting-title">Webhook URL</div>
|
||||
<div class="gh-setting-desc">Automatically send newly published posts to a channel in Slack</div>
|
||||
<div class="gh-setting-desc">Automatically send newly published posts to a channel in Slack or any Slack-compatible service like Discord or Mattermost.</div>
|
||||
<div class="gh-setting-content-extended">
|
||||
{{#gh-form-group errors=model.errors hasValidated=model.hasValidated property="url"}}
|
||||
{{gh-input model.url name="slack[url]" update=(action "updateURL") onenter=(action "save") focusOut=(action "triggerDirtyState") placeholder="https://hooks.slack.com/services/..." data-test-slack-url-input=true}}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import BaseValidator from './base';
|
||||
import {isBlank} from '@ember/utils';
|
||||
|
||||
export default BaseValidator.create({
|
||||
properties: ['url'],
|
||||
@ -7,9 +8,8 @@ export default BaseValidator.create({
|
||||
let url = model.get('url');
|
||||
let hasValidated = model.get('hasValidated');
|
||||
|
||||
let urlRegex = new RegExp(/(^https:\/\/hooks\.slack\.com\/services\/)(\S+)/);
|
||||
|
||||
if (!validator.empty(url) && !url.match(urlRegex)) {
|
||||
// eslint-disable-next-line camelcase
|
||||
if (!isBlank(url) && !validator.isURL(url, {require_protocol: true})) {
|
||||
model.get('errors').add(
|
||||
'url',
|
||||
'The URL must be in a format like https://hooks.slack.com/services/<your personal key>'
|
||||
|
@ -47,7 +47,8 @@ describe('Unit: Validator: slack-integration', function () {
|
||||
let validUrls = [
|
||||
'https://hooks.slack.com/services/;alskdjf',
|
||||
'https://hooks.slack.com/services/123445678',
|
||||
'https://hooks.slack.com/services/some_webhook'
|
||||
'https://hooks.slack.com/services/some_webhook',
|
||||
'https://discordapp.com/api/webhooks/380692408364433418/mGLHSRyEoUaTvY91Te16WOT8Obn-BrJoiTNoxeUqhb6klKERb9xaZkUBYC5AeduwYCCy/slack'
|
||||
];
|
||||
|
||||
validUrls.forEach(function (url) {
|
||||
|
Loading…
Reference in New Issue
Block a user