Run cargo fmt

This commit is contained in:
Kitaiti Makoto 2021-01-16 01:13:45 +09:00
parent 3fd89e6b48
commit 26ffde726f
9 changed files with 55 additions and 32 deletions

View File

@ -314,8 +314,7 @@ fn get_proxy_config() -> Option<ProxyConfig> {
} }
}) })
} else { } else {
reqwest::Proxy::all(proxy_url) reqwest::Proxy::all(proxy_url).expect("Invalid PROXY_URL")
.expect("Invalid PROXY_URL")
}; };
Some(ProxyConfig { Some(ProxyConfig {
url, url,

View File

@ -287,15 +287,15 @@ impl Post {
pub fn get_receivers_urls(&self, conn: &Connection) -> Result<Vec<String>> { pub fn get_receivers_urls(&self, conn: &Connection) -> Result<Vec<String>> {
Ok(self Ok(self
.get_authors(conn)? .get_authors(conn)?
.into_iter() .into_iter()
.filter_map(|a| a.get_followers(conn).ok()) .filter_map(|a| a.get_followers(conn).ok())
.fold(vec![], |mut acc, f| { .fold(vec![], |mut acc, f| {
for x in f { for x in f {
acc.push(x.ap_url); acc.push(x.ap_url);
} }
acc acc
})) }))
} }
pub fn to_activity(&self, conn: &Connection) -> Result<LicensedArticle> { pub fn to_activity(&self, conn: &Connection) -> Result<LicensedArticle> {

View File

@ -91,9 +91,11 @@ pub fn create(
}); });
Flash::success( Flash::success(
Redirect::to( Redirect::to(uri!(
uri!(super::posts::details: blog = blog_name, slug = slug, responding_to = _), super::posts::details: blog = blog_name,
), slug = slug,
responding_to = _
)),
i18n!(&rockets.intl.catalog, "Your comment has been posted."), i18n!(&rockets.intl.catalog, "Your comment has been posted."),
) )
}) })
@ -168,7 +170,11 @@ pub fn delete(
} }
} }
Ok(Flash::success( Ok(Flash::success(
Redirect::to(uri!(super::posts::details: blog = blog, slug = slug, responding_to = _)), Redirect::to(uri!(
super::posts::details: blog = blog,
slug = slug,
responding_to = _
)),
i18n!(&rockets.intl.catalog, "Your comment has been deleted."), i18n!(&rockets.intl.catalog, "Your comment has been deleted."),
)) ))
} }

View File

@ -408,9 +408,14 @@ pub fn interact(rockets: PlumeRocket, user: Option<User>, target: String) -> Opt
} }
if let Ok(post) = Post::from_id(&rockets, &target, None, CONFIG.proxy()) { if let Ok(post) = Post::from_id(&rockets, &target, None, CONFIG.proxy()) {
return Some(Redirect::to( return Some(Redirect::to(uri!(
uri!(super::posts::details: blog = post.get_blog(&rockets.conn).expect("Can't retrieve blog").fqn, slug = &post.slug, responding_to = _), super::posts::details: blog = post
)); .get_blog(&rockets.conn)
.expect("Can't retrieve blog")
.fqn,
slug = &post.slug,
responding_to = _
)));
} }
if let Ok(comment) = Comment::from_id(&rockets, &target, None, CONFIG.proxy()) { if let Ok(comment) = Comment::from_id(&rockets, &target, None, CONFIG.proxy()) {

View File

@ -45,9 +45,11 @@ pub fn create(
.execute(move || broadcast(&user, delete_act, dest, CONFIG.proxy().cloned())); .execute(move || broadcast(&user, delete_act, dest, CONFIG.proxy().cloned()));
} }
Ok(Redirect::to( Ok(Redirect::to(uri!(
uri!(super::posts::details: blog = blog, slug = slug, responding_to = _), super::posts::details: blog = blog,
)) slug = slug,
responding_to = _
)))
} }
#[post("/~/<blog>/<slug>/like", rank = 2)] #[post("/~/<blog>/<slug>/like", rank = 2)]

View File

@ -356,7 +356,11 @@ pub fn update(
} }
Flash::success( Flash::success(
Redirect::to(uri!(details: blog = blog, slug = new_slug, responding_to = _)), Redirect::to(uri!(
details: blog = blog,
slug = new_slug,
responding_to = _
)),
i18n!(intl, "Your article has been updated."), i18n!(intl, "Your article has been updated."),
) )
.into() .into()
@ -543,7 +547,11 @@ pub fn create(
} }
Ok(Flash::success( Ok(Flash::success(
Redirect::to(uri!(details: blog = blog_name, slug = slug, responding_to = _)), Redirect::to(uri!(
details: blog = blog_name,
slug = slug,
responding_to = _
)),
i18n!(&rockets.intl.catalog, "Your article has been saved."), i18n!(&rockets.intl.catalog, "Your article has been saved."),
) )
.into()) .into())
@ -583,7 +591,11 @@ pub fn delete(
.any(|a| a.id == user.id) .any(|a| a.id == user.id)
{ {
return Ok(Flash::error( return Ok(Flash::error(
Redirect::to(uri!(details: blog = blog_name, slug = slug, responding_to = _)), Redirect::to(uri!(
details: blog = blog_name,
slug = slug,
responding_to = _
)),
i18n!(intl.catalog, "You are not allowed to delete this article."), i18n!(intl.catalog, "You are not allowed to delete this article."),
)); ));
} }

View File

@ -45,9 +45,11 @@ pub fn create(
.execute(move || broadcast(&user, delete_act, dest, CONFIG.proxy().cloned())); .execute(move || broadcast(&user, delete_act, dest, CONFIG.proxy().cloned()));
} }
Ok(Redirect::to( Ok(Redirect::to(uri!(
uri!(super::posts::details: blog = blog, slug = slug, responding_to = _), super::posts::details: blog = blog,
)) slug = slug,
responding_to = _
)))
} }
#[post("/~/<blog>/<slug>/reshare", rank = 1)] #[post("/~/<blog>/<slug>/reshare", rank = 1)]

View File

@ -55,8 +55,7 @@ pub fn search(query: Option<Form<SearchQuery>>, rockets: PlumeRocket) -> Ructe {
let query = query.map(Form::into_inner).unwrap_or_default(); let query = query.map(Form::into_inner).unwrap_or_default();
let page = query.page.unwrap_or_default(); let page = query.page.unwrap_or_default();
let mut parsed_query = let mut parsed_query =
Query::from_str(&query.q.as_deref().unwrap_or_default()) Query::from_str(&query.q.as_deref().unwrap_or_default()).unwrap_or_default();
.unwrap_or_default();
param_to_query!(query, parsed_query; normal: title, subtitle, content, tag, param_to_query!(query, parsed_query; normal: title, subtitle, content, tag,
instance, author, blog, lang, license; instance, author, blog, lang, license;

View File

@ -210,9 +210,7 @@ pub fn password_reset(
.map_err(|err| password_reset_error_response(err, &rockets))?; .map_err(|err| password_reset_error_response(err, &rockets))?;
Ok(Flash::success( Ok(Flash::success(
Redirect::to(uri!( Redirect::to(uri!(new: m = _)),
new: m = _
)),
i18n!( i18n!(
rockets.intl.catalog, rockets.intl.catalog,
"Your password was successfully reset." "Your password was successfully reset."