mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
closes #6584 - Frontend Changes: - adds 'Apps' to Navigation Menu - adds 'Slack' as nested page to Apps - adds `apps.css` - adds `slack-integration` model and uses `slack-settings` custom transform to parse JSON file - adds validation for `slack` model - adds fixtures and `slack/test` API endpoint to Mirage - adds acceptance tests for `apps-test` and `slack-test` - adds unit tests for `slack-settings` and `slack-integration` - Backend Changes: - adds API endpoint `slack/test` to send Test Notification - adds default-values for slack model - sends payload to slack: - text: the url of the blogpost / test message - icon_url: url to ghost logo - username: Ghost - adds `slack/index.js` to send webhook to slack if - a new post is published (if slack webhook url is saved in settings) - user clicks on 'Send Test Notification' in UI - adds `slack.init()` to `server.index.js` to add event listener - adds unit test for `slack/index`
24 lines
653 B
JavaScript
24 lines
653 B
JavaScript
import BaseValidator from './base';
|
|
|
|
export default BaseValidator.create({
|
|
properties: ['url'],
|
|
|
|
url(model) {
|
|
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)) {
|
|
model.get('errors').add(
|
|
'url',
|
|
'The URL must be in a format like ' +
|
|
'https://hooks.slack.com/services/<your personal key>'
|
|
);
|
|
|
|
this.invalidate();
|
|
}
|
|
|
|
hasValidated.addObject('url');
|
|
}
|
|
});
|