Просмотр исходного кода

Merge pull request #4143 from weseek/feat/4836-respond-slack-reviews

Feat/4836 respond slack reviews
Yuki Takei 4 лет назад
Родитель
Сommit
2f33de4ab6

+ 1 - 0
packages/slack/src/index.ts

@@ -29,3 +29,4 @@ export * from './utils/post-ephemeral-errors';
 export * from './utils/reshape-contents-body';
 export * from './utils/reshape-contents-body';
 export * from './utils/slash-command-parser';
 export * from './utils/slash-command-parser';
 export * from './utils/webclient-factory';
 export * from './utils/webclient-factory';
+export * from './utils/required-scopes';

+ 3 - 3
packages/slack/src/utils/check-communicable.ts

@@ -4,6 +4,7 @@ import { WebClient } from '@slack/web-api';
 
 
 import { generateWebClient } from './webclient-factory';
 import { generateWebClient } from './webclient-factory';
 import { ConnectionStatus } from '../interfaces/connection-status';
 import { ConnectionStatus } from '../interfaces/connection-status';
+import { requiredScopes } from './required-scopes';
 
 
 /**
 /**
  * Check whether the HTTP server responds or not.
  * Check whether the HTTP server responds or not.
@@ -45,11 +46,10 @@ const testSlackApiServer = async(client: WebClient): Promise<any> => {
 
 
 const checkSlackScopes = (resultTestSlackApiServer: any) => {
 const checkSlackScopes = (resultTestSlackApiServer: any) => {
   const slackScopes = resultTestSlackApiServer.response_metadata.scopes;
   const slackScopes = resultTestSlackApiServer.response_metadata.scopes;
-  const correctScopes = ['commands', 'team:read', 'chat:write'];
-  const isPassedScopeCheck = correctScopes.every(e => slackScopes.includes(e));
+  const isPassedScopeCheck = requiredScopes.every(e => slackScopes.includes(e));
 
 
   if (!isPassedScopeCheck) {
   if (!isPassedScopeCheck) {
-    throw new Error('The scopes is not appropriate. Required scopes is [\'commands\', \'team:read\', \'chat:write\']');
+    throw new Error(`The scopes you registered are not appropriate. Required scopes are ${requiredScopes}`);
   }
   }
 };
 };
 
 

+ 1 - 0
packages/slack/src/utils/required-scopes.ts

@@ -0,0 +1 @@
+export const requiredScopes: string[] = ['commands', 'team:read', 'chat:write', 'channels:history', 'groups:history', 'im:history', 'mpim:history'];

+ 3 - 3
packages/slackbot-proxy/src/controllers/slack.ts

@@ -336,11 +336,11 @@ export class SlackCtrl {
         + '<h1>Congratulations!</h1>'
         + '<h1>Congratulations!</h1>'
         + '<p>GROWI Bot installation has succeeded.</p>'
         + '<p>GROWI Bot installation has succeeded.</p>'
         + '<div class="d-inline-flex flex-column">'
         + '<div class="d-inline-flex flex-column">'
-        + `<a class="btn btn-outline-primary mb-3" href="${appPageUrl}">`
+        + `<a class="mb-3" href="${appPageUrl}">`
         + 'Access to Slack App detail page.'
         + 'Access to Slack App detail page.'
         + '</a>'
         + '</a>'
-        + '<a class="btn btn-outline-primary" href="https://docs.growi.org/en/admin-guide/management-cookbook/slack-integration/official-bot-settings.html">'
-        + 'How to set up ?'
+        + '<a class="btn btn-outline-success" href="https://docs.growi.org/en/admin-guide/management-cookbook/slack-integration/official-bot-settings.html">'
+        + 'Getting started'
         + '</a>'
         + '</a>'
         + '</div>'
         + '</div>'
         + '</body></html>');
         + '</body></html>');

+ 2 - 9
packages/slackbot-proxy/src/controllers/top.ts

@@ -2,6 +2,7 @@ import {
   Controller, Get, Inject, View,
   Controller, Get, Inject, View,
 } from '@tsed/common';
 } from '@tsed/common';
 
 
+import { requiredScopes } from '@growi/slack';
 import { InstallerService } from '~/services/InstallerService';
 import { InstallerService } from '~/services/InstallerService';
 
 
 const isOfficialMode = process.env.OFFICIAL_MODE === 'true';
 const isOfficialMode = process.env.OFFICIAL_MODE === 'true';
@@ -18,15 +19,7 @@ export class TopCtrl {
   async getTopPage(): Promise<any> {
   async getTopPage(): Promise<any> {
     const url = await this.installerService.installer.generateInstallUrl({
     const url = await this.installerService.installer.generateInstallUrl({
       // Add the scopes your app needs
       // Add the scopes your app needs
-      scopes: [
-        'channels:history',
-        'commands',
-        'groups:history',
-        'im:history',
-        'mpim:history',
-        'chat:write',
-        'team:read',
-      ],
+      scopes: requiredScopes,
     });
     });
 
 
     return { url, isOfficialMode };
     return { url, isOfficialMode };

+ 1 - 1
packages/slackbot-proxy/src/views/top.ejs

@@ -14,7 +14,7 @@
           <img alt="Add to Slack" height="40" width="139" src="/images/add-to-slack.png"/>
           <img alt="Add to Slack" height="40" width="139" src="/images/add-to-slack.png"/>
         </a>
         </a>
       </div>
       </div>
-      <a class="btn btn-outline-primary" href="https://docs.growi.org/en/admin-guide/management-cookbook/slack-integration/official-bot-settings.html">How to set up ?</a>
+      <a class="btn btn-outline-success" href="https://docs.growi.org/en/admin-guide/management-cookbook/slack-integration/official-bot-settings.html">Getting started</a>
       <div class="d-flex justify-content-evenly my-3">
       <div class="d-flex justify-content-evenly my-3">
         <% if (isOfficialMode) { %>
         <% if (isOfficialMode) { %>
           <a href="/privacy">
           <a href="/privacy">