Clippy
This commit is contained in:
+1
-1
@@ -10,7 +10,7 @@ pub fn create(conn: DbConn, data: Json<NewAppData>) -> Api<App> {
|
||||
let client_id = random_hex();
|
||||
let client_secret = random_hex();
|
||||
let app = App::insert(
|
||||
&*conn,
|
||||
&conn,
|
||||
NewApp {
|
||||
name: data.name.clone(),
|
||||
client_id,
|
||||
|
||||
+13
-13
@@ -160,7 +160,7 @@ pub fn delete(name: String, conn: DbConn, rockets: PlumeRocket) -> RespondOrRedi
|
||||
.and_then(|u| u.is_author_in(&conn, &blog).ok())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
blog.delete(&*conn).expect("blog::expect: deletion error");
|
||||
blog.delete(&conn).expect("blog::expect: deletion error");
|
||||
Flash::success(
|
||||
Redirect::to(uri!(super::instance::index)),
|
||||
i18n!(rockets.intl.catalog, "Your blog was deleted."),
|
||||
@@ -364,7 +364,7 @@ pub fn outbox_page(
|
||||
#[get("/~/<name>/atom.xml")]
|
||||
pub fn atom_feed(name: String, conn: DbConn) -> Option<Content<String>> {
|
||||
let blog = Blog::find_by_fqn(&conn, &name).ok()?;
|
||||
let entries = Post::get_recents_for_blog(&*conn, &blog, 15).ok()?;
|
||||
let entries = Post::get_recents_for_blog(&conn, &blog, 15).ok()?;
|
||||
let uri = Instance::get_local()
|
||||
.ok()?
|
||||
.compute_box("~", &name, "atom.xml");
|
||||
@@ -454,9 +454,9 @@ mod tests {
|
||||
long_description_html: "<p>Good morning</p>".to_string(),
|
||||
short_description: SafeString::new("Hello"),
|
||||
short_description_html: "<p>Hello</p>".to_string(),
|
||||
name: random_hex().to_string(),
|
||||
name: random_hex(),
|
||||
open_registrations: true,
|
||||
public_domain: random_hex().to_string(),
|
||||
public_domain: random_hex(),
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
@@ -465,18 +465,18 @@ mod tests {
|
||||
});
|
||||
let mut user = NewUser::default();
|
||||
user.instance_id = instance.id;
|
||||
user.username = random_hex().to_string();
|
||||
user.ap_url = random_hex().to_string();
|
||||
user.inbox_url = random_hex().to_string();
|
||||
user.outbox_url = random_hex().to_string();
|
||||
user.followers_endpoint = random_hex().to_string();
|
||||
user.username = random_hex();
|
||||
user.ap_url = random_hex();
|
||||
user.inbox_url = random_hex();
|
||||
user.outbox_url = random_hex();
|
||||
user.followers_endpoint = random_hex();
|
||||
let user = User::insert(conn, user).unwrap();
|
||||
let mut blog = NewBlog::default();
|
||||
blog.instance_id = instance.id;
|
||||
blog.actor_id = random_hex().to_string();
|
||||
blog.ap_url = random_hex().to_string();
|
||||
blog.inbox_url = random_hex().to_string();
|
||||
blog.outbox_url = random_hex().to_string();
|
||||
blog.actor_id = random_hex();
|
||||
blog.ap_url = random_hex();
|
||||
blog.inbox_url = random_hex();
|
||||
blog.outbox_url = random_hex();
|
||||
let blog = Blog::insert(conn, blog).unwrap();
|
||||
BlogAuthor::insert(
|
||||
conn,
|
||||
|
||||
@@ -125,7 +125,7 @@ pub fn create(
|
||||
user.has_reshared(&conn, &post)
|
||||
.expect("comments::create: reshared error"),
|
||||
user.is_following(
|
||||
&*conn,
|
||||
&conn,
|
||||
post.get_authors(&conn)
|
||||
.expect("comments::create: authors error")[0]
|
||||
.id
|
||||
|
||||
@@ -105,7 +105,7 @@ pub fn update_settings(
|
||||
Instance::get_local().expect("instance::update_settings: local instance error");
|
||||
instance
|
||||
.update(
|
||||
&*conn,
|
||||
&conn,
|
||||
form.name.clone(),
|
||||
form.open_registrations,
|
||||
form.short_description.clone(),
|
||||
@@ -366,8 +366,8 @@ pub fn edit_users(
|
||||
}
|
||||
|
||||
fn ban(id: i32, conn: &Connection, worker: &ScheduledThreadPool) -> Result<(), ErrorPage> {
|
||||
let u = User::get(&*conn, id)?;
|
||||
u.delete(&*conn)?;
|
||||
let u = User::get(conn, id)?;
|
||||
u.delete(conn)?;
|
||||
if Instance::get_local()
|
||||
.map(|i| u.instance_id == i.id)
|
||||
.unwrap_or(false)
|
||||
@@ -382,8 +382,8 @@ fn ban(id: i32, conn: &Connection, worker: &ScheduledThreadPool) -> Result<(), E
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
let target = User::one_by_instance(&*conn)?;
|
||||
let delete_act = u.delete_activity(&*conn)?;
|
||||
let target = User::one_by_instance(conn)?;
|
||||
let delete_act = u.delete_activity(conn)?;
|
||||
worker.execute(move || broadcast(&u, delete_act, target, CONFIG.proxy().cloned()));
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -20,14 +20,14 @@ pub fn create(
|
||||
let b = Blog::find_by_fqn(&conn, &blog)?;
|
||||
let post = Post::find_by_slug(&conn, &slug, b.id)?;
|
||||
|
||||
if !user.has_liked(&*conn, &post)? {
|
||||
let like = likes::Like::insert(&*conn, likes::NewLike::new(&post, &user))?;
|
||||
like.notify(&*conn)?;
|
||||
if !user.has_liked(&conn, &post)? {
|
||||
let like = likes::Like::insert(&conn, likes::NewLike::new(&post, &user))?;
|
||||
like.notify(&conn)?;
|
||||
|
||||
Timeline::add_to_all_timelines(&conn, &post, Kind::Like(&user))?;
|
||||
|
||||
let dest = User::one_by_instance(&*conn)?;
|
||||
let act = like.to_activity(&*conn)?;
|
||||
let dest = User::one_by_instance(&conn)?;
|
||||
let act = like.to_activity(&conn)?;
|
||||
rockets
|
||||
.worker
|
||||
.execute(move || broadcast(&user, act, dest, CONFIG.proxy().cloned()));
|
||||
|
||||
@@ -145,9 +145,9 @@ pub fn details(
|
||||
|
||||
#[post("/medias/<id>/delete")]
|
||||
pub fn delete(id: i32, user: User, conn: DbConn, intl: I18n) -> Result<Flash<Redirect>, ErrorPage> {
|
||||
let media = Media::get(&*conn, id)?;
|
||||
let media = Media::get(&conn, id)?;
|
||||
if media.owner_id == user.id {
|
||||
media.delete(&*conn)?;
|
||||
media.delete(&conn)?;
|
||||
Ok(Flash::success(
|
||||
Redirect::to(uri!(list: page = _)),
|
||||
i18n!(intl.catalog, "Your media have been deleted."),
|
||||
@@ -167,9 +167,9 @@ pub fn set_avatar(
|
||||
conn: DbConn,
|
||||
intl: I18n,
|
||||
) -> Result<Flash<Redirect>, ErrorPage> {
|
||||
let media = Media::get(&*conn, id)?;
|
||||
let media = Media::get(&conn, id)?;
|
||||
if media.owner_id == user.id {
|
||||
user.set_avatar(&*conn, media.id)?;
|
||||
user.set_avatar(&conn, media.id)?;
|
||||
Ok(Flash::success(
|
||||
Redirect::to(uri!(details: id = id)),
|
||||
i18n!(intl.catalog, "Your avatar has been updated."),
|
||||
|
||||
+1
-1
@@ -165,7 +165,7 @@ fn post_to_atom(post: Post, conn: &Connection) -> Entry {
|
||||
.build(),
|
||||
)
|
||||
.authors(
|
||||
post.get_authors(&*conn)
|
||||
post.get_authors(conn)
|
||||
.expect("Atom feed: author error")
|
||||
.into_iter()
|
||||
.map(|a| {
|
||||
|
||||
+6
-6
@@ -48,10 +48,10 @@ pub fn me(user: Option<User>) -> RespondOrRedirect {
|
||||
#[get("/@/<name>", rank = 2)]
|
||||
pub fn details(name: String, rockets: PlumeRocket, conn: DbConn) -> Result<Ructe, ErrorPage> {
|
||||
let user = User::find_by_fqn(&conn, &name)?;
|
||||
let recents = Post::get_recents_for_author(&*conn, &user, 6)?;
|
||||
let reshares = Reshare::get_recents_for_author(&*conn, &user, 6)?;
|
||||
let recents = Post::get_recents_for_author(&conn, &user, 6)?;
|
||||
let reshares = Reshare::get_recents_for_author(&conn, &user, 6)?;
|
||||
|
||||
if !user.get_instance(&*conn)?.local {
|
||||
if !user.get_instance(&conn)?.local {
|
||||
tracing::trace!("remote user found");
|
||||
user.remote_user_found(); // Doesn't block
|
||||
}
|
||||
@@ -62,14 +62,14 @@ pub fn details(name: String, rockets: PlumeRocket, conn: DbConn) -> Result<Ructe
|
||||
rockets
|
||||
.user
|
||||
.clone()
|
||||
.and_then(|x| x.is_following(&*conn, user.id).ok())
|
||||
.and_then(|x| x.is_following(&conn, user.id).ok())
|
||||
.unwrap_or(false),
|
||||
user.instance_id != Instance::get_local()?.id,
|
||||
user.get_instance(&*conn)?.public_domain,
|
||||
user.get_instance(&conn)?.public_domain,
|
||||
recents,
|
||||
reshares
|
||||
.into_iter()
|
||||
.filter_map(|r| r.get_post(&*conn).ok())
|
||||
.filter_map(|r| r.get_post(&conn).ok())
|
||||
.collect()
|
||||
)))
|
||||
}
|
||||
|
||||
@@ -50,10 +50,10 @@ impl Resolver<DbConn> for WebfingerResolver {
|
||||
fn find(prefix: Prefix, acct: String, conn: DbConn) -> Result<Webfinger, ResolverError> {
|
||||
match prefix {
|
||||
Prefix::Acct => User::find_by_fqn(&conn, &acct)
|
||||
.and_then(|usr| usr.webfinger(&*conn))
|
||||
.and_then(|usr| usr.webfinger(&conn))
|
||||
.or(Err(ResolverError::NotFound)),
|
||||
Prefix::Group => Blog::find_by_fqn(&conn, &acct)
|
||||
.and_then(|blog| blog.webfinger(&*conn))
|
||||
.and_then(|blog| blog.webfinger(&conn))
|
||||
.or(Err(ResolverError::NotFound)),
|
||||
Prefix::Custom(_) => Err(ResolverError::NotFound),
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ impl<'r> Responder<'r> for Ructe {
|
||||
macro_rules! render {
|
||||
($group:tt :: $page:tt ( $( $param:expr ),* ) ) => {
|
||||
{
|
||||
use crate::templates;
|
||||
use $crate::templates;
|
||||
|
||||
let mut res = vec![];
|
||||
templates::$group::$page(
|
||||
|
||||
Reference in New Issue
Block a user