zahmis пре 5 година
родитељ
комит
b2da1fa568
2 измењених фајлова са 19 додато и 10 уклоњено
  1. 2 2
      config/env.dev.js
  2. 17 8
      src/server/service/bolt.js

+ 2 - 2
config/env.dev.js

@@ -22,6 +22,6 @@ module.exports = {
   // DEV_HTTPS: true,
   // FORCE_WIKI_MODE: 'private', // 'public', 'private', undefined
   // PROMSTER_ENABLED: true,
-  // SLACK_SIGNING_SECRET: '',
-  // SLACK_BOT_TOKEN: '',
+  SLACK_SIGNING_SECRET: '90388b8786db74bcbd2a77d18e4e0202',
+  SLACK_BOT_TOKEN: 'xoxb-165254347429-1645771202130-am9x1h3A6NfilbT0DE8IE9eY',
 };

+ 17 - 8
src/server/service/bolt.js

@@ -1,4 +1,5 @@
 const logger = require('@alias/logger')('growi:service:BoltService');
+const axios = require('axios');
 
 class BoltReciever {
 
@@ -9,14 +10,6 @@ class BoltReciever {
   async requestHandler(req, res) {
     let ackCalled = false;
 
-    const payload = JSON.parse(req.body.payload);
-    const { type } = payload;
-    console.log(type);
-
-    if (type === 'view_submission') {
-      console.log('hgoe');
-    }
-
     // for verification request URL on Event Subscriptions
     if (req.body.challenge && req.body.type) {
       return res.send(req.body);
@@ -44,6 +37,22 @@ class BoltReciever {
     };
 
     await this.bolt.processEvent(event);
+
+    // payload action. click "Submit" etc.
+    if (req.body.payload == null) {
+      return;
+    }
+
+    const payload = JSON.parse(req.body.payload);
+    const { type } = payload;
+
+    if (type === 'view_submission') {
+      return axios.post('http://localhost:3000/_api/v3/pages', {
+        access_token: 'vu5rtuYMSZsYUx4a2ow4xvssjj+uuh0RFYOi03Jhrm4=',
+        path: payload.view.state.values.path.path_input.value,
+        body: payload.view.state.values.contents.contents_input.value,
+      });
+    }
   }
 
 }