Преглед изворни кода

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 {