Skip to content

Commit

Permalink
Change expiration to expire_at_s
Browse files Browse the repository at this point in the history
  • Loading branch information
Bren2010 committed Mar 11, 2024
1 parent 8345016 commit 85112a0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DROP INDEX IF EXISTS key_store_expiration;

ALTER TABLE openmls_key_store
DROP COLUMN expiration;
DROP COLUMN expire_at_s;
4 changes: 2 additions & 2 deletions xmtp_mls/migrations/2024-02-23-182644_add_expiration/up.sql
Original file line number Diff line number Diff line change
@@ -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);
6 changes: 3 additions & 3 deletions xmtp_mls/src/storage/encrypted_store/key_store_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{impl_fetch, impl_store, Delete};
pub struct StoredKeyStoreEntry {
pub key_bytes: Vec<u8>,
pub value_bytes: Vec<u8>,
pub expiration: Option<i64>,
pub expire_at_s: Option<i64>,
}

impl_fetch!(StoredKeyStoreEntry, openmls_key_store, Vec<u8>);
Expand All @@ -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
Expand All @@ -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(())
Expand Down
2 changes: 1 addition & 1 deletion xmtp_mls/src/storage/encrypted_store/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ diesel::table! {
openmls_key_store (key_bytes) {
key_bytes -> Binary,
value_bytes -> Binary,
expiration -> Nullable<BigInt>,
expire_at_s -> Nullable<BigInt>,
}
}

Expand Down
2 changes: 1 addition & 1 deletion xmtp_mls/src/subscriptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ where
log::error!("Error rotating key package: {:?}", err);
}
Some(group)
},
}
Err(err) => {
log::error!("Error processing stream entry: {:?}", err);
None
Expand Down

0 comments on commit 85112a0

Please sign in to comment.