match post text value to avoid panic when field is empty

This commit is contained in:
glyph 2022-08-26 08:46:46 +01:00
parent 9434af37b9
commit 8128b32f40
1 changed files with 4 additions and 1 deletions

View File

@ -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();