From c05be725b39ddf2bb356e03c457790cc2e60aedc Mon Sep 17 00:00:00 2001 From: lilia Date: Tue, 21 Jul 2015 15:58:50 -0700 Subject: [PATCH] Move makeAttachmentPointer Clean up unnecessary pre-declaration of `var makeAttachmentPointer`. --- js/libtextsecure.js | 29 ++++++++++++++--------------- libtextsecure/sendmessage.js | 29 ++++++++++++++--------------- 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 4e0a853d..c3ed5ac4 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -39769,7 +39769,20 @@ window.textsecure.messaging = function() { }); } - var makeAttachmentPointer; + function makeAttachmentPointer(attachment) { + var proto = new textsecure.protobuf.AttachmentPointer(); + proto.key = textsecure.crypto.getRandomBytes(64); + + var iv = textsecure.crypto.getRandomBytes(16); + return textsecure.crypto.encryptAttachment(attachment.data, proto.key, iv).then(function(encryptedBin) { + return TextSecureServer.putAttachment(encryptedBin).then(function(id) { + proto.id = id; + proto.contentType = attachment.contentType; + return proto; + }); + }); + } + var refreshGroup = function(number, groupId, devicesForNumber) { groupId = getString(groupId); @@ -39951,20 +39964,6 @@ window.textsecure.messaging = function() { getDevicesAndSendToNumber(numbers[i]); } - makeAttachmentPointer = function(attachment) { - var proto = new textsecure.protobuf.AttachmentPointer(); - proto.key = textsecure.crypto.getRandomBytes(64); - - var iv = textsecure.crypto.getRandomBytes(16); - return textsecure.crypto.encryptAttachment(attachment.data, proto.key, iv).then(function(encryptedBin) { - return TextSecureServer.putAttachment(encryptedBin).then(function(id) { - proto.id = id; - proto.contentType = attachment.contentType; - return proto; - }); - }); - } - var sendIndividualProto = function(number, proto, timestamp) { return new Promise(function(resolve, reject) { sendMessageProto(timestamp, [number], proto, function(res) { diff --git a/libtextsecure/sendmessage.js b/libtextsecure/sendmessage.js index 14db4ce4..0b67e121 100644 --- a/libtextsecure/sendmessage.js +++ b/libtextsecure/sendmessage.js @@ -65,7 +65,20 @@ window.textsecure.messaging = function() { }); } - var makeAttachmentPointer; + function makeAttachmentPointer(attachment) { + var proto = new textsecure.protobuf.AttachmentPointer(); + proto.key = textsecure.crypto.getRandomBytes(64); + + var iv = textsecure.crypto.getRandomBytes(16); + return textsecure.crypto.encryptAttachment(attachment.data, proto.key, iv).then(function(encryptedBin) { + return TextSecureServer.putAttachment(encryptedBin).then(function(id) { + proto.id = id; + proto.contentType = attachment.contentType; + return proto; + }); + }); + } + var refreshGroup = function(number, groupId, devicesForNumber) { groupId = getString(groupId); @@ -247,20 +260,6 @@ window.textsecure.messaging = function() { getDevicesAndSendToNumber(numbers[i]); } - makeAttachmentPointer = function(attachment) { - var proto = new textsecure.protobuf.AttachmentPointer(); - proto.key = textsecure.crypto.getRandomBytes(64); - - var iv = textsecure.crypto.getRandomBytes(16); - return textsecure.crypto.encryptAttachment(attachment.data, proto.key, iv).then(function(encryptedBin) { - return TextSecureServer.putAttachment(encryptedBin).then(function(id) { - proto.id = id; - proto.contentType = attachment.contentType; - return proto; - }); - }); - } - var sendIndividualProto = function(number, proto, timestamp) { return new Promise(function(resolve, reject) { sendMessageProto(timestamp, [number], proto, function(res) {