relay filter/appview bootstrap
at main 874 B view raw
1use serde::Serialize; 2 3use super::Record; 4 5#[derive(Debug, Serialize)] 6pub struct ChannelView { 7 pub uri: String, 8 pub cid: String, 9 pub author: String, 10 #[serde(rename = "displayName")] 11 pub display_name: String, 12 pub description: Option<String>, 13 #[serde(rename = "createdAt")] 14 pub created_at: String, 15 #[serde(rename = "indexedAt")] 16 pub indexed_at: String, 17} 18 19impl From<Record> for ChannelView { 20 fn from(r: Record) -> Self { 21 Self { 22 uri: r.uri, 23 cid: r.cid, 24 author: r.creator_did, 25 display_name: r.data.get("name").and_then(|v| v.as_str()).unwrap_or_default().to_string(), 26 description: r.data.get("topic").and_then(|v| v.as_str()).map(String::from), 27 created_at: r.created_at.to_rfc3339(), 28 indexed_at: r.indexed_at.to_rfc3339(), 29 } 30 } 31}