lrf 2 年之前
父节点
当前提交
bb04dfa5cd
共有 1 个文件被更改,包括 3 次插入6 次删除
  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 });
   }
 
   // 获取信息