From f2bdafc7e9ccca9248480fb1168e149c4123ceb8 Mon Sep 17 00:00:00 2001 From: lilia Date: Sat, 17 Dec 2016 13:59:07 +0100 Subject: [PATCH] Validate/reformat phone numbers in contact syncs Turns out there's no garauntee that Android will send us contact info with phone numbers in e164 format. When that happens, we fail to update the correct contact. Fix by performing validation on the incoming number before attempting to merge changes to the name, avatar, or color. Fixes #903 --- js/background.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/js/background.js b/js/background.js index 24b4c1d58..0bd349bf0 100644 --- a/js/background.js +++ b/js/background.js @@ -128,14 +128,22 @@ function onContactReceived(ev) { var contactDetails = ev.contactDetails; - ConversationController.create({ + + var c = new Whisper.Conversation({ name: contactDetails.name, id: contactDetails.number, avatar: contactDetails.avatar, color: contactDetails.color, type: 'private', active_at: Date.now() - }).save(); + }); + var error; + if (error = c.validateNumber()) { + console.log(error); + return; + } + + ConversationController.create(c).save(); } function onGroupReceived(ev) {