Browse Source

create boltService instance

kaori 5 years ago
parent
commit
469ac20d12
2 changed files with 11 additions and 2 deletions
  1. 9 0
      src/server/crowi/index.js
  2. 2 2
      src/server/routes/apiv3/slack-bot.js

+ 9 - 0
src/server/crowi/index.js

@@ -57,6 +57,7 @@ function Crowi(rootdir) {
   this.syncPageStatusService = null;
   this.syncPageStatusService = null;
   this.cdnResourcesService = new CdnResourcesService();
   this.cdnResourcesService = new CdnResourcesService();
   this.interceptorManager = new InterceptorManager();
   this.interceptorManager = new InterceptorManager();
+  this.boltService = null;
   this.xss = new Xss();
   this.xss = new Xss();
 
 
   this.tokens = null;
   this.tokens = null;
@@ -116,6 +117,7 @@ Crowi.prototype.init = async function() {
     this.setupImport(),
     this.setupImport(),
     this.setupPageService(),
     this.setupPageService(),
     this.setupSyncPageStatusService(),
     this.setupSyncPageStatusService(),
+    this.setupBoltService(),
   ]);
   ]);
 
 
   // globalNotification depends on slack and mailer
   // globalNotification depends on slack and mailer
@@ -649,4 +651,11 @@ Crowi.prototype.setupSyncPageStatusService = async function() {
   }
   }
 };
 };
 
 
+Crowi.prototype.setupBoltService = async function() {
+  const BoltService = require('../service/bolt');
+  if (this.boltService == null) {
+    this.boltService = new BoltService(this);
+  }
+};
+
 module.exports = Crowi;
 module.exports = Crowi;

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

@@ -5,10 +5,10 @@ const router = express.Router();
 
 
 
 
 module.exports = (crowi) => {
 module.exports = (crowi) => {
-  const { BoltService } = crowi;
+  const { boltService } = crowi;
 
 
   router.get('/', async(req, res) => {
   router.get('/', async(req, res) => {
-    const app = BoltService.getBoltAppInstance();
+    const app = boltService.getBoltAppInstance();
 
 
     // TODO: improve event method
     // TODO: improve event method
     app.event('message', async({ event, client }) => {
     app.event('message', async({ event, client }) => {