aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service/database.vala
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/service/database.vala
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/service/database.vala')
-rw-r--r--libdino/src/service/database.vala22
1 files changed, 16 insertions, 6 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) {