mirror of
https://github.com/Brandon-Rozek/website-toots.git
synced 2024-11-09 10:40:35 -05:00
Simplified renaming code
This commit is contained in:
parent
e0d4722086
commit
43e24254b8
1 changed files with 6 additions and 13 deletions
|
@ -16,22 +16,15 @@ fn reformat_toot(x: &mut serde_json::Value) -> Result<(), String> {
|
||||||
.ok_or_else(|| "JSON not an object".to_string())?;
|
.ok_or_else(|| "JSON not an object".to_string())?;
|
||||||
|
|
||||||
// URL -> Syndication
|
// URL -> Syndication
|
||||||
let toot_url: serde_json::Value = toot
|
|
||||||
.get_mut("url")
|
|
||||||
.ok_or_else(|| "Missing URL".to_string())?
|
|
||||||
.to_owned();
|
|
||||||
toot.remove("uri");
|
toot.remove("uri");
|
||||||
toot.remove("url");
|
let toot_url = toot.remove("url")
|
||||||
toot.insert("syndication".to_string(), toot_url.to_owned());
|
.ok_or_else(|| "Missing URL".to_string())?;
|
||||||
|
toot.insert("syndication".to_string(), toot_url);
|
||||||
|
|
||||||
// Created At -> Date
|
// Created At -> Date
|
||||||
let toot_date: serde_json::Value = toot
|
let toot_date = toot.remove("created_at")
|
||||||
.get_mut("created_at")
|
.ok_or_else(|| "Missing created_at".to_string())?;
|
||||||
.ok_or_else(|| "Missing created_at".to_string())?
|
toot.insert("date".to_string(), toot_date);
|
||||||
.to_owned();
|
|
||||||
// Note: Already checked whether created_at exists
|
|
||||||
toot.remove("created_at");
|
|
||||||
toot.insert("date".to_string(), toot_date.to_owned());
|
|
||||||
|
|
||||||
// Strip out highly dynamic account information
|
// Strip out highly dynamic account information
|
||||||
let account: &mut tera::Map<String, serde_json::Value> = toot
|
let account: &mut tera::Map<String, serde_json::Value> = toot
|
||||||
|
|
Loading…
Reference in a new issue