Post your last.fm now playing to your Bluesky followers

*: be more strict on how we delete kv contents

+14 -3
+14 -3
src/lib.rs
··· 195 195 } 196 196 } 197 197 198 + const KEY_PREFIX: &'static str = "skeetfm_"; 199 + 198 200 #[event(scheduled)] 199 201 async fn scheduled(_evt: ScheduledEvent, _env: Env, _ctx: ScheduleContext) { 200 202 console_error_panic_hook::set_once(); ··· 213 215 let res = kv 214 216 .list() 215 217 .limit(1) 216 - .prefix(kv_key.clone()) 218 + .prefix(format!("{KEY_PREFIX}{}", kv_key.clone())) 217 219 .execute() 218 220 .await 219 221 .unwrap(); ··· 221 223 return; 222 224 } 223 225 224 - kv.delete(&kv_key).await.ok(); 226 + let res = kv 227 + .list() 228 + .prefix(KEY_PREFIX.to_string()) 229 + .execute() 230 + .await 231 + .unwrap(); 232 + 233 + for key in res.keys { 234 + kv.delete(&key.name).await.ok(); 235 + } 225 236 226 237 post_now_playing(np, vars.bsky_username, vars.bsky_password, vars.pds_address).await; 227 238 228 - kv.put(&kv_key, kv_key.clone()) 239 + kv.put(&format!("{KEY_PREFIX}{}", kv_key.clone()), kv_key.clone()) 229 240 .unwrap() 230 241 .execute() 231 242 .await