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);
|
return Outcome::Success(token);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Outcome::Failure((Status::InternalServerError, TokenError::DbError));
|
return Outcome::Failure((
|
||||||
|
Status::InternalServerError,
|
||||||
|
TokenError::DbError,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -105,7 +108,6 @@ impl<'a, 'r> FromRequestAsync<'a, 'r> for ApiToken {
|
|||||||
return Outcome::Failure((Status::BadRequest, TokenError::NoType));
|
return Outcome::Failure((Status::BadRequest, TokenError::NoType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Outcome::Forward(())
|
Outcome::Forward(())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -213,10 +213,7 @@ impl Media {
|
|||||||
));
|
));
|
||||||
|
|
||||||
let mut dest = tokio::fs::File::create(path.clone()).await?;
|
let mut dest = tokio::fs::File::create(path.clone()).await?;
|
||||||
let contents = reqwest::get(remote_url.as_str())
|
let contents = reqwest::get(remote_url.as_str()).await?.bytes().await?;
|
||||||
.await?
|
|
||||||
.bytes()
|
|
||||||
.await?;
|
|
||||||
dest.write_all(&contents).await?;
|
dest.write_all(&contents).await?;
|
||||||
|
|
||||||
Media::insert(
|
Media::insert(
|
||||||
|
@ -23,13 +23,17 @@ mod module {
|
|||||||
impl<'a, 'r> FromRequestAsync<'a, 'r> for PlumeRocket {
|
impl<'a, 'r> FromRequestAsync<'a, 'r> for PlumeRocket {
|
||||||
type Error = ();
|
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 {
|
Box::pin(async move {
|
||||||
let conn = try_outcome!(DbConn::from_request(request).await);
|
let conn = try_outcome!(DbConn::from_request(request).await);
|
||||||
let intl = try_outcome!(rocket_i18n::I18n::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 user = try_outcome!(users::User::from_request(request).await);
|
||||||
let worker = try_outcome!(request.guard::<'_, State<'_, Arc<ScheduledThreadPool>>>());
|
let worker =
|
||||||
let searcher = try_outcome!(request.guard::<'_, State<'_, Arc<search::Searcher>>>());
|
try_outcome!(request.guard::<'_, State<'_, Arc<ScheduledThreadPool>>>());
|
||||||
|
let searcher =
|
||||||
|
try_outcome!(request.guard::<'_, State<'_, Arc<search::Searcher>>>());
|
||||||
let flash_msg = request.guard::<FlashMessage<'_, '_>>().succeeded();
|
let flash_msg = request.guard::<FlashMessage<'_, '_>>().succeeded();
|
||||||
Outcome::Success(PlumeRocket {
|
Outcome::Success(PlumeRocket {
|
||||||
conn,
|
conn,
|
||||||
@ -65,12 +69,16 @@ mod module {
|
|||||||
impl<'a, 'r> FromRequestAsync<'a, 'r> for PlumeRocket {
|
impl<'a, 'r> FromRequestAsync<'a, 'r> for PlumeRocket {
|
||||||
type Error = ();
|
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 {
|
Box::pin(async move {
|
||||||
let conn = try_outcome!(DbConn::from_request(request).await);
|
let conn = try_outcome!(DbConn::from_request(request).await);
|
||||||
let user = try_outcome!(users::User::from_request(request).await);
|
let user = try_outcome!(users::User::from_request(request).await);
|
||||||
let worker = try_outcome!(request.guard::<'_, State<'_, Arc<ScheduledThreadPool>>>());
|
let worker =
|
||||||
let searcher = try_outcome!(request.guard::<'_, State<'_, Arc<search::Searcher>>>());
|
try_outcome!(request.guard::<'_, State<'_, Arc<ScheduledThreadPool>>>());
|
||||||
|
let searcher =
|
||||||
|
try_outcome!(request.guard::<'_, State<'_, Arc<search::Searcher>>>());
|
||||||
Outcome::Success(PlumeRocket {
|
Outcome::Success(PlumeRocket {
|
||||||
conn,
|
conn,
|
||||||
user: Some(user),
|
user: Some(user),
|
||||||
|
@ -580,14 +580,11 @@ impl FromId<PlumeRocket> for Post {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let image = article
|
let image = article.object_props.icon_object::<Image>().ok().unwrap();
|
||||||
.object_props
|
|
||||||
.icon_object::<Image>()
|
|
||||||
.ok()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let mut r = Runtime::new().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 title = article.object_props.name_string()?;
|
||||||
let post = Post::insert(
|
let post = Post::insert(
|
||||||
@ -710,7 +707,8 @@ impl FromId<PlumeRocket> for PostUpdate {
|
|||||||
.ok()
|
.ok()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mut r = Runtime::new().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 {
|
Ok(PostUpdate {
|
||||||
ap_url: updated.object.object_props.id_string()?,
|
ap_url: updated.object.object_props.id_string()?,
|
||||||
|
@ -235,7 +235,8 @@ impl User {
|
|||||||
.join(", "),
|
.join(", "),
|
||||||
)?,
|
)?,
|
||||||
)
|
)
|
||||||
.send().await?;
|
.send()
|
||||||
|
.await?;
|
||||||
let text = &res.text().await?;
|
let text = &res.text().await?;
|
||||||
// without this workaround, publicKey is not correctly deserialized
|
// without this workaround, publicKey is not correctly deserialized
|
||||||
let ap_sign = serde_json::from_str::<ApSignature>(text)?;
|
let ap_sign = serde_json::from_str::<ApSignature>(text)?;
|
||||||
@ -371,7 +372,8 @@ impl User {
|
|||||||
.join(", "),
|
.join(", "),
|
||||||
)?,
|
)?,
|
||||||
)
|
)
|
||||||
.send().await?;
|
.send()
|
||||||
|
.await?;
|
||||||
let text = &res.text().await?;
|
let text = &res.text().await?;
|
||||||
let json: serde_json::Value = serde_json::from_str(text)?;
|
let json: serde_json::Value = serde_json::from_str(text)?;
|
||||||
let items = json["items"]
|
let items = json["items"]
|
||||||
@ -401,7 +403,8 @@ impl User {
|
|||||||
.join(", "),
|
.join(", "),
|
||||||
)?,
|
)?,
|
||||||
)
|
)
|
||||||
.send().await?;
|
.send()
|
||||||
|
.await?;
|
||||||
let text = &res.text().await?;
|
let text = &res.text().await?;
|
||||||
let json: serde_json::Value = serde_json::from_str(text)?;
|
let json: serde_json::Value = serde_json::from_str(text)?;
|
||||||
if let Some(first) = json.get("first") {
|
if let Some(first) = json.get("first") {
|
||||||
@ -446,7 +449,8 @@ impl User {
|
|||||||
.join(", "),
|
.join(", "),
|
||||||
)?,
|
)?,
|
||||||
)
|
)
|
||||||
.send().await?;
|
.send()
|
||||||
|
.await?;
|
||||||
let text = &res.text().await?;
|
let text = &res.text().await?;
|
||||||
let json: serde_json::Value = serde_json::from_str(text)?;
|
let json: serde_json::Value = serde_json::from_str(text)?;
|
||||||
Ok(json["items"]
|
Ok(json["items"]
|
||||||
|
@ -32,15 +32,15 @@ impl<'r> Responder<'r> for ApiError {
|
|||||||
Error::NotFound => Json(json!({
|
Error::NotFound => Json(json!({
|
||||||
"error": "Not found"
|
"error": "Not found"
|
||||||
}))
|
}))
|
||||||
.respond_to(req),
|
.respond_to(req),
|
||||||
Error::Unauthorized => Json(json!({
|
Error::Unauthorized => Json(json!({
|
||||||
"error": "You are not authorized to access this resource"
|
"error": "You are not authorized to access this resource"
|
||||||
}))
|
}))
|
||||||
.respond_to(req),
|
.respond_to(req),
|
||||||
_ => Json(json!({
|
_ => Json(json!({
|
||||||
"error": "Server error"
|
"error": "Server error"
|
||||||
}))
|
}))
|
||||||
.respond_to(req),
|
.respond_to(req),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,8 @@ use rocket_contrib::json::Json;
|
|||||||
use rocket_i18n::I18n;
|
use rocket_i18n::I18n;
|
||||||
use scheduled_thread_pool::ScheduledThreadPool;
|
use scheduled_thread_pool::ScheduledThreadPool;
|
||||||
use serde_json;
|
use serde_json;
|
||||||
use std::str::FromStr;
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::str::FromStr;
|
||||||
use validator::{Validate, ValidationErrors};
|
use validator::{Validate, ValidationErrors};
|
||||||
|
|
||||||
use crate::inbox;
|
use crate::inbox;
|
||||||
|
@ -11,7 +11,7 @@ use std::{
|
|||||||
use validator::{Validate, ValidationError, ValidationErrors};
|
use validator::{Validate, ValidationError, ValidationErrors};
|
||||||
|
|
||||||
use crate::routes::{
|
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 crate::template_utils::{IntoContext, Ructe};
|
||||||
use plume_common::activity_pub::{broadcast, ActivityStream, ApRequest};
|
use plume_common::activity_pub::{broadcast, ActivityStream, ApRequest};
|
||||||
|
Loading…
Reference in New Issue
Block a user