From 30bca85f5a016192098af6f41ca6531d42577036 Mon Sep 17 00:00:00 2001 From: lilia Date: Mon, 22 Dec 2014 13:24:02 -0800 Subject: [PATCH] Fix undefined proto.source --- js/background.js | 4 ++-- js/helpers.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/js/background.js b/js/background.js index 63c6e20c3..82bb759eb 100644 --- a/js/background.js +++ b/js/background.js @@ -118,9 +118,9 @@ // This function can be called from the background script on an // incoming message or from the frontend after the user accepts an // identity key change. - return textsecure.processDecrypted(pushMessageContent).then(function(pushMessageContent) { + var source = message.get('source'); + return textsecure.processDecrypted(pushMessageContent, source).then(function(pushMessageContent) { var now = new Date().getTime(); - var source = message.get('source'); var conversationId = pushMessageContent.group ? pushMessageContent.group.id : source; var conversation = conversations.add({id: conversationId}, {merge: true}); conversation.fetch().always(function() { diff --git a/js/helpers.js b/js/helpers.js index cf9f4284e..72a153f33 100644 --- a/js/helpers.js +++ b/js/helpers.js @@ -147,7 +147,7 @@ var handleAttachment = function(attachment) { then(updateAttachment); }; -textsecure.processDecrypted = function(decrypted) { +textsecure.processDecrypted = function(decrypted, source) { // Now that its decrypted, validate the message and clean it up for consumer processing // Note that messages may (generally) only perform one action and we ignore remaining fields @@ -174,7 +174,7 @@ textsecure.processDecrypted = function(decrypted) { } textsecure.storage.groups.createNewGroup(decrypted.group.members, decrypted.group.id); } else { - var fromIndex = existingGroup.indexOf(proto.source); + var fromIndex = existingGroup.indexOf(source); if (fromIndex < 0) { //TODO: This could be indication of a race... @@ -209,7 +209,7 @@ textsecure.processDecrypted = function(decrypted) { break; case textsecure.protobuf.PushMessageContent.GroupContext.Type.QUIT: - textsecure.storage.groups.removeNumber(decrypted.group.id, proto.source); + textsecure.storage.groups.removeNumber(decrypted.group.id, source); decrypted.body = null; decrypted.attachments = [];