wip: refactor

This commit is contained in:
2024-12-25 13:44:16 +07:00
parent 37d810d9e5
commit 0745b497f0
13 changed files with 117 additions and 120 deletions

View File

@@ -27,6 +27,21 @@ pub fn get_keys_by_account(public_key: PublicKey) -> Result<Keys, anyhow::Error>
Ok(keys)
}
pub fn get_room_id(owner: &PublicKey, public_keys: &[PublicKey]) -> String {
let hex: Vec<String> = public_keys
.iter()
.map(|m| {
let hex = m.to_hex();
let split = &hex[..6];
split.to_owned()
})
.collect();
let mems = hex.join("-");
format!("{}-{}", &owner.to_hex()[..6], mems)
}
pub fn show_npub(public_key: PublicKey, len: usize) -> String {
let bech32 = public_key.to_bech32().unwrap_or_default();
let separator = " ... ";