aboutsummaryrefslogtreecommitdiff
path: root/plugins/http-files/src/manager.vala
diff options
context:
space:
mode:
authorfiaxh <fiaxh@users.noreply.github.com>2018-08-31 16:25:51 +0200
committerGitHub <noreply@github.com>2018-08-31 16:25:51 +0200
commitecb18afdb51b3230ea451a27a5b345cf5100f02e (patch)
tree44bae666c4cc31afce3a5d6891f6b4f65dfcebb1 /plugins/http-files/src/manager.vala
parent9e93a77a624aed24402cf1ece69c05aaa0aab600 (diff)
parentf5547076d2397cec5c9d7374bd161f93327488c4 (diff)
downloaddino-ecb18afdb51b3230ea451a27a5b345cf5100f02e.tar.gz
dino-ecb18afdb51b3230ea451a27a5b345cf5100f02e.zip
Merge pull request #415 from bobufa/message-search
Message search
Diffstat (limited to 'plugins/http-files/src/manager.vala')
-rw-r--r--plugins/http-files/src/manager.vala23
1 files changed, 10 insertions, 13 deletions
diff --git a/plugins/http-files/src/manager.vala b/plugins/http-files/src/manager.vala
index 7335b89a..9faa8933 100644
--- a/plugins/http-files/src/manager.vala
+++ b/plugins/http-files/src/manager.vala
@@ -81,28 +81,25 @@ public class Manager : StreamInteractionModule, FileSender, Object {
}
}
-public class FileMessageFilterDisplay : Plugins.MessageDisplayProvider, Object {
- public string id { get; set; default="file_message_filter"; }
- public double priority { get; set; default=10; }
-
+public class FileMessageFilter : ContentFilter, Object {
public Database db;
- public FileMessageFilterDisplay(Dino.Database db) {
+ public FileMessageFilter(Dino.Database db) {
this.db = db;
}
- public bool can_display(Entities.Message? message) {
- return message_is_file(db, message);
- }
-
- public Plugins.MetaConversationItem? get_item(Entities.Message message, Conversation conversation) {
- return null;
+ 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;
}
}
private bool message_is_file(Database db, Entities.Message message) {
- Qlite.QueryBuilder builder = db.file_transfer.select().with(db.file_transfer.info, "=", message.id.to_string());
- Qlite.QueryBuilder builder2 = db.file_transfer.select().with(db.file_transfer.info, "=", message.body);
+ 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;
}