cargo fmt
This commit is contained in:
parent
be8c67ee9a
commit
e9c7259ffb
@ -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(())
|
||||
})
|
||||
}
|
||||
|
@ -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(
|
||||
|
@ -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<ScheduledThreadPool>>>());
|
||||
let searcher = try_outcome!(request.guard::<'_, State<'_, Arc<search::Searcher>>>());
|
||||
let worker =
|
||||
try_outcome!(request.guard::<'_, State<'_, Arc<ScheduledThreadPool>>>());
|
||||
let searcher =
|
||||
try_outcome!(request.guard::<'_, State<'_, Arc<search::Searcher>>>());
|
||||
let flash_msg = request.guard::<FlashMessage<'_, '_>>().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<ScheduledThreadPool>>>());
|
||||
let searcher = try_outcome!(request.guard::<'_, State<'_, Arc<search::Searcher>>>());
|
||||
let worker =
|
||||
try_outcome!(request.guard::<'_, State<'_, Arc<ScheduledThreadPool>>>());
|
||||
let searcher =
|
||||
try_outcome!(request.guard::<'_, State<'_, Arc<search::Searcher>>>());
|
||||
Outcome::Success(PlumeRocket {
|
||||
conn,
|
||||
user: Some(user),
|
||||
|
@ -580,14 +580,11 @@ impl FromId<PlumeRocket> for Post {
|
||||
}
|
||||
});
|
||||
|
||||
let image = article
|
||||
.object_props
|
||||
.icon_object::<Image>()
|
||||
.ok()
|
||||
.unwrap();
|
||||
let image = article.object_props.icon_object::<Image>().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<PlumeRocket> 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()?,
|
||||
|
@ -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::<ApSignature>(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"]
|
||||
|
@ -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;
|
||||
|
@ -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};
|
||||
|
Loading…
Reference in New Issue
Block a user