Skip to content

Commit

Permalink
Be resilient to missing data in MessageReceiver constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg-signal committed Jan 11, 2021
1 parent bc57a31 commit 37aa314
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions ts/textsecure/MessageReceiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ class MessageReceiverInner extends EventTarget {

count: number;

deviceId: number;
deviceId?: number;

hasConnected?: boolean;

incomingQueue: PQueue;

isEmptied?: boolean;

number_id: string | null;
number_id?: string;

password: string;

Expand All @@ -143,7 +143,7 @@ class MessageReceiverInner extends EventTarget {

uuid: string;

uuid_id: string | null;
uuid_id?: string;

wsr?: WebSocketResource;

Expand Down Expand Up @@ -176,12 +176,14 @@ class MessageReceiverInner extends EventTarget {
options.serverTrustRoot
);

this.number_id = oldUsername ? utils.unencodeNumber(oldUsername)[0] : null;
this.uuid_id = username ? utils.unencodeNumber(username)[0] : null;
this.deviceId = parseInt(
utils.unencodeNumber(username || oldUsername)[1],
10
);
this.number_id = oldUsername
? utils.unencodeNumber(oldUsername)[0]
: undefined;
this.uuid_id = username ? utils.unencodeNumber(username)[0] : undefined;
this.deviceId =
username || oldUsername
? parseInt(utils.unencodeNumber(username || oldUsername)[1], 10)
: undefined;

this.incomingQueue = new PQueue({ concurrency: 1, timeout: 1000 * 60 * 2 });
this.pendingQueue = new PQueue({ concurrency: 1, timeout: 1000 * 60 * 2 });
Expand Down

0 comments on commit 37aa314

Please sign in to comment.