Parakeet is a Rust-based Bluesky AppServer aiming to implement most of the functionality required to support the Bluesky client
appview atproto bluesky rust appserver
66
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(consumer): handle resolution, as it turns out, wasn't correct.

Mia 5ce5276e 235b620a

+26 -11
+26 -11
consumer/src/indexer/mod.rs
··· 187 187 did: &str, 188 188 expected_handle: Option<String>, 189 189 ) -> eyre::Result<Option<Option<String>>> { 190 + // Resolve the did doc 190 191 let Some(did_doc) = state.resolver.resolve_did(did).await? else { 191 192 eyre::bail!("missing did doc"); 192 193 }; 193 194 194 - let Some(handle) = did_doc 195 - .also_known_as 196 - .and_then(|aka| aka.first().cloned()) 197 - .and_then(|handle| handle.strip_prefix("at://").map(String::from)) 198 - else { 199 - eyre::bail!("DID doc contained no handle"); 200 - }; 195 + // if there's no handles in aka or the expected is none, set to none in DB. 196 + if did_doc.also_known_as.as_ref().is_none_or(|v| v.is_empty()) || expected_handle.is_none() { 197 + return Ok(Some(None)); 198 + } 199 + 200 + let expected = expected_handle.unwrap(); 201 + 202 + // check if the handle from the event is in the did doc 203 + let expected_in_doc = did_doc.also_known_as.is_some_and(|v| { 204 + v.iter() 205 + .filter_map(|v| v.strip_prefix("at://")) 206 + .find(|v| v == &expected) 207 + .is_some() 208 + }); 209 + 210 + // if it isn't, set to invalid. 211 + if !expected_in_doc { 212 + tracing::warn!("Handle not in DID doc"); 213 + return Ok(Some(None)); 214 + } 201 215 202 216 // in theory, we can use com.atproto.identity.resolveHandle against a PDS, but that seems 203 217 // like a way to end up with really sus handles. 204 - let Some(handle_did) = state.resolver.resolve_handle(&handle).await? else { 205 - eyre::bail!("Failed to resolve did for handle {handle}"); 218 + let Some(handle_did) = state.resolver.resolve_handle(&expected).await? else { 219 + Ok(Some(None)) 206 220 }; 207 221 222 + // finally, check if the event did matches the handle, if not, set invalid, otherwise set the handle. 208 223 if handle_did != did { 209 - Ok(None) 224 + Ok(Some(None)) 210 225 } else { 211 - Ok(Some(expected_handle)) 226 + Ok(Some(Some(expected))) 212 227 } 213 228 } 214 229