diff options
author | fiaxh <git@lightrise.org> | 2019-08-21 19:31:46 +0200 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2019-08-21 22:37:52 +0200 |
commit | 0521afa3d828ea0dfc79e6c5c76697e2a3a270c0 (patch) | |
tree | b7d64f2b2e13d01c81621962816d90e8b8e279ca /plugins | |
parent | 3ad2891eb80d9381fed8547d6429904120af1f3e (diff) | |
download | dino-0521afa3d828ea0dfc79e6c5c76697e2a3a270c0.tar.gz dino-0521afa3d828ea0dfc79e6c5c76697e2a3a270c0.zip |
Fix specified size for encrypted file uploads
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/http-files/src/file_provider.vala | 16 | ||||
-rw-r--r-- | plugins/http-files/src/file_sender.vala | 4 | ||||
-rw-r--r-- | plugins/omemo/src/file_transfer/file_decryptor.vala | 2 |
3 files changed, 13 insertions, 9 deletions
diff --git a/plugins/http-files/src/file_provider.vala b/plugins/http-files/src/file_provider.vala index 38687863..2ce8d96b 100644 --- a/plugins/http-files/src/file_provider.vala +++ b/plugins/http-files/src/file_provider.vala @@ -62,7 +62,7 @@ public class FileProvider : Dino.FileProvider, Object { receive_data.url = message.body; var file_meta = new HttpFileMeta(); - file_meta.file_name = Uri.unescape_string(message.body.substring(message.body.last_index_of("/") + 1)); + file_meta.file_name = extract_file_name_from_url(message.body); file_meta.message = message; file_incoming(additional_info, message.from, message.time, message.local_time, conversation, receive_data, file_meta); @@ -121,11 +121,7 @@ public class FileProvider : Dino.FileProvider, Object { file_meta.size = file_transfer.size; file_meta.mime_type = file_transfer.mime_type; - // Extract file name from URL - file_meta.file_name = Uri.unescape_string(message.body.substring(message.body.last_index_of("/") + 1)); - if (file_meta.file_name.contains("#")) { - file_meta.file_name = file_meta.file_name.substring(0, file_meta.file_name.last_index_of("#")); - } + file_meta.file_name = extract_file_name_from_url(message.body); file_meta.message = message; @@ -145,6 +141,14 @@ public class FileProvider : Dino.FileProvider, Object { return receive_data; } + private string extract_file_name_from_url(string url) { + string ret = Uri.unescape_string(url.substring(url.last_index_of("/") + 1)); + if (ret.contains("#")) { + ret = ret.substring(0, ret.last_index_of("#")); + } + return ret; + } + public int get_id() { return 0; } } diff --git a/plugins/http-files/src/file_sender.vala b/plugins/http-files/src/file_sender.vala index ce40d2f8..3ab0d736 100644 --- a/plugins/http-files/src/file_sender.vala +++ b/plugins/http-files/src/file_sender.vala @@ -17,7 +17,7 @@ public class HttpFileSender : FileSender, Object { stream_interactor.get_module(MessageProcessor.IDENTITY).build_message_stanza.connect(check_add_oob); } - public async FileSendData? prepare_send_file(Conversation conversation, FileTransfer file_transfer) throws FileSendError { + public async FileSendData? prepare_send_file(Conversation conversation, FileTransfer file_transfer, FileMeta file_meta) throws FileSendError { HttpFileSendData send_data = new HttpFileSendData(); if (send_data == null) return null; @@ -25,7 +25,7 @@ public class HttpFileSender : FileSender, Object { if (stream == null) return null; try { - var slot_result = yield stream_interactor.module_manager.get_module(file_transfer.account, Xmpp.Xep.HttpFileUpload.Module.IDENTITY).request_slot(stream, file_transfer.server_file_name, file_transfer.size, file_transfer.mime_type); + var slot_result = yield stream_interactor.module_manager.get_module(file_transfer.account, Xmpp.Xep.HttpFileUpload.Module.IDENTITY).request_slot(stream, file_transfer.server_file_name, file_meta.size, file_meta.mime_type); send_data.url_down = slot_result.url_get; send_data.url_up = slot_result.url_put; } catch (Xep.HttpFileUpload.HttpFileTransferError e) { diff --git a/plugins/omemo/src/file_transfer/file_decryptor.vala b/plugins/omemo/src/file_transfer/file_decryptor.vala index dcb65301..6998fef2 100644 --- a/plugins/omemo/src/file_transfer/file_decryptor.vala +++ b/plugins/omemo/src/file_transfer/file_decryptor.vala @@ -15,7 +15,7 @@ public class OmemoFileDecryptor : FileDecryptor, Object { public FileReceiveData prepare_get_meta_info(Conversation conversation, FileTransfer file_transfer, FileReceiveData receive_data) { HttpFileReceiveData? http_receive_data = receive_data as HttpFileReceiveData; if (http_receive_data == null) assert(false); -// if ((receive_data as OmemoHttpFileReceiveData) != null) return receive_data; + if ((receive_data as OmemoHttpFileReceiveData) != null) return receive_data; var omemo_http_receive_data = new OmemoHttpFileReceiveData(); omemo_http_receive_data.url = aesgcm_to_https_link(http_receive_data.url); |