From 94fb860e39920ffb2507792802d68d3c3ab42f29 Mon Sep 17 00:00:00 2001
From: blavenie <benoit.lavenier@e-is.pro>
Date: Mon, 13 Mar 2017 12:08:26 +0100
Subject: [PATCH] - do a copy before encrypt a message, to be able to resue it
 for outbox - fix #382

---
 www/plugins/es/js/services/wallet-services.js | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/www/plugins/es/js/services/wallet-services.js b/www/plugins/es/js/services/wallet-services.js
index f2c61619f..7d6938860 100644
--- a/www/plugins/es/js/services/wallet-services.js
+++ b/www/plugins/es/js/services/wallet-services.js
@@ -33,6 +33,7 @@ angular.module('cesium.es.wallet.services', ['ngResource', 'cesium.wallet.servic
   }
 
   function packRecordFields(record, keypair, recipientFieldName, cypherFieldNames) {
+
     recipientFieldName = recipientFieldName || 'recipient';
     if (!record[recipientFieldName]) {
       return $q.reject({message:'ES_WALLET.ERROR.RECIPIENT_IS_MANDATORY'});
@@ -43,6 +44,9 @@ angular.module('cesium.es.wallet.services', ['ngResource', 'cesium.wallet.servic
       cypherFieldNames = [cypherFieldNames];
     }
 
+    // Work on a copy, to keep the original record (as it could be use again - fix #382)
+    record = angular.copy(record);
+
     // Get recipient
     var recipientPk = CryptoUtils.util.decode_base58(record[recipientFieldName]);
 
-- 
GitLab