Noreposts Feed

Add enhanced logging to track Jetstream consumer activity

+26 -9
+16 -6
src/jetstream_consumer.rs
··· 3 3 use async_trait::async_trait; 4 4 use chrono::{DateTime, Utc}; 5 5 use std::sync::Arc; 6 - use tracing::{error, warn}; 6 + use tracing::{error, warn, info, debug}; 7 7 8 8 use crate::{database::Database, types::{Follow, Post}}; 9 9 ··· 17 17 } 18 18 19 19 pub async fn start(&self, jetstream_hostname: String) -> Result<()> { 20 + info!("Starting Jetstream consumer, connecting to {}", jetstream_hostname); 21 + 20 22 let config = ConsumerTaskConfig { 21 23 user_agent: "following-no-reposts-feed/1.0".to_string(), 22 24 compression: true, 23 - jetstream_hostname, 25 + jetstream_hostname: jetstream_hostname.clone(), 24 26 zstd_dictionary_location: String::new(), 25 27 collections: vec![ 26 28 "app.bsky.feed.post".to_string(), ··· 33 35 }; 34 36 35 37 let consumer = Consumer::new(config); 38 + info!("Registering event handler..."); 36 39 consumer.register_handler(Arc::new(self.clone())).await?; 37 40 38 41 let cancellation_token = CancellationToken::new(); 42 + info!("Starting Jetstream consumer background task..."); 39 43 40 44 // Start cleanup task 41 45 let db_cleanup = Arc::clone(&self.db); ··· 68 72 if let JetstreamEvent::Commit { did, time_us: _, kind: _, commit } = event { 69 73 match commit.collection.as_str() { 70 74 "app.bsky.feed.post" => { 75 + debug!("Received post event from {}", did); 71 76 self.handle_post_event(&did, &commit.collection, &commit.rkey, &commit.operation, Some(&commit.record), &commit.cid).await?; 72 77 } 73 78 "app.bsky.graph.follow" => { 79 + info!("Received follow event: {} -> target", did); 74 80 self.handle_follow_event(&did, &commit.collection, &commit.rkey, &commit.operation, Some(&commit.record)).await?; 75 81 } 76 82 _ => {} // Ignore other collections ··· 121 127 .with_timezone(&Utc); 122 128 123 129 let post = Post { 124 - uri, 130 + uri: uri.clone(), 125 131 cid: cid.to_string(), 126 132 author_did: did.to_string(), 127 - text, 133 + text: text.clone(), 128 134 created_at, 129 135 indexed_at: Utc::now(), 130 136 }; 131 137 132 138 if let Err(e) = self.db.insert_post(&post).await { 133 139 error!("Failed to insert post: {}", e); 140 + } else { 141 + debug!("Inserted post: {} by {}", uri, did); 134 142 } 135 143 } 136 144 } ··· 174 182 .with_timezone(&Utc); 175 183 176 184 let follow = Follow { 177 - uri, 185 + uri: uri.clone(), 178 186 follower_did: did.to_string(), 179 - target_did, 187 + target_did: target_did.clone(), 180 188 created_at, 181 189 indexed_at: Utc::now(), 182 190 }; 183 191 184 192 if let Err(e) = self.db.insert_follow(&follow).await { 185 193 error!("Failed to insert follow: {}", e); 194 + } else { 195 + info!("Inserted follow: {} -> {}", did, target_did); 186 196 } 187 197 } 188 198 }
+10 -3
src/publish.rs
··· 93 93 record, 94 94 }; 95 95 96 - client 96 + let response = client 97 97 .post(format!("{}/xrpc/com.atproto.repo.putRecord", pds_url)) 98 98 .header("Authorization", format!("Bearer {}", login_response.access_jwt)) 99 99 .json(&put_request) 100 100 .send() 101 - .await? 102 - .error_for_status()?; 101 + .await?; 102 + 103 + if !response.status().is_success() { 104 + let error_text = response.text().await?; 105 + eprintln!("Error response: {}", error_text); 106 + return Err(anyhow!("Failed to publish feed: {}", error_text)); 107 + } 108 + 109 + response.error_for_status()?; 103 110 104 111 println!("\n✅ Feed published successfully!"); 105 112 println!("🔗 Feed AT-URI: at://{}/app.bsky.feed.generator/{}", login_response.did, record_name);