From a35602b210fd8c542d3ec2d3d96b28bc909d0e36 Mon Sep 17 00:00:00 2001 From: Matthew Esposito Date: Tue, 24 Sep 2024 23:11:29 -0400 Subject: [PATCH] fix(client): catch json suspended user error in better place --- src/client.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/client.rs b/src/client.rs index 9b8450ae..c1de2634 100644 --- a/src/client.rs +++ b/src/client.rs @@ -416,11 +416,14 @@ pub async fn json(path: String, quarantine: bool) -> Result { match serde_json::from_reader(body.reader()) { Ok(value) => { let json: Value = value; - println!("{json:?}"); // If user is suspended - if json["data"]["is_suspended"].as_bool().unwrap_or_default() { - return Err("suspended".into()); + if let Some(data) = json.get("data") { + if let Some(is_suspended) = data.get("is_suspended").and_then(Value::as_bool) { + if is_suspended { + return Err("suspended".into()); + } + } } // If Reddit returned an error