diff options
author | Vika <vika@fireburn.ru> | 2021-05-04 23:12:59 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2021-05-04 23:12:59 +0300 |
commit | 5b65175710a19daf43c81e52e180fd66ecfe4353 (patch) | |
tree | 40527b7b61a425926fb0b3a34ec782bda4b8d79d /src/micropub/post.rs | |
parent | 1a78c48bd86ff72cc9c7020e69ec9a77302a2f8b (diff) | |
download | kittybox-5b65175710a19daf43c81e52e180fd66ecfe4353.tar.zst |
Clippy lints
Diffstat (limited to 'src/micropub/post.rs')
-rw-r--r-- | src/micropub/post.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/micropub/post.rs b/src/micropub/post.rs index 7ec3566..37cbe26 100644 --- a/src/micropub/post.rs +++ b/src/micropub/post.rs @@ -40,7 +40,7 @@ fn get_folder_from_type(post_type: &str) -> String { }).to_string() } -fn normalize_mf2<'a>(mut body: serde_json::Value, user: &User) -> (String, serde_json::Value) { +fn normalize_mf2(mut body: serde_json::Value, user: &User) -> (String, serde_json::Value) { // Normalize the MF2 object here. let me = &user.me; let published: DateTime<FixedOffset>; @@ -91,7 +91,7 @@ fn normalize_mf2<'a>(mut body: serde_json::Value, user: &User) -> (String, serde match body["properties"]["url"].as_array_mut() { Some(array) => { if !array.iter().any(|i| i.as_str().unwrap_or("") == uid) { - array.push(serde_json::Value::String(uid.to_string())) + array.push(serde_json::Value::String(uid)) } } None => { @@ -126,7 +126,7 @@ fn normalize_mf2<'a>(mut body: serde_json::Value, user: &User) -> (String, serde body["properties"]["channel"] = json!([default_channel]); } body["properties"]["posted-with"] = json!([user.client_id]); - if let None = body["properties"]["author"][0].as_str() { + if body["properties"]["author"][0].as_str().is_none() { body["properties"]["author"] = json!([me.as_str()]) } // TODO: maybe highlight #hashtags? @@ -168,7 +168,7 @@ async fn new_post<S: Storage>(req: Request<ApplicationState<S>>, body: serde_jso for channel in post["properties"]["channel"] .as_array().unwrap().iter() .map(|i| i.as_str().unwrap_or("").to_string()) - .filter(|i| i != "") + .filter(|i| !i.is_empty()) .collect::<Vec<_>>() { let default_channel = user.me.join(DEFAULT_CHANNEL_PATH).unwrap().to_string(); @@ -243,9 +243,9 @@ async fn process_json<S: Storage>(req: Request<ApplicationState<S>>, body: serde return error_json!(400, "invalid_request", "This action is not supported.") } } - } else if let Some(_) = body["type"][0].as_str() { + } else if body["type"][0].is_string() { // This is definitely an h-entry or something similar. Check if it has properties? - if let Some(_) = body["properties"].as_object() { + if body["properties"].is_object() { // Ok, this is definitely a new h-entry. Let's save it. return new_post(req, body).await } else { @@ -269,10 +269,10 @@ fn convert_form_to_mf2_json(form: Vec<(String, String)>) -> serde_json::Value { } } } - if mf2["type"].as_array().unwrap().len() == 0 { + if mf2["type"].as_array().unwrap().is_empty() { mf2["type"].as_array_mut().unwrap().push(json!("h-entry")); } - return mf2 + mf2 } async fn process_form<S: Storage>(req: Request<ApplicationState<S>>, form: Vec<(String, String)>) -> Result { |