index.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. /* eslint-disable @typescript-eslint/no-this-alias */
  2. import http from 'http';
  3. import path from 'path';
  4. import { createTerminus } from '@godaddy/terminus';
  5. import { initMongooseGlobalSettings, getMongoUri, mongoOptions } from '@growi/core';
  6. import mongoose from 'mongoose';
  7. import pkg from '^/package.json';
  8. import CdnResourcesService from '~/services/cdn-resources-service';
  9. import Xss from '~/services/xss';
  10. import loggerFactory from '~/utils/logger';
  11. import { projectRoot } from '~/utils/project-dir-utils';
  12. import Activity from '../models/activity';
  13. import PageOperation, { PageActionType } from '../models/page-operation';
  14. import PageRedirect from '../models/page-redirect';
  15. import Tag from '../models/tag';
  16. import UserGroup from '../models/user-group';
  17. import AclService from '../service/acl';
  18. import AppService from '../service/app';
  19. import AttachmentService from '../service/attachment';
  20. import ConfigManager from '../service/config-manager';
  21. import { InstallerService } from '../service/installer';
  22. import PageService from '../service/page';
  23. import PageGrantService from '../service/page-grant';
  24. import PageOperationService from '../service/page-operation';
  25. import SearchService from '../service/search';
  26. import { SlackIntegrationService } from '../service/slack-integration';
  27. import { UserNotificationService } from '../service/user-notification';
  28. const logger = loggerFactory('growi:crowi');
  29. const httpErrorHandler = require('../middlewares/http-error-handler');
  30. const models = require('../models');
  31. const PluginService = require('../plugins/plugin.service');
  32. const sep = path.sep;
  33. function Crowi() {
  34. this.version = pkg.version;
  35. this.runtimeVersions = undefined; // initialized by scanRuntimeVersions()
  36. this.publicDir = path.join(projectRoot, 'public') + sep;
  37. this.resourceDir = path.join(projectRoot, 'resource') + sep;
  38. this.localeDir = path.join(this.resourceDir, 'locales') + sep;
  39. this.viewsDir = path.resolve(__dirname, '../views') + sep;
  40. this.tmpDir = path.join(projectRoot, 'tmp') + sep;
  41. this.cacheDir = path.join(this.tmpDir, 'cache');
  42. this.express = null;
  43. this.config = {};
  44. this.configManager = null;
  45. this.s2sMessagingService = null;
  46. this.mailService = null;
  47. this.passportService = null;
  48. this.globalNotificationService = null;
  49. this.userNotificationService = null;
  50. this.xssService = null;
  51. this.aclService = null;
  52. this.appService = null;
  53. this.fileUploadService = null;
  54. this.restQiitaAPIService = null;
  55. this.growiBridgeService = null;
  56. this.exportService = null;
  57. this.importService = null;
  58. this.searchService = null;
  59. this.socketIoService = null;
  60. this.pageService = null;
  61. this.syncPageStatusService = null;
  62. this.cdnResourcesService = new CdnResourcesService();
  63. this.slackIntegrationService = null;
  64. this.inAppNotificationService = null;
  65. this.activityService = null;
  66. this.commentService = null;
  67. this.xss = new Xss();
  68. this.tokens = null;
  69. this.models = {};
  70. this.env = process.env;
  71. this.node_env = this.env.NODE_ENV || 'development';
  72. this.port = this.env.PORT || 3000;
  73. this.events = {
  74. user: new (require('../events/user'))(this),
  75. page: new (require('../events/page'))(this),
  76. activity: new (require('../events/activity'))(this),
  77. bookmark: new (require('../events/bookmark'))(this),
  78. comment: new (require('../events/comment'))(this),
  79. tag: new (require('../events/tag'))(this),
  80. admin: new (require('../events/admin'))(this),
  81. };
  82. }
  83. Crowi.prototype.init = async function() {
  84. await this.setupDatabase();
  85. await this.setupModels();
  86. await this.setupConfigManager();
  87. await this.setupSessionConfig();
  88. // setup messaging services
  89. await this.setupS2sMessagingService();
  90. await this.setupSocketIoService();
  91. // customizeService depends on AppService and XssService
  92. // passportService depends on appService
  93. // export and import depends on setUpGrowiBridge
  94. await Promise.all([
  95. this.setUpApp(),
  96. this.setUpXss(),
  97. this.setUpGrowiBridge(),
  98. ]);
  99. await Promise.all([
  100. this.scanRuntimeVersions(),
  101. this.setupPassport(),
  102. this.setupSearcher(),
  103. this.setupMailer(),
  104. this.setupSlackIntegrationService(),
  105. this.setupCsrf(),
  106. this.setUpFileUpload(),
  107. this.setUpFileUploaderSwitchService(),
  108. this.setupAttachmentService(),
  109. this.setUpAcl(),
  110. this.setUpCustomize(),
  111. this.setUpRestQiitaAPI(),
  112. this.setupUserGroupService(),
  113. this.setupExport(),
  114. this.setupImport(),
  115. this.setupPageService(),
  116. this.setupInAppNotificationService(),
  117. this.setupActivityService(),
  118. this.setupCommentService(),
  119. this.setupSyncPageStatusService(),
  120. ]);
  121. // globalNotification depends on slack and mailer
  122. await Promise.all([
  123. this.setUpGlobalNotification(),
  124. this.setUpUserNotification(),
  125. ]);
  126. await this.autoInstall();
  127. };
  128. /**
  129. * Execute functions that should be run after the express server is ready.
  130. */
  131. Crowi.prototype.asyncAfterExpressServerReady = async function() {
  132. if (this.pageOperationService != null) {
  133. await this.pageOperationService.afterExpressServerReady();
  134. }
  135. };
  136. Crowi.prototype.isPageId = function(pageId) {
  137. if (!pageId) {
  138. return false;
  139. }
  140. if (typeof pageId === 'string' && pageId.match(/^[\da-f]{24}$/)) {
  141. return true;
  142. }
  143. return false;
  144. };
  145. Crowi.prototype.setConfig = function(config) {
  146. this.config = config;
  147. };
  148. Crowi.prototype.getConfig = function() {
  149. return this.config;
  150. };
  151. Crowi.prototype.getEnv = function() {
  152. return this.env;
  153. };
  154. // getter/setter of model instance
  155. //
  156. Crowi.prototype.model = function(name, model) {
  157. if (model != null) {
  158. this.models[name] = model;
  159. }
  160. return this.models[name];
  161. };
  162. // getter/setter of event instance
  163. Crowi.prototype.event = function(name, event) {
  164. if (event) {
  165. this.events[name] = event;
  166. }
  167. return this.events[name];
  168. };
  169. Crowi.prototype.setupDatabase = function() {
  170. mongoose.Promise = global.Promise;
  171. // mongoUri = mongodb://user:password@host/dbname
  172. const mongoUri = getMongoUri();
  173. initMongooseGlobalSettings();
  174. return mongoose.connect(mongoUri, mongoOptions);
  175. };
  176. Crowi.prototype.setupSessionConfig = async function() {
  177. const session = require('express-session');
  178. const sessionMaxAge = this.configManager.getConfig('crowi', 'security:sessionMaxAge') || 2592000000; // default: 30days
  179. const redisUrl = this.env.REDISTOGO_URL || this.env.REDIS_URI || this.env.REDIS_URL || null;
  180. const uid = require('uid-safe').sync;
  181. // generate pre-defined uid for healthcheck
  182. const healthcheckUid = uid(24);
  183. const sessionConfig = {
  184. rolling: true,
  185. secret: this.env.SECRET_TOKEN || 'this is default session secret',
  186. resave: false,
  187. saveUninitialized: true,
  188. cookie: {
  189. maxAge: sessionMaxAge,
  190. },
  191. genid(req) {
  192. // return pre-defined uid when healthcheck
  193. if (req.path === '/_api/v3/healthcheck') {
  194. return healthcheckUid;
  195. }
  196. return uid(24);
  197. },
  198. };
  199. if (this.env.SESSION_NAME) {
  200. sessionConfig.name = this.env.SESSION_NAME;
  201. }
  202. // use Redis for session store
  203. if (redisUrl) {
  204. const redis = require('redis');
  205. const redisClient = redis.createClient({ url: redisUrl });
  206. const RedisStore = require('connect-redis')(session);
  207. sessionConfig.store = new RedisStore({ client: redisClient });
  208. }
  209. // use MongoDB for session store
  210. else {
  211. const MongoStore = require('connect-mongo');
  212. sessionConfig.store = MongoStore.create({ client: mongoose.connection.getClient() });
  213. }
  214. this.sessionConfig = sessionConfig;
  215. };
  216. Crowi.prototype.setupConfigManager = async function() {
  217. this.configManager = new ConfigManager();
  218. return this.configManager.loadConfigs();
  219. };
  220. Crowi.prototype.setupS2sMessagingService = async function() {
  221. const s2sMessagingService = require('../service/s2s-messaging')(this);
  222. if (s2sMessagingService != null) {
  223. s2sMessagingService.subscribe();
  224. this.configManager.setS2sMessagingService(s2sMessagingService);
  225. // add as a message handler
  226. s2sMessagingService.addMessageHandler(this.configManager);
  227. this.s2sMessagingService = s2sMessagingService;
  228. }
  229. };
  230. Crowi.prototype.setupSocketIoService = async function() {
  231. const SocketIoService = require('../service/socket-io');
  232. if (this.socketIoService == null) {
  233. this.socketIoService = new SocketIoService(this);
  234. }
  235. };
  236. Crowi.prototype.setupModels = async function() {
  237. let allModels = {};
  238. // include models that dependent on crowi
  239. allModels = models;
  240. // include models that independent from crowi
  241. allModels.Activity = Activity;
  242. allModels.Tag = Tag;
  243. allModels.UserGroup = UserGroup;
  244. allModels.PageRedirect = PageRedirect;
  245. Object.keys(allModels).forEach((key) => {
  246. return this.model(key, models[key](this));
  247. });
  248. };
  249. Crowi.prototype.scanRuntimeVersions = async function() {
  250. const self = this;
  251. const check = require('check-node-version');
  252. return new Promise((resolve, reject) => {
  253. check((err, result) => {
  254. if (err) {
  255. reject(err);
  256. }
  257. self.runtimeVersions = result;
  258. resolve();
  259. });
  260. });
  261. };
  262. Crowi.prototype.getSlack = function() {
  263. return this.slack;
  264. };
  265. Crowi.prototype.getSlackLegacy = function() {
  266. return this.slackLegacy;
  267. };
  268. Crowi.prototype.getGlobalNotificationService = function() {
  269. return this.globalNotificationService;
  270. };
  271. Crowi.prototype.getUserNotificationService = function() {
  272. return this.userNotificationService;
  273. };
  274. Crowi.prototype.getRestQiitaAPIService = function() {
  275. return this.restQiitaAPIService;
  276. };
  277. Crowi.prototype.setupPassport = async function() {
  278. logger.debug('Passport is enabled');
  279. // initialize service
  280. const PassportService = require('../service/passport');
  281. if (this.passportService == null) {
  282. this.passportService = new PassportService(this);
  283. }
  284. this.passportService.setupSerializer();
  285. // setup strategies
  286. try {
  287. this.passportService.setupStrategyById('local');
  288. this.passportService.setupStrategyById('ldap');
  289. this.passportService.setupStrategyById('saml');
  290. this.passportService.setupStrategyById('oidc');
  291. this.passportService.setupStrategyById('basic');
  292. this.passportService.setupStrategyById('google');
  293. this.passportService.setupStrategyById('github');
  294. this.passportService.setupStrategyById('twitter');
  295. }
  296. catch (err) {
  297. logger.error(err);
  298. }
  299. // add as a message handler
  300. if (this.s2sMessagingService != null) {
  301. this.s2sMessagingService.addMessageHandler(this.passportService);
  302. }
  303. return Promise.resolve();
  304. };
  305. Crowi.prototype.setupSearcher = async function() {
  306. this.searchService = new SearchService(this);
  307. };
  308. Crowi.prototype.setupMailer = async function() {
  309. const MailService = require('~/server/service/mail');
  310. this.mailService = new MailService(this);
  311. // add as a message handler
  312. if (this.s2sMessagingService != null) {
  313. this.s2sMessagingService.addMessageHandler(this.mailService);
  314. }
  315. };
  316. Crowi.prototype.setupCsrf = async function() {
  317. const Tokens = require('csrf');
  318. this.tokens = new Tokens();
  319. return Promise.resolve();
  320. };
  321. Crowi.prototype.autoInstall = function() {
  322. const isInstalled = this.configManager.getConfig('crowi', 'app:installed');
  323. const username = this.configManager.getConfig('crowi', 'autoInstall:adminUsername');
  324. if (isInstalled || username == null) {
  325. return;
  326. }
  327. logger.info('Start automatic installation');
  328. const firstAdminUserToSave = {
  329. username,
  330. name: this.configManager.getConfig('crowi', 'autoInstall:adminName'),
  331. email: this.configManager.getConfig('crowi', 'autoInstall:adminEmail'),
  332. password: this.configManager.getConfig('crowi', 'autoInstall:adminPassword'),
  333. admin: true,
  334. };
  335. const globalLang = this.configManager.getConfig('crowi', 'autoInstall:globalLang');
  336. const allowGuestMode = this.configManager.getConfig('crowi', 'autoInstall:allowGuestMode');
  337. const serverDate = this.configManager.getConfig('crowi', 'autoInstall:serverDate');
  338. const installerService = new InstallerService(this);
  339. try {
  340. installerService.install(firstAdminUserToSave, globalLang ?? 'en_US', {
  341. allowGuestMode,
  342. serverDate,
  343. });
  344. }
  345. catch (err) {
  346. logger.warn('Automatic installation failed.', err);
  347. }
  348. };
  349. Crowi.prototype.getTokens = function() {
  350. return this.tokens;
  351. };
  352. Crowi.prototype.start = async function() {
  353. // init CrowiDev
  354. if (this.node_env === 'development') {
  355. const CrowiDev = require('./dev');
  356. this.crowiDev = new CrowiDev(this);
  357. this.crowiDev.init();
  358. }
  359. await this.init();
  360. await this.buildServer();
  361. const { express, configManager } = this;
  362. // setup plugins
  363. this.pluginService = new PluginService(this, express);
  364. await this.pluginService.autoDetectAndLoadPlugins();
  365. const app = (this.node_env === 'development') ? this.crowiDev.setupServer(express) : express;
  366. const httpServer = http.createServer(app);
  367. // setup terminus
  368. this.setupTerminus(httpServer);
  369. // attach to socket.io
  370. this.socketIoService.attachServer(httpServer);
  371. // listen
  372. const serverListening = httpServer.listen(this.port, () => {
  373. logger.info(`[${this.node_env}] Express server is listening on port ${this.port}`);
  374. if (this.node_env === 'development') {
  375. this.crowiDev.setupExpressAfterListening(express);
  376. }
  377. });
  378. // listen for promster
  379. if (configManager.getConfig('crowi', 'promster:isEnabled')) {
  380. const { createServer } = require('@promster/server');
  381. const promsterPort = configManager.getConfig('crowi', 'promster:port');
  382. createServer({ port: promsterPort }).then(() => {
  383. logger.info(`[${this.node_env}] Promster server is listening on port ${promsterPort}`);
  384. });
  385. }
  386. // setup Express Routes
  387. this.setupRoutesAtLast();
  388. // setup Global Error Handlers
  389. this.setupGlobalErrorHandlers();
  390. // Execute this asynchronously after the express server is ready so it does not block the ongoing process
  391. this.asyncAfterExpressServerReady();
  392. return serverListening;
  393. };
  394. Crowi.prototype.buildServer = async function() {
  395. const env = this.node_env;
  396. const express = require('express')();
  397. require('./express-init')(this, express);
  398. // use bunyan
  399. if (env === 'production') {
  400. const expressBunyanLogger = require('express-bunyan-logger');
  401. const logger = loggerFactory('express');
  402. express.use(expressBunyanLogger({
  403. logger,
  404. excludes: ['*'],
  405. }));
  406. }
  407. // use morgan
  408. else {
  409. const morgan = require('morgan');
  410. express.use(morgan('dev'));
  411. }
  412. this.express = express;
  413. };
  414. Crowi.prototype.setupTerminus = function(server) {
  415. createTerminus(server, {
  416. signals: ['SIGINT', 'SIGTERM'],
  417. onSignal: async() => {
  418. logger.info('Server is starting cleanup');
  419. await mongoose.disconnect();
  420. return;
  421. },
  422. onShutdown: async() => {
  423. logger.info('Cleanup finished, server is shutting down');
  424. },
  425. });
  426. };
  427. /**
  428. * setup Express Routes
  429. * !! this must be at last because it includes '/*' route !!
  430. */
  431. Crowi.prototype.setupRoutesAtLast = function() {
  432. require('../routes')(this, this.express);
  433. };
  434. /**
  435. * setup global error handlers
  436. * !! this must be after the Routes setup !!
  437. */
  438. Crowi.prototype.setupGlobalErrorHandlers = function() {
  439. this.express.use(httpErrorHandler);
  440. };
  441. /**
  442. * require API for plugins
  443. *
  444. * @param {string} modulePath relative path from /lib/crowi/index.js
  445. * @return {module}
  446. *
  447. * @memberof Crowi
  448. */
  449. Crowi.prototype.require = function(modulePath) {
  450. return require(modulePath);
  451. };
  452. /**
  453. * setup GlobalNotificationService
  454. */
  455. Crowi.prototype.setUpGlobalNotification = async function() {
  456. const GlobalNotificationService = require('../service/global-notification');
  457. if (this.globalNotificationService == null) {
  458. this.globalNotificationService = new GlobalNotificationService(this);
  459. }
  460. };
  461. /**
  462. * setup UserNotificationService
  463. */
  464. Crowi.prototype.setUpUserNotification = async function() {
  465. if (this.userNotificationService == null) {
  466. this.userNotificationService = new UserNotificationService(this);
  467. }
  468. };
  469. /**
  470. * setup XssService
  471. */
  472. Crowi.prototype.setUpXss = async function() {
  473. const XssService = require('../service/xss');
  474. if (this.xssService == null) {
  475. this.xssService = new XssService(this.configManager);
  476. }
  477. };
  478. /**
  479. * setup AclService
  480. */
  481. Crowi.prototype.setUpAcl = async function() {
  482. if (this.aclService == null) {
  483. this.aclService = new AclService(this.configManager);
  484. }
  485. };
  486. /**
  487. * setup CustomizeService
  488. */
  489. Crowi.prototype.setUpCustomize = async function() {
  490. const CustomizeService = require('../service/customize');
  491. if (this.customizeService == null) {
  492. this.customizeService = new CustomizeService(this);
  493. this.customizeService.initCustomCss();
  494. this.customizeService.initCustomTitle();
  495. // add as a message handler
  496. if (this.s2sMessagingService != null) {
  497. this.s2sMessagingService.addMessageHandler(this.customizeService);
  498. }
  499. }
  500. };
  501. /**
  502. * setup AppService
  503. */
  504. Crowi.prototype.setUpApp = async function() {
  505. if (this.appService == null) {
  506. this.appService = new AppService(this);
  507. // add as a message handler
  508. const isInstalled = this.configManager.getConfig('crowi', 'app:installed');
  509. if (this.s2sMessagingService != null && !isInstalled) {
  510. this.s2sMessagingService.addMessageHandler(this.appService);
  511. }
  512. }
  513. };
  514. /**
  515. * setup FileUploadService
  516. */
  517. Crowi.prototype.setUpFileUpload = async function(isForceUpdate = false) {
  518. if (this.fileUploadService == null || isForceUpdate) {
  519. this.fileUploadService = require('../service/file-uploader')(this);
  520. }
  521. };
  522. /**
  523. * setup FileUploaderSwitchService
  524. */
  525. Crowi.prototype.setUpFileUploaderSwitchService = async function() {
  526. const FileUploaderSwitchService = require('../service/file-uploader-switch');
  527. this.fileUploaderSwitchService = new FileUploaderSwitchService(this);
  528. // add as a message handler
  529. if (this.s2sMessagingService != null) {
  530. this.s2sMessagingService.addMessageHandler(this.fileUploaderSwitchService);
  531. }
  532. };
  533. /**
  534. * setup AttachmentService
  535. */
  536. Crowi.prototype.setupAttachmentService = async function() {
  537. if (this.attachmentService == null) {
  538. this.attachmentService = new AttachmentService(this);
  539. }
  540. };
  541. /**
  542. * setup RestQiitaAPIService
  543. */
  544. Crowi.prototype.setUpRestQiitaAPI = async function() {
  545. const RestQiitaAPIService = require('../service/rest-qiita-API');
  546. if (this.restQiitaAPIService == null) {
  547. this.restQiitaAPIService = new RestQiitaAPIService(this);
  548. }
  549. };
  550. Crowi.prototype.setupUserGroupService = async function() {
  551. const UserGroupService = require('../service/user-group');
  552. if (this.userGroupService == null) {
  553. this.userGroupService = new UserGroupService(this);
  554. return this.userGroupService.init();
  555. }
  556. };
  557. Crowi.prototype.setUpGrowiBridge = async function() {
  558. const GrowiBridgeService = require('../service/growi-bridge');
  559. if (this.growiBridgeService == null) {
  560. this.growiBridgeService = new GrowiBridgeService(this);
  561. }
  562. };
  563. Crowi.prototype.setupExport = async function() {
  564. const ExportService = require('../service/export');
  565. if (this.exportService == null) {
  566. this.exportService = new ExportService(this);
  567. }
  568. };
  569. Crowi.prototype.setupImport = async function() {
  570. const ImportService = require('../service/import');
  571. if (this.importService == null) {
  572. this.importService = new ImportService(this);
  573. }
  574. };
  575. Crowi.prototype.setupPageService = async function() {
  576. if (this.pageService == null) {
  577. this.pageService = new PageService(this);
  578. }
  579. if (this.pageGrantService == null) {
  580. this.pageGrantService = new PageGrantService(this);
  581. }
  582. if (this.pageOperationService == null) {
  583. this.pageOperationService = new PageOperationService(this);
  584. await this.pageOperationService.init();
  585. }
  586. };
  587. Crowi.prototype.setupInAppNotificationService = async function() {
  588. const InAppNotificationService = require('../service/in-app-notification');
  589. if (this.inAppNotificationService == null) {
  590. this.inAppNotificationService = new InAppNotificationService(this);
  591. }
  592. };
  593. Crowi.prototype.setupActivityService = async function() {
  594. const ActivityService = require('../service/activity');
  595. if (this.activityService == null) {
  596. this.activityService = new ActivityService(this);
  597. await this.activityService.createTtlIndex();
  598. }
  599. };
  600. Crowi.prototype.setupCommentService = async function() {
  601. const CommentService = require('../service/comment');
  602. if (this.commentService == null) {
  603. this.commentService = new CommentService(this);
  604. }
  605. };
  606. Crowi.prototype.setupSyncPageStatusService = async function() {
  607. const SyncPageStatusService = require('../service/system-events/sync-page-status');
  608. if (this.syncPageStatusService == null) {
  609. this.syncPageStatusService = new SyncPageStatusService(this, this.s2sMessagingService, this.socketIoService);
  610. // add as a message handler
  611. if (this.s2sMessagingService != null) {
  612. this.s2sMessagingService.addMessageHandler(this.syncPageStatusService);
  613. }
  614. }
  615. };
  616. Crowi.prototype.setupSlackIntegrationService = async function() {
  617. if (this.slackIntegrationService == null) {
  618. this.slackIntegrationService = new SlackIntegrationService(this);
  619. }
  620. // add as a message handler
  621. if (this.s2sMessagingService != null) {
  622. this.s2sMessagingService.addMessageHandler(this.slackIntegrationService);
  623. }
  624. };
  625. export default Crowi;