diff --git a/plume-models/src/api_tokens.rs b/plume-models/src/api_tokens.rs index bcf49646..84aefbf8 100644 --- a/plume-models/src/api_tokens.rs +++ b/plume-models/src/api_tokens.rs @@ -95,7 +95,10 @@ impl<'a, 'r> FromRequestAsync<'a, 'r> for ApiToken { return Outcome::Success(token); } } else { - return Outcome::Failure((Status::InternalServerError, TokenError::DbError)); + return Outcome::Failure(( + Status::InternalServerError, + TokenError::DbError, + )); } } } else { @@ -105,7 +108,6 @@ impl<'a, 'r> FromRequestAsync<'a, 'r> for ApiToken { return Outcome::Failure((Status::BadRequest, TokenError::NoType)); } - Outcome::Forward(()) }) } diff --git a/plume-models/src/medias.rs b/plume-models/src/medias.rs index 6c401366..c0c60aa8 100644 --- a/plume-models/src/medias.rs +++ b/plume-models/src/medias.rs @@ -213,10 +213,7 @@ impl Media { )); let mut dest = tokio::fs::File::create(path.clone()).await?; - let contents = reqwest::get(remote_url.as_str()) - .await? - .bytes() - .await?; + let contents = reqwest::get(remote_url.as_str()).await?.bytes().await?; dest.write_all(&contents).await?; Media::insert( diff --git a/plume-models/src/plume_rocket.rs b/plume-models/src/plume_rocket.rs index 358339ac..5be466e7 100644 --- a/plume-models/src/plume_rocket.rs +++ b/plume-models/src/plume_rocket.rs @@ -23,13 +23,17 @@ mod module { impl<'a, 'r> FromRequestAsync<'a, 'r> for PlumeRocket { type Error = (); - fn from_request(request: &'a Request<'r>) -> request::FromRequestFuture<'a, Self, Self::Error> { + fn from_request( + request: &'a Request<'r>, + ) -> request::FromRequestFuture<'a, Self, Self::Error> { Box::pin(async move { let conn = try_outcome!(DbConn::from_request(request).await); let intl = try_outcome!(rocket_i18n::I18n::from_request(request).await); let user = try_outcome!(users::User::from_request(request).await); - let worker = try_outcome!(request.guard::<'_, State<'_, Arc>>()); - let searcher = try_outcome!(request.guard::<'_, State<'_, Arc>>()); + let worker = + try_outcome!(request.guard::<'_, State<'_, Arc>>()); + let searcher = + try_outcome!(request.guard::<'_, State<'_, Arc>>()); let flash_msg = request.guard::>().succeeded(); Outcome::Success(PlumeRocket { conn, @@ -65,12 +69,16 @@ mod module { impl<'a, 'r> FromRequestAsync<'a, 'r> for PlumeRocket { type Error = (); - fn from_request(request: &'a Request<'r>) -> request::FromRequestFuture<'a, Self, Self::Error> { + fn from_request( + request: &'a Request<'r>, + ) -> request::FromRequestFuture<'a, Self, Self::Error> { Box::pin(async move { let conn = try_outcome!(DbConn::from_request(request).await); let user = try_outcome!(users::User::from_request(request).await); - let worker = try_outcome!(request.guard::<'_, State<'_, Arc>>()); - let searcher = try_outcome!(request.guard::<'_, State<'_, Arc>>()); + let worker = + try_outcome!(request.guard::<'_, State<'_, Arc>>()); + let searcher = + try_outcome!(request.guard::<'_, State<'_, Arc>>()); Outcome::Success(PlumeRocket { conn, user: Some(user), diff --git a/plume-models/src/posts.rs b/plume-models/src/posts.rs index b562fe4b..92b3f5a9 100644 --- a/plume-models/src/posts.rs +++ b/plume-models/src/posts.rs @@ -580,14 +580,11 @@ impl FromId for Post { } }); - let image = article - .object_props - .icon_object::() - .ok() - .unwrap(); + let image = article.object_props.icon_object::().ok().unwrap(); let mut r = Runtime::new().unwrap(); - let cover = Some(r.block_on(async {Media::from_activity(&c, &image).await.ok().unwrap().id})); + let cover = + Some(r.block_on(async { Media::from_activity(&c, &image).await.ok().unwrap().id })); let title = article.object_props.name_string()?; let post = Post::insert( @@ -710,7 +707,8 @@ impl FromId for PostUpdate { .ok() .unwrap(); let mut r = Runtime::new().unwrap(); - let cover = Some(r.block_on(async {Media::from_activity(&c, &image).await.ok().unwrap().id})); + let cover = + Some(r.block_on(async { Media::from_activity(&c, &image).await.ok().unwrap().id })); Ok(PostUpdate { ap_url: updated.object.object_props.id_string()?, diff --git a/plume-models/src/users.rs b/plume-models/src/users.rs index 2ad04139..adc529b3 100644 --- a/plume-models/src/users.rs +++ b/plume-models/src/users.rs @@ -235,7 +235,8 @@ impl User { .join(", "), )?, ) - .send().await?; + .send() + .await?; let text = &res.text().await?; // without this workaround, publicKey is not correctly deserialized let ap_sign = serde_json::from_str::(text)?; @@ -371,7 +372,8 @@ impl User { .join(", "), )?, ) - .send().await?; + .send() + .await?; let text = &res.text().await?; let json: serde_json::Value = serde_json::from_str(text)?; let items = json["items"] @@ -401,7 +403,8 @@ impl User { .join(", "), )?, ) - .send().await?; + .send() + .await?; let text = &res.text().await?; let json: serde_json::Value = serde_json::from_str(text)?; if let Some(first) = json.get("first") { @@ -446,7 +449,8 @@ impl User { .join(", "), )?, ) - .send().await?; + .send() + .await?; let text = &res.text().await?; let json: serde_json::Value = serde_json::from_str(text)?; Ok(json["items"] diff --git a/src/api/mod.rs b/src/api/mod.rs index 58d0fec3..2a53b19a 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -32,15 +32,15 @@ impl<'r> Responder<'r> for ApiError { Error::NotFound => Json(json!({ "error": "Not found" })) - .respond_to(req), + .respond_to(req), Error::Unauthorized => Json(json!({ "error": "You are not authorized to access this resource" })) - .respond_to(req), + .respond_to(req), _ => Json(json!({ "error": "Server error" })) - .respond_to(req), + .respond_to(req), } } } diff --git a/src/routes/instance.rs b/src/routes/instance.rs index 59407720..a4897cff 100644 --- a/src/routes/instance.rs +++ b/src/routes/instance.rs @@ -6,8 +6,8 @@ use rocket_contrib::json::Json; use rocket_i18n::I18n; use scheduled_thread_pool::ScheduledThreadPool; use serde_json; -use std::str::FromStr; use std::path::PathBuf; +use std::str::FromStr; use validator::{Validate, ValidationErrors}; use crate::inbox; diff --git a/src/routes/posts.rs b/src/routes/posts.rs index c10ae0da..9b295b2f 100644 --- a/src/routes/posts.rs +++ b/src/routes/posts.rs @@ -11,7 +11,7 @@ use std::{ use validator::{Validate, ValidationError, ValidationErrors}; use crate::routes::{ - comments::NewCommentForm, errors::ErrorPage, Page, ContentLen, RemoteForm, RespondOrRedirect, + comments::NewCommentForm, errors::ErrorPage, ContentLen, Page, RemoteForm, RespondOrRedirect, }; use crate::template_utils::{IntoContext, Ructe}; use plume_common::activity_pub::{broadcast, ActivityStream, ApRequest};