lrf 2 years ago
parent
commit
bb04dfa5cd
1 changed files with 3 additions and 6 deletions
  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 });
   }
 
   // 获取信息