aboutsummaryrefslogtreecommitdiff
path: root/plugins/http-files/src
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2018-11-27 14:57:52 +0100
committerfiaxh <git@lightrise.org>2018-11-27 15:02:18 +0100
commit141db9e40a3a81cfa3ad3587dc47f69c541d0fde (patch)
treeaf02d0049c24abcdbf7b15f1c1037114319c7d73 /plugins/http-files/src
parent01360a73ae8a148ca19c75e3b11167965b887d8b (diff)
downloaddino-141db9e40a3a81cfa3ad3587dc47f69c541d0fde.tar.gz
dino-141db9e40a3a81cfa3ad3587dc47f69c541d0fde.zip
Implement aesgcm encrypted file upload
Diffstat (limited to 'plugins/http-files/src')
-rw-r--r--plugins/http-files/src/file_provider.vala5
-rw-r--r--plugins/http-files/src/manager.vala6
2 files changed, 3 insertions, 8 deletions
diff --git a/plugins/http-files/src/file_provider.vala b/plugins/http-files/src/file_provider.vala
index a0fe1218..19d34bb0 100644
--- a/plugins/http-files/src/file_provider.vala
+++ b/plugins/http-files/src/file_provider.vala
@@ -13,17 +13,12 @@ public class FileProvider : Dino.FileProvider, Object {
private Dino.Database dino_db;
private Regex url_regex;
- private Gee.List<string> ignore_once = new ArrayList<string>();
-
public FileProvider(StreamInteractor stream_interactor, Dino.Database dino_db) {
this.stream_interactor = stream_interactor;
this.dino_db = dino_db;
this.url_regex = new Regex("""^(?i)\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))$""");
stream_interactor.get_module(MessageProcessor.IDENTITY).received_pipeline.connect(new ReceivedMessageListener(this));
- stream_interactor.get_module(Manager.IDENTITY).uploaded.connect((file_transfer, url) => {
- ignore_once.add(url);
- });
}
private class ReceivedMessageListener : MessageListener {
diff --git a/plugins/http-files/src/manager.vala b/plugins/http-files/src/manager.vala
index b5aa0d26..96490bb1 100644
--- a/plugins/http-files/src/manager.vala
+++ b/plugins/http-files/src/manager.vala
@@ -71,7 +71,7 @@ public class Manager : StreamInteractionModule, FileSender, Object {
upload(stream, file_transfer,
(stream, url_down) => {
uploaded(file_transfer, url_down);
- file_transfer.info = url_down;
+ file_transfer.info = url_down; // store the message content temporarily so the message gets filtered out
Entities.Message message = stream_interactor.get_module(MessageProcessor.IDENTITY).create_out_message(url_down, conversation);
message.encryption = Encryption.NONE;
stream_interactor.get_module(MessageProcessor.IDENTITY).send_message(message, conversation);
@@ -91,7 +91,7 @@ public class Manager : StreamInteractionModule, FileSender, Object {
}
public bool can_send(Conversation conversation, FileTransfer file_transfer) {
- return true;
+ return file_transfer.encryption != Encryption.OMEMO;
}
public bool is_upload_available(Conversation conversation) {
@@ -116,7 +116,7 @@ public class Manager : StreamInteractionModule, FileSender, Object {
}
private void check_add_oob(Entities.Message message, Xmpp.MessageStanza message_stanza, Conversation conversation) {
- if (message_is_file(db, message)) {
+ if (message_is_file(db, message) && message.body.has_prefix("http")) {
Xep.OutOfBandData.add_url_to_message(message_stanza, message_stanza.body);
}
}