diff options
author | fiaxh <git@lightrise.org> | 2019-12-18 18:23:31 +0100 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2019-12-18 20:35:04 +0100 |
commit | 321c3529f3fedbd5eaa9cd619ee408fb683921ca (patch) | |
tree | 3743e39ee2a8225ed8d1c2bb1259e17b22a1fa47 /libdino/src/service/database.vala | |
parent | 9fe8450571e49aaf376d07b379968c575bc0445c (diff) | |
download | dino-321c3529f3fedbd5eaa9cd619ee408fb683921ca.tar.gz dino-321c3529f3fedbd5eaa9cd619ee408fb683921ca.zip |
Add (partial) support for unique stanza ids (XEP-0359)
Diffstat (limited to 'libdino/src/service/database.vala')
-rw-r--r-- | libdino/src/service/database.vala | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/libdino/src/service/database.vala b/libdino/src/service/database.vala index 60f1b52c..54854fd1 100644 --- a/libdino/src/service/database.vala +++ b/libdino/src/service/database.vala @@ -7,7 +7,7 @@ using Dino.Entities; namespace Dino { public class Database : Qlite.Database { - private const int VERSION = 9; + private const int VERSION = 10; public class AccountTable : Table { public Column<int> id = new Column.Integer("id") { primary_key = true, auto_increment = true }; @@ -55,6 +55,7 @@ public class Database : Qlite.Database { public class MessageTable : Table { public Column<int> id = new Column.Integer("id") { primary_key = true, auto_increment = true }; public Column<string> stanza_id = new Column.Text("stanza_id"); + public Column<string> server_id = new Column.Text("server_id") { min_version=10 }; public Column<int> account_id = new Column.Integer("account_id") { not_null = true }; public Column<int> counterpart_id = new Column.Integer("counterpart_id") { not_null = true }; public Column<string> counterpart_resource = new Column.Text("counterpart_resource"); @@ -69,7 +70,7 @@ public class Database : Qlite.Database { internal MessageTable(Database db) { base(db, "message"); - init({id, stanza_id, account_id, counterpart_id, our_resource, counterpart_resource, direction, + init({id, stanza_id, server_id, account_id, counterpart_id, our_resource, counterpart_resource, direction, type_, time, local_time, body, encryption, marked}); // get latest messages @@ -405,6 +406,14 @@ public class Database : Qlite.Database { return builder.count() > 0; } + public bool contains_message_by_server_id(Account account, Jid counterpart, string server_id) { + QueryBuilder builder = message.select() + .with(message.server_id, "=", server_id) + .with(message.counterpart_id, "=", get_jid_id(counterpart)) + .with(message.account_id, "=", account.id); + return builder.count() > 0; + } + public Message? get_message_by_id(int id) { Row? row = message.row_with(message.id, id).inner; if (row != null) { |