diff options
author | fiaxh <git@lightrise.org> | 2021-12-09 15:46:16 +0100 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2021-12-09 15:46:16 +0100 |
commit | fa1ba2f83dcbfbd009b61a6139be2233d729cb89 (patch) | |
tree | 459770198fc38bf2f1620cdfb316a4ba1dff5ff4 /plugins | |
parent | 905f93bcccd26a035cc9d37378b45ff87298adb5 (diff) | |
download | dino-fa1ba2f83dcbfbd009b61a6139be2233d729cb89.tar.gz dino-fa1ba2f83dcbfbd009b61a6139be2233d729cb89.zip |
Remove ContentFilters
fixes #1129 #573
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/http-files/CMakeLists.txt | 1 | ||||
-rw-r--r-- | plugins/http-files/src/file_provider.vala | 13 | ||||
-rw-r--r-- | plugins/http-files/src/file_sender.vala | 14 | ||||
-rw-r--r-- | plugins/http-files/src/message_filter.vala | 23 | ||||
-rw-r--r-- | plugins/http-files/src/plugin.vala | 5 |
5 files changed, 8 insertions, 48 deletions
diff --git a/plugins/http-files/CMakeLists.txt b/plugins/http-files/CMakeLists.txt index 625c215f..77579fdb 100644 --- a/plugins/http-files/CMakeLists.txt +++ b/plugins/http-files/CMakeLists.txt @@ -11,7 +11,6 @@ vala_precompile(HTTP_FILES_VALA_C SOURCES src/file_provider.vala src/file_sender.vala - src/message_filter.vala src/plugin.vala src/register_plugin.vala CUSTOM_VAPIS diff --git a/plugins/http-files/src/file_provider.vala b/plugins/http-files/src/file_provider.vala index cd7b25b7..e3382439 100644 --- a/plugins/http-files/src/file_provider.vala +++ b/plugins/http-files/src/file_provider.vala @@ -23,7 +23,7 @@ public class FileProvider : Dino.FileProvider, Object { private class ReceivedMessageListener : MessageListener { public string[] after_actions_const = new string[]{ "STORE" }; - public override string action_group { get { return ""; } } + public override string action_group { get { return "MESSAGE_REINTERPRETING"; } } public override string[] after_actions { get { return after_actions_const; } } private FileProvider outer; @@ -39,19 +39,14 @@ public class FileProvider : Dino.FileProvider, Object { bool normal_file = oob_url != null && oob_url == message.body && FileProvider.http_url_regex.match(message.body); bool omemo_file = FileProvider.omemo_url_regex.match(message.body); if (normal_file || omemo_file) { - yield outer.on_file_message(message, conversation); + outer.on_file_message(message, conversation); + return true; } return false; } } - private async void on_file_message(Entities.Message message, Conversation conversation) { - // Hide message - ContentItem? content_item = stream_interactor.get_module(ContentItemStore.IDENTITY).get_item(conversation, 1, message.id); - if (content_item != null) { - stream_interactor.get_module(ContentItemStore.IDENTITY).set_item_hide(content_item, true); - } - + private void on_file_message(Entities.Message message, Conversation conversation) { var additional_info = message.id.to_string(); var receive_data = new HttpFileReceiveData(); diff --git a/plugins/http-files/src/file_sender.vala b/plugins/http-files/src/file_sender.vala index a038e70f..e005b8c5 100644 --- a/plugins/http-files/src/file_sender.vala +++ b/plugins/http-files/src/file_sender.vala @@ -42,19 +42,11 @@ public class HttpFileSender : FileSender, Object { yield upload(file_transfer, send_data, file_meta); - file_transfer.info = send_data.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(send_data.url_down, conversation); - - message.encryption = send_data.encrypt_message ? conversation.encryption : Encryption.NONE; - stream_interactor.get_module(MessageProcessor.IDENTITY).send_message(message, conversation); - file_transfer.info = message.id.to_string(); - ContentItem? content_item = stream_interactor.get_module(ContentItemStore.IDENTITY).get_item(conversation, 1, message.id); - if (content_item != null) { - stream_interactor.get_module(ContentItemStore.IDENTITY).set_item_hide(content_item, true); - } + message.encryption = send_data.encrypt_message ? conversation.encryption : Encryption.NONE; + stream_interactor.get_module(MessageProcessor.IDENTITY).send_xmpp_message(message, conversation); } public async bool can_send(Conversation conversation, FileTransfer file_transfer) { @@ -126,7 +118,7 @@ public class HttpFileSender : FileSender, Object { } private void check_add_oob(Entities.Message message, Xmpp.MessageStanza message_stanza, Conversation conversation) { - if (message.encryption == Encryption.NONE && message_is_file(db, message) && message.body.has_prefix("http")) { + if (message.encryption == Encryption.NONE && message.body.has_prefix("http") && message_is_file(db, message)) { Xep.OutOfBandData.add_url_to_message(message_stanza, message_stanza.body); } } diff --git a/plugins/http-files/src/message_filter.vala b/plugins/http-files/src/message_filter.vala deleted file mode 100644 index 01035c4c..00000000 --- a/plugins/http-files/src/message_filter.vala +++ /dev/null @@ -1,23 +0,0 @@ -using Dino.Entities; -using Xmpp; -using Gee; - -namespace Dino.Plugins.HttpFiles { - -public class FileMessageFilter : ContentFilter, Object { - public Database db; - - public FileMessageFilter(Dino.Database db) { - this.db = db; - } - - public bool discard(ContentItem content_item) { - if (content_item.type_ == MessageItem.TYPE) { - MessageItem message_item = content_item as MessageItem; - return message_is_file(db, message_item.message); - } - return false; - } -} - -} diff --git a/plugins/http-files/src/plugin.vala b/plugins/http-files/src/plugin.vala index bdf48770..67b32f65 100644 --- a/plugins/http-files/src/plugin.vala +++ b/plugins/http-files/src/plugin.vala @@ -17,8 +17,6 @@ public class Plugin : RootInterface, Object { app.stream_interactor.get_module(FileManager.IDENTITY).add_provider(file_provider); app.stream_interactor.get_module(FileManager.IDENTITY).add_sender(file_sender); - - app.stream_interactor.get_module(ContentItemStore.IDENTITY).add_filter(new FileMessageFilter(app.db)); } public void shutdown() { @@ -28,8 +26,7 @@ public class Plugin : RootInterface, Object { private bool message_is_file(Database db, Entities.Message message) { Qlite.QueryBuilder builder = db.file_transfer.select({db.file_transfer.id}).with(db.file_transfer.info, "=", message.id.to_string()); - Qlite.QueryBuilder builder2 = db.file_transfer.select({db.file_transfer.id}).with(db.file_transfer.info, "=", message.body); - return builder.count() > 0 || builder2.count() > 0; + return builder.count() > 0; } } |