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

FB: using get method from index.js under crowi

kaori 4 лет назад
Родитель
Сommit
71a9bd9a37

+ 4 - 0
packages/app/src/server/crowi/index.js

@@ -308,6 +308,10 @@ Crowi.prototype.scanRuntimeVersions = async function() {
   });
 };
 
+Crowi.prototype.getSocketIoService = function() {
+  return this.socketIoService;
+};
+
 Crowi.prototype.getSlack = function() {
   return this.slack;
 };

+ 3 - 3
packages/app/src/server/models/notification.ts

@@ -195,10 +195,10 @@ export default (crowi: Crowi) => {
   };
 
   notificationEvent.on('update', (user) => {
-    const { socketIoService } = crowi;
+    const io = crowi.getSocketIoService();
 
-    if (socketIoService.isInitialized) {
-      socketIoService.getDefaultSocket().emit('notification updated', { user });
+    if (io != null) {
+      io.sockets.emit('notification updated', { user });
     }
   });