lrf 2 năm trước cách đây
mục cha
commit
bb04dfa5cd
1 tập tin đã thay đổi với 3 bổ sung6 xóa
  1. 3 6
      src/socket/ws.controller.ts

+ 3 - 6
src/socket/ws.controller.ts

@@ -38,12 +38,9 @@ export class WsSocketController {
   async checkNeedSend(client) {
     const to = get(client, 'token');
     if (!to) return;
-    const list = await this.model.find({ to }).lean();
-    for (const i of list) {
-      const { to, msg } = i;
-      await this.toSend(msg, to);
-      await this.model.deleteOne({ _id: i._id });
-    }
+    await this.model.find({ to }).lean();
+    await this.toSend({ type: 'needCheck' }, to);
+    await this.model.deleteMany({ to });
   }
 
   // 获取信息