Browse Source

implement shareSearchResults

itizawa 5 years ago
parent
commit
ea9182256e
2 changed files with 8 additions and 2 deletions
  1. 1 2
      src/server/routes/apiv3/slack-bot.js
  2. 7 0
      src/server/service/bolt.js

+ 1 - 2
src/server/routes/apiv3/slack-bot.js

@@ -33,7 +33,6 @@ module.exports = (crowi) => {
     // Send response immediately to avoid opelation_timeout error
     // Send response immediately to avoid opelation_timeout error
     // See https://api.slack.com/apis/connections/events-api#the-events-api__responding-to-events
     // See https://api.slack.com/apis/connections/events-api#the-events-api__responding-to-events
     res.send();
     res.send();
-    console.log(req.body);
 
 
     const { body } = req;
     const { body } = req;
     const args = body.text.split(' ');
     const args = body.text.split(' ');
@@ -58,7 +57,7 @@ module.exports = (crowi) => {
 
 
     switch (actionId) {
     switch (actionId) {
       case 'shareSearchResults': {
       case 'shareSearchResults': {
-        console.log(payload);
+        await crowi.boltService.shareSearchResults(payload);
         break;
         break;
       }
       }
       case 'showNextResults': {
       case 'showNextResults': {

+ 7 - 0
src/server/service/bolt.js

@@ -154,6 +154,13 @@ class BoltService extends S2sMessageHandlable {
     };
     };
   }
   }
 
 
+  shareSearchResults(payload) {
+    this.client.chat.postMessage({
+      channel: payload.channel.id,
+      text: payload.actions[0].value,
+    });
+  }
+
   async showEphemeralSearchResults(body, args, offsetNum) {
   async showEphemeralSearchResults(body, args, offsetNum) {
     const {
     const {
       resultPaths, offset, resultsTotal,
       resultPaths, offset, resultsTotal,