aboutsummaryrefslogtreecommitdiff
path: root/libdino/src
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2018-03-07 21:17:15 +0100
committerfiaxh <git@mx.ax.lt>2018-03-10 20:01:22 +0100
commitc6ff25cc7a410416ab3f83565205d4841c97e4cb (patch)
treec41fead90fd075249ed5dd7181bb6b6f8cf94e9c /libdino/src
parentc8f68678be021d52a1fbc4efeba890b203123ef1 (diff)
downloaddino-c6ff25cc7a410416ab3f83565205d4841c97e4cb.tar.gz
dino-c6ff25cc7a410416ab3f83565205d4841c97e4cb.zip
Only assume UUID to be unique for one counterpart+account when deduplicating
Diffstat (limited to 'libdino/src')
-rw-r--r--libdino/src/service/database.vala22
-rw-r--r--libdino/src/service/message_processor.vala2
2 files changed, 17 insertions, 7 deletions
diff --git a/libdino/src/service/database.vala b/libdino/src/service/database.vala
index c668ce17..25db82f8 100644
--- a/libdino/src/service/database.vala
+++ b/libdino/src/service/database.vala
@@ -273,7 +273,6 @@ public class Database : Qlite.Database {
QueryBuilder builder = message.select()
.with(message.account_id, "=", account.id)
.with(message.counterpart_id, "=", get_jid_id(query_message.counterpart))
- .with(message.counterpart_resource, "=", query_message.counterpart.resourcepart)
.with(message.body, "=", query_message.body)
.with(message.time, "<", (long) query_message.time.add_minutes(1).to_unix())
.with(message.time, ">", (long) query_message.time.add_minutes(-1).to_unix());
@@ -282,14 +281,25 @@ public class Database : Qlite.Database {
} else {
builder.with_null(message.stanza_id);
}
+ if (query_message.counterpart.resourcepart != null) {
+ builder.with(message.counterpart_resource, "=", query_message.counterpart.resourcepart);
+ } else {
+ builder.with_null(message.counterpart_resource);
+ }
return builder.count() > 0;
}
- public bool contains_message_by_stanza_id(string stanza_id, Account account) {
- return message.select()
- .with(message.stanza_id, "=", stanza_id)
- .with(message.account_id, "=", account.id)
- .count() > 0;
+ public bool contains_message_by_stanza_id(Message query_message, Account account) {
+ QueryBuilder builder = message.select()
+ .with(message.stanza_id, "=", query_message.stanza_id)
+ .with(message.counterpart_id, "=", get_jid_id(query_message.counterpart))
+ .with(message.account_id, "=", account.id);
+ if (query_message.counterpart.resourcepart != null) {
+ builder.with(message.counterpart_resource, "=", query_message.counterpart.resourcepart);
+ } else {
+ builder.with_null(message.counterpart_resource);
+ }
+ return builder.count() > 0;
}
public Message? get_message_by_id(int id) {
diff --git a/libdino/src/service/message_processor.vala b/libdino/src/service/message_processor.vala
index 14db0132..d0e3e79a 100644
--- a/libdino/src/service/message_processor.vala
+++ b/libdino/src/service/message_processor.vala
@@ -171,7 +171,7 @@ public class MessageProcessor : StreamInteractionModule, Object {
public override async bool run(Entities.Message message, Xmpp.MessageStanza stanza, Conversation conversation) {
bool is_uuid = message.stanza_id != null && Regex.match_simple("""[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}""", message.stanza_id);
- bool new_uuid_msg = is_uuid && !db.contains_message_by_stanza_id(message.stanza_id, conversation.account);
+ bool new_uuid_msg = is_uuid && !db.contains_message_by_stanza_id(message, conversation.account);
bool new_misc_msg = !is_uuid && !db.contains_message(message, conversation.account);
bool new_msg = new_uuid_msg || new_misc_msg;
return !new_msg;