use map to store more stuff in the json

master
rascul 2 years ago
parent f14b449d13
commit 38b48bdee3

@ -4,7 +4,7 @@ use actix_web::Error;
use chrono::Utc; use chrono::Utc;
use futures_util::StreamExt; use futures_util::StreamExt;
use harsh::Harsh; use harsh::Harsh;
use serde_json::Value; use serde_json::{Map, Value};
use crate::{client, Client}; use crate::{client, Client};
@ -85,13 +85,22 @@ impl WotLog {
/// Read and parse the log /// Read and parse the log
pub fn parse_log(self: &mut Self) -> Result<(), Error> { pub fn parse_log(self: &mut Self) -> Result<(), Error> {
self.json = match self.client { let mut map: Map<String, Value> = Map::new();
Client::Mudlet => client::mudlet::parse_log(&self.raw)?, map.insert("id".into(), self.id.clone().into());
Client::TinTin => Value::Null, map.insert("player".into(), self.player.clone().into());
Client::ZMud => Value::Null, map.insert("title".into(), self.title.clone().into());
Client::None => Value::Null,
match self.client {
Client::Mudlet => {
map.insert("replay".into(), client::mudlet::parse_log(&self.raw)?.into());
}
Client::TinTin => (),
Client::ZMud => (),
Client::None => (),
}; };
self.json = map.into();
Ok(()) Ok(())
} }
} }

Loading…
Cancel
Save