From 85112a0eb7beae412eff6e9c2fe45918025485fd Mon Sep 17 00:00:00 2001 From: Brendan McMillion Date: Mon, 11 Mar 2024 10:02:31 -0700 Subject: [PATCH] Change expiration to expire_at_s --- .../migrations/2024-02-23-182644_add_expiration/down.sql | 2 +- xmtp_mls/migrations/2024-02-23-182644_add_expiration/up.sql | 4 ++-- xmtp_mls/src/storage/encrypted_store/key_store_entry.rs | 6 +++--- xmtp_mls/src/storage/encrypted_store/schema.rs | 2 +- xmtp_mls/src/subscriptions.rs | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/xmtp_mls/migrations/2024-02-23-182644_add_expiration/down.sql b/xmtp_mls/migrations/2024-02-23-182644_add_expiration/down.sql index 9c49163ba..f700c6e84 100644 --- a/xmtp_mls/migrations/2024-02-23-182644_add_expiration/down.sql +++ b/xmtp_mls/migrations/2024-02-23-182644_add_expiration/down.sql @@ -1,4 +1,4 @@ DROP INDEX IF EXISTS key_store_expiration; ALTER TABLE openmls_key_store -DROP COLUMN expiration; +DROP COLUMN expire_at_s; diff --git a/xmtp_mls/migrations/2024-02-23-182644_add_expiration/up.sql b/xmtp_mls/migrations/2024-02-23-182644_add_expiration/up.sql index ed920819b..11c04b2e9 100644 --- a/xmtp_mls/migrations/2024-02-23-182644_add_expiration/up.sql +++ b/xmtp_mls/migrations/2024-02-23-182644_add_expiration/up.sql @@ -1,4 +1,4 @@ ALTER TABLE openmls_key_store -ADD COLUMN expiration BIGINT; +ADD COLUMN expire_at_s BIGINT; -CREATE INDEX IF NOT EXISTS key_store_expiration ON openmls_key_store(expiration); +CREATE INDEX IF NOT EXISTS key_store_expiration ON openmls_key_store(expire_at_s); diff --git a/xmtp_mls/src/storage/encrypted_store/key_store_entry.rs b/xmtp_mls/src/storage/encrypted_store/key_store_entry.rs index 2af1b8d7c..59fa5d479 100644 --- a/xmtp_mls/src/storage/encrypted_store/key_store_entry.rs +++ b/xmtp_mls/src/storage/encrypted_store/key_store_entry.rs @@ -10,7 +10,7 @@ use crate::{impl_fetch, impl_store, Delete}; pub struct StoredKeyStoreEntry { pub key_bytes: Vec, pub value_bytes: Vec, - pub expiration: Option, + pub expire_at_s: Option, } impl_fetch!(StoredKeyStoreEntry, openmls_key_store, Vec); @@ -37,7 +37,7 @@ impl DbConnection<'_> { let entry = StoredKeyStoreEntry { key_bytes: key, value_bytes: value, - expiration: if let Some(e) = exp { + expire_at_s: if let Some(e) = exp { e.try_into().ok() } else { None @@ -54,7 +54,7 @@ impl DbConnection<'_> { .values(entry) .execute(conn)?; // Delete expired entries. - diesel::delete(openmls_key_store.filter(expiration.lt(current_time))).execute(conn) + diesel::delete(openmls_key_store.filter(expire_at_s.lt(current_time))).execute(conn) })?; Ok(()) diff --git a/xmtp_mls/src/storage/encrypted_store/schema.rs b/xmtp_mls/src/storage/encrypted_store/schema.rs index 6bd5d8a69..770c36e65 100644 --- a/xmtp_mls/src/storage/encrypted_store/schema.rs +++ b/xmtp_mls/src/storage/encrypted_store/schema.rs @@ -47,7 +47,7 @@ diesel::table! { openmls_key_store (key_bytes) { key_bytes -> Binary, value_bytes -> Binary, - expiration -> Nullable, + expire_at_s -> Nullable, } } diff --git a/xmtp_mls/src/subscriptions.rs b/xmtp_mls/src/subscriptions.rs index 1dec8c7e0..20a71a98c 100644 --- a/xmtp_mls/src/subscriptions.rs +++ b/xmtp_mls/src/subscriptions.rs @@ -93,7 +93,7 @@ where log::error!("Error rotating key package: {:?}", err); } Some(group) - }, + } Err(err) => { log::error!("Error processing stream entry: {:?}", err); None