don't
5
fork

Configure Feed

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

fix(knot,jetstream): filter collections

Signed-off-by: tjh <x@tjh.dev>

tjh 030d9596 6d179eb0

+22 -1
+19
crates/jetstream/src/client_config.rs
··· 79 79 self.subscriber_options.cursor = cursor; 80 80 self 81 81 } 82 + 83 + /// Add the specified collection filters to the config. 84 + /// 85 + /// # Panics 86 + /// 87 + /// Panics if a collection is not a valid NSID or if the maximum number of filters is 88 + /// exceeded. 89 + /// 90 + pub fn with_collections<'a>(mut self, collections: impl IntoIterator<Item = &'a str>) -> Self { 91 + for collection in collections { 92 + let collection = collection 93 + .parse() 94 + .expect("collection filter should be valid"); 95 + self.subscriber_options 96 + .add_collection(collection) 97 + .expect("collection filters count should not exceed maximum"); 98 + } 99 + self 100 + } 82 101 } 83 102 84 103 #[cfg(test)]
+3 -1
crates/knot/src/main.rs
··· 211 211 tracing::info!(?cursor, ?cursor_us, "found jetstream cursor"); 212 212 } 213 213 214 - let mut config = JetstreamConfig::default().with_cursor(cursor.map(|(_, us)| us)); 214 + let mut config = JetstreamConfig::default() 215 + .with_cursor(cursor.map(|(_, us)| us)) 216 + .with_collections(["sh.tangled.publicKey", "sh.tangled.repo"]); 215 217 216 218 let mut records = sqlx::query!( 217 219 "SELECT DISTINCT did FROM knot_member UNION SELECT DISTINCT did FROM repository_member"