From 8128b32f404aaf6e96b77e358ff4d9e8f8a338d0 Mon Sep 17 00:00:00 2001 From: glyph Date: Fri, 26 Aug 2022 08:46:46 +0100 Subject: [PATCH] match post text value to avoid panic when field is empty --- src/sbot.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sbot.rs b/src/sbot.rs index c5b7134..ac0cdf3 100644 --- a/src/sbot.rs +++ b/src/sbot.rs @@ -185,7 +185,10 @@ pub async fn get_root_posts( if !content_map.contains_key("root") { latest_sequence = msg.value.sequence; - let text = content_map.get_key_value("text").unwrap().1.to_string(); + let text = match content_map.get_key_value("text") { + Some(value) => value.1.to_string(), + None => String::from(""), + }; let timestamp = msg.value.timestamp.round() as i64 / 1000; let datetime = NaiveDateTime::from_timestamp(timestamp, 0); let date = datetime.format("%d %b %Y").to_string();