about summary refs log tree commit diff
path: root/src/micropub/post.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/micropub/post.rs')
-rw-r--r--src/micropub/post.rs16
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 {