diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 77fd6ce9b142..7e0c14a30aca 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -39049,6 +39049,9 @@ MessageSender.prototype = { proto.id = id; proto.contentType = attachment.contentType; proto.digest = result.digest; + if (attachment.fileName) { + proto.fileName = attachment.fileName; + } return proto; }); }.bind(this)); diff --git a/js/views/attachment_view.js b/js/views/attachment_view.js index 001388f6a322..f6f6600efef0 100644 --- a/js/views/attachment_view.js +++ b/js/views/attachment_view.js @@ -91,6 +91,10 @@ } }, suggestedName: function() { + if (this.model.fileName) { + return this.model.fileName; + } + var suggestion = 'signal'; if (this.timestamp) { suggestion += moment(this.timestamp).format('-YYYY-MM-DD-HHmmss'); diff --git a/js/views/file_input_view.js b/js/views/file_input_view.js index 8e81005105de..cd3bb6a0f5f2 100644 --- a/js/views/file_input_view.js +++ b/js/views/file_input_view.js @@ -223,12 +223,17 @@ }, readFile: function(file) { - var contentType = file.type; return new Promise(function(resolve, reject) { var FR = new FileReader(); FR.onload = function(e) { - resolve({data: e.target.result, contentType: contentType}); + resolve({ + data: e.target.result, + contentType: file.type, + fileName: file.name + }); }; + FR.onerror = reject; + FR.onabort = reject; FR.readAsArrayBuffer(file); }); }, diff --git a/libtextsecure/sendmessage.js b/libtextsecure/sendmessage.js index 2be683169fe8..683330ec939a 100644 --- a/libtextsecure/sendmessage.js +++ b/libtextsecure/sendmessage.js @@ -124,6 +124,9 @@ MessageSender.prototype = { proto.id = id; proto.contentType = attachment.contentType; proto.digest = result.digest; + if (attachment.fileName) { + proto.fileName = attachment.fileName; + } return proto; }); }.bind(this)); diff --git a/protos/IncomingPushMessageSignal.proto b/protos/IncomingPushMessageSignal.proto index 50d3fbb1d314..dacbc01357da 100644 --- a/protos/IncomingPushMessageSignal.proto +++ b/protos/IncomingPushMessageSignal.proto @@ -123,6 +123,7 @@ message AttachmentPointer { optional uint32 size = 4; optional bytes thumbnail = 5; optional bytes digest = 6; + optional string fileName = 7; } message GroupContext {