From a2b80a5e6896ca501a3887c62fad6f9e81d542d3 Mon Sep 17 00:00:00 2001 From: Maxim Shishmarev Date: Wed, 8 Jul 2020 10:57:24 +1000 Subject: [PATCH] Address review comments --- ts/receiver/receiver.ts | 7 ------- ts/session/snode_api/swarmPolling.ts | 16 +++++++++------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/ts/receiver/receiver.ts b/ts/receiver/receiver.ts index 1736b54dc..911b78516 100644 --- a/ts/receiver/receiver.ts +++ b/ts/receiver/receiver.ts @@ -151,13 +151,6 @@ async function handleRequestDetail( envelope.senderIdentity = senderIdentity; } - // TODO: 'source' is almost certainly undefined here (sealed sender), - // so this check is not appropriate here - const blocked = await isBlocked(envelope.source); - if (blocked) { - return; - } - envelope.id = envelope.serverGuid || window.getGuid(); envelope.serverTimestamp = envelope.serverTimestamp ? envelope.serverTimestamp.toNumber() diff --git a/ts/session/snode_api/swarmPolling.ts b/ts/session/snode_api/swarmPolling.ts index 2b4eddd42..a742f490a 100644 --- a/ts/session/snode_api/swarmPolling.ts +++ b/ts/session/snode_api/swarmPolling.ts @@ -56,11 +56,13 @@ export class SwarmPolling { this.groupPubkeys.push(pubkey); } - public addPubkey(pubkey: PubKey) { + public addPubkey(pk: PubKey | string) { + const pubkey = PubKey.cast(pk); this.pubkeys.push(pubkey); } - public removePubkey(pubkey: PubKey) { + public removePubkey(pk: PubKey | string) { + const pubkey = PubKey.cast(pk); this.pubkeys = this.pubkeys.filter(key => !pubkey.isEqual(key)); this.groupPubkeys = this.groupPubkeys.filter(key => !pubkey.isEqual(key)); } @@ -68,9 +70,9 @@ export class SwarmPolling { protected async pollOnceForKey(pubkey: PubKey, isGroup: boolean) { // NOTE: sometimes pubkey is string, sometimes it is object, so // accept both until this is fixed: - const pk = (pubkey.key ? pubkey.key : pubkey) as string; + const pkStr = pubkey.key; - const snodes = await getSnodesFor(pk); + const snodes = await getSnodesFor(pkStr); // Select nodes for which we already have lastHashes const alreadyPolled = snodes.filter( @@ -106,7 +108,7 @@ export class SwarmPolling { const newMessages = await this.handleSeenMessages(messages); newMessages.forEach((m: Message) => { - const options = isGroup ? { conversationId: pk } : {}; + const options = isGroup ? { conversationId: pkStr } : {}; processMessage(m.data, options); }); } @@ -119,7 +121,7 @@ export class SwarmPolling { ): Promise> { const edkey = node.pubkey_ed25519; - const pkStr = (pubkey.key ? pubkey.key : pubkey) as string; + const pkStr = pubkey.key; const prevHash = await this.getLastHash(edkey, pkStr); @@ -197,7 +199,7 @@ export class SwarmPolling { hash: string, expiration: number ): Promise { - const pkStr = (pubkey.key ? pubkey.key : pubkey) as string; + const pkStr = pubkey.key; await Data.updateLastHash({ convoId: pkStr,