Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit

Permalink
Add primal image url to wasm model
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Jan 29, 2024
1 parent a8b07f5 commit cbefe8b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions mutiny-wasm/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,8 @@ pub struct TagItem {
lnurl: Option<LnUrl>,
#[serde(skip_serializing_if = "Option::is_none")]
image_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
primal_image_url: Option<String>,
/// Epoch time in seconds when this tag was last used
pub last_used_time: u64,
}
Expand Down Expand Up @@ -753,6 +755,11 @@ impl TagItem {
pub fn image_url(&self) -> Option<String> {
self.image_url.clone()
}

#[wasm_bindgen(getter)]
pub fn primal_image_url(&self) -> Option<String> {
self.primal_image_url.clone()
}
}

impl From<(String, MutinyContact)> for TagItem {
Expand All @@ -764,6 +771,12 @@ impl From<(String, MutinyContact)> for TagItem {
npub: contact.npub.map(|n| n.to_bech32().expect("bech32")),
ln_address: contact.ln_address,
lnurl: contact.lnurl,
primal_image_url: contact.image_url.as_ref().map(|i| {
format!(
"https://primal.b-cdn.net/media-cache?s=s&a=1&u={}",
urlencoding::encode(i)
)
}),
image_url: contact.image_url,
last_used_time: contact.last_used,
}
Expand All @@ -781,6 +794,7 @@ impl From<labels::TagItem> for TagItem {
ln_address: None,
lnurl: None,
image_url: None,
primal_image_url: None,
last_used_time: item.last_used_time,
},
labels::TagItem::Contact(contact) => contact.into(),
Expand Down

0 comments on commit cbefe8b

Please sign in to comment.