Changeset View
Changeset View
Standalone View
Standalone View
services/identity/src/ddb_utils.rs
use aws_sdk_dynamodb::model::{AttributeValue, PutRequest, WriteRequest}; | use aws_sdk_dynamodb::model::{AttributeValue, PutRequest, WriteRequest}; | ||||
use std::collections::HashMap; | use std::collections::HashMap; | ||||
use std::iter::IntoIterator; | use std::iter::IntoIterator; | ||||
#[derive(Copy, Clone, Debug)] | #[derive(Copy, Clone, Debug)] | ||||
pub enum OlmAccountType { | pub enum OlmAccountType { | ||||
Content, | Content, | ||||
Notification, | Notification, | ||||
} | } | ||||
// Prefix the onetime keys with the olm account variant. This allows for a single | // Prefix the onetime keys with the olm account variant. This allows for a single | ||||
// DDB table to contain both notification and content keys for a device. | // DDB table to contain both notification and content keys for a device. | ||||
fn create_onetime_key_partition_key( | pub fn create_onetime_key_partition_key( | ||||
device_id: &str, | device_id: &str, | ||||
account_type: OlmAccountType, | account_type: OlmAccountType, | ||||
) -> String { | ) -> String { | ||||
match account_type { | match account_type { | ||||
OlmAccountType::Content => format!("content_{device_id}"), | OlmAccountType::Content => format!("content_{device_id}"), | ||||
OlmAccountType::Notification => format!("notification_{device_id}"), | OlmAccountType::Notification => format!("notification_{device_id}"), | ||||
} | } | ||||
} | } | ||||
Show All 36 Lines |