瀏覽代碼

Conversation updates: Log error if receiver is unknown (#889)

This prevents an ugly exception in case something goes wrong.
Danilo Bargen 6 年之前
父節點
當前提交
af34de8aae
共有 2 個文件被更改,包括 6 次插入1 次删除
  1. 5 0
      src/services/webclient.ts
  2. 1 1
      src/threema/container.ts

+ 5 - 0
src/services/webclient.ts

@@ -3176,6 +3176,11 @@ export class WebClientService {
 
         // Get receiver
         const receiver = this.receivers.getData({type: data.type, id: data.id});
+        if (!hasValue(receiver)) {
+            const log = `Received conversation update for unknown ${data.type} receiver`;
+            this.arpLog.error(log);
+            return;
+        }
 
         // Unpack required argument fields
         const type: string = args[WebClientService.ARGUMENT_MODE];

+ 1 - 1
src/threema/container.ts

@@ -113,7 +113,7 @@ class Receivers implements threema.Container.Receivers {
     /**
      * Get the receiver matching a certain template.
      */
-    public getData(receiver: threema.BaseReceiver): threema.Receiver | null {
+    public getData(receiver: threema.BaseReceiver): threema.Receiver | undefined {
         if (receiver.type === 'me') {
             return this.me.id === receiver.id ? this.me : undefined;
         } else {