Address review comments

pull/1224/head
Maxim Shishmarev 5 years ago
parent 29fe64f5d5
commit a2b80a5e68

@ -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()

@ -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<Array<any>> {
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<void> {
const pkStr = (pubkey.key ? pubkey.key : pubkey) as string;
const pkStr = pubkey.key;
await Data.updateLastHash({
convoId: pkStr,

Loading…
Cancel
Save