|
|
@@ -126,39 +126,6 @@ module.exports = function(crowi) {
|
|
|
return text;
|
|
|
};
|
|
|
|
|
|
- // this is called to generate redirect_uri
|
|
|
- slack.getSlackAuthCallbackUrl = function()
|
|
|
- {
|
|
|
- // Web アクセスがきてないと app:url がセットされないので crowi.setupSlack 時にはできない
|
|
|
- // cli, bot 系作るときに問題なりそう
|
|
|
- return (config.crowi['app:url'] || '') + '/admin/notification/slackAuth';
|
|
|
- }
|
|
|
-
|
|
|
- // this is called to get the url for oauth screen
|
|
|
- slack.getAuthorizeURL = function () {
|
|
|
- if (Config.hasSlackWebClientConfig(config)) {
|
|
|
- const slackClientId = config.notification['slack:clientId'];
|
|
|
- const redirectUri = slack.getSlackAuthCallbackUrl();
|
|
|
-
|
|
|
- return `${SLACK_URL}/oauth/authorize?client_id=${slackClientId}&redirect_uri=${redirectUri}&scope=chat:write:bot`;
|
|
|
- } else {
|
|
|
-
|
|
|
- return '';
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // this is called to get access token with code (oauth process)
|
|
|
- slack.getOauthAccessToken = function(code) {
|
|
|
-
|
|
|
- const client = new SlackWebClient();
|
|
|
-
|
|
|
- const clientId = config.notification['slack:clientId'];
|
|
|
- const clientSecret = config.notification['slack:clientSecret'];
|
|
|
- const redirectUri = slack.getSlackAuthCallbackUrl();
|
|
|
-
|
|
|
- return client.oauth.access(clientId, clientSecret, code, {redirect_uri: redirectUri});
|
|
|
- }
|
|
|
-
|
|
|
// slack.post = function (channel, message, opts) {
|
|
|
slack.post = (page, user, channel, updateType, previousRevision) => {
|
|
|
const messageObj = prepareSlackMessage(page, user, channel, updateType, previousRevision);
|