diff options
author | fiaxh <git@lightrise.org> | 2020-03-27 19:28:13 +0100 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2020-03-29 20:24:38 +0200 |
commit | c029da49bc20fdaf6da2788fbb83662ec9cf278e (patch) | |
tree | f4185a7985382e5b239c1284c264332c84de3227 /plugins/omemo/src/logic/database.vala | |
parent | a6a92487d6d9cfe8f9923effda0ed66f825dbbd2 (diff) | |
download | dino-c029da49bc20fdaf6da2788fbb83662ec9cf278e.tar.gz dino-c029da49bc20fdaf6da2788fbb83662ec9cf278e.zip |
Warn about undecrypted and untrusted messages
Diffstat (limited to 'plugins/omemo/src/logic/database.vala')
-rw-r--r-- | plugins/omemo/src/logic/database.vala | 30 |
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) |