aboutsummaryrefslogtreecommitdiff
path: root/plugins/http-files
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2019-08-21 19:31:46 +0200
committerfiaxh <git@lightrise.org>2019-08-21 22:37:52 +0200
commit0521afa3d828ea0dfc79e6c5c76697e2a3a270c0 (patch)
treeb7d64f2b2e13d01c81621962816d90e8b8e279ca /plugins/http-files
parent3ad2891eb80d9381fed8547d6429904120af1f3e (diff)
downloaddino-0521afa3d828ea0dfc79e6c5c76697e2a3a270c0.tar.gz
dino-0521afa3d828ea0dfc79e6c5c76697e2a3a270c0.zip
Fix specified size for encrypted file uploads
Diffstat (limited to 'plugins/http-files')
-rw-r--r--plugins/http-files/src/file_provider.vala16
-rw-r--r--plugins/http-files/src/file_sender.vala4
2 files changed, 12 insertions, 8 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) {