···2323use hydrant::config::Config;
2424use hydrant::control::{EventStream, Hydrant, ReposControl};
2525use hydrant::filter::FilterMode;
2626+use jacquard_common::types::did::Did;
2627use jacquard_common::types::tid::Tid;
2728use scc::HashMap;
2829···101102}
102103103104async fn handle_stream(index: Arc<StatusIndex>, repos: ReposControl, mut stream: EventStream) {
105105+ // get handle of did through the hydrant api
106106+ let get_handle = async |did: &Did<'_>| {
107107+ repos
108108+ .get(did)
109109+ .await
110110+ .ok()
111111+ .flatten()
112112+ .and_then(|info| info.handle)
113113+ .unwrap_or_else(|| did.to_string())
114114+ };
104115 while let Some(event) = stream.next().await {
105116 if let Some(rec) = event.record {
106117 let did = rec.did.as_str().to_owned();
···119130 .and_then(|v| v.as_str())
120131 .unwrap_or("");
121132 if index.set(did.clone(), emoji.clone(), created_at) {
122122- let name = repos
123123- .get(&rec.did)
124124- .await
125125- .ok()
126126- .flatten()
127127- .and_then(|info| info.handle)
128128- .unwrap_or(did);
133133+ let name = get_handle(&rec.did).await;
129134 println!("[{created_at}] {name}: {emoji}");
130135 }
131136 }
132137 "delete" => {
133133- let name = repos
134134- .get(&rec.did)
135135- .await
136136- .ok()
137137- .flatten()
138138- .and_then(|info| info.handle)
139139- .unwrap_or(did.clone());
138138+ let name = get_handle(&rec.did).await;
140139 index.delete(&did);
140140+ // parse the tid to use as date since createdAt doesnt make sense here
141141 let date = Tid::from_str(&rec.rkey)
142142 .ok()
143143 .and_then(|tid| DateTime::from_timestamp_micros(tid.timestamp() as i64))
···183183184184 let index = Arc::new(StatusIndex::new());
185185 tokio::select! {
186186+ // this finally starts hydrant, so it will start crawling and backfilling etc.
186187 r = hydrant.run() => r,
187188 _ = run_ticker(index.clone()) => Ok(()),
188189 _ = handle_stream(index.clone(), hydrant.repos.clone(), stream) => Ok(()),