aboutsummaryrefslogtreecommitdiff
path: root/plugins/omemo/src/logic/database.vala
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/omemo/src/logic/database.vala')
-rw-r--r--plugins/omemo/src/logic/database.vala30
1 files changed, 28 insertions, 2 deletions
diff --git a/plugins/omemo/src/logic/database.vala b/plugins/omemo/src/logic/database.vala
index 7a320696..429b5f0b 100644
--- a/plugins/omemo/src/logic/database.vala
+++ b/plugins/omemo/src/logic/database.vala
@@ -6,7 +6,7 @@ using Dino.Entities;
namespace Dino.Plugins.Omemo {
public class Database : Qlite.Database {
- private const int VERSION = 4;
+ private const int VERSION = 5;
public class IdentityMetaTable : Table {
//Default to provide backwards compatability
@@ -18,10 +18,12 @@ public class Database : Qlite.Database {
public Column<int> trust_level = new Column.Integer("trust_level") { default = TrustLevel.UNKNOWN.to_string(), min_version = 2 };
public Column<bool> now_active = new Column.BoolInt("now_active") { default = "1" };
public Column<long> last_active = new Column.Long("last_active");
+ public Column<long> last_message_untrusted = new Column.Long("last_message_untrusted") { min_version = 5 };
+ public Column<long> last_message_undecryptable = new Column.Long("last_message_undecryptable") { min_version = 5 };
internal IdentityMetaTable(Database db) {
base(db, "identity_meta");
- init({identity_id, address_name, device_id, identity_key_public_base64, trusted_identity, trust_level, now_active, last_active});
+ init({identity_id, address_name, device_id, identity_key_public_base64, trusted_identity, trust_level, now_active, last_active, last_message_untrusted, last_message_undecryptable});
index("identity_meta_idx", {identity_id, address_name, device_id}, true);
index("identity_meta_list_idx", {identity_id, address_name});
}
@@ -78,6 +80,30 @@ public class Database : Qlite.Database {
.value(this.trust_level, trust).perform();
}
+ public void update_last_message_untrusted(int identity_id, int device_id, DateTime? time) {
+ var stmt = update()
+ .with(this.identity_id, "=", identity_id)
+ .with(this.device_id, "=", device_id);
+ if (time != null) {
+ stmt.set(last_message_untrusted, (long)time.to_unix());
+ } else {
+ stmt.set_null(last_message_untrusted);
+ }
+ stmt.perform();
+ }
+
+ public void update_last_message_undecryptable(int identity_id, int device_id, DateTime? time) {
+ var stmt = update()
+ .with(this.identity_id, "=", identity_id)
+ .with(this.device_id, "=", device_id);
+ if (time != null) {
+ stmt.set(last_message_undecryptable, (long)time.to_unix());
+ } else {
+ stmt.set_null(last_message_undecryptable);
+ }
+ stmt.perform();
+ }
+
public QueryBuilder get_trusted_devices(int identity_id, string address_name) {
return this.with_address(identity_id, address_name)
.with(this.trust_level, "!=", TrustLevel.UNTRUSTED)