From 7b7d85dc5341e451084acf030b438a1882fa17c3 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 3 Jun 2019 10:47:12 -0700 Subject: [PATCH] Using Rust 2018 now. - Fixes #170 --- server/Cargo.toml | 1 + server/src/api/mod.rs | 26 +++++++------- server/src/apub.rs | 6 ++-- server/src/db/category.rs | 4 +-- server/src/db/comment.rs | 22 ++++++------ server/src/db/community.rs | 32 ++++++++--------- server/src/db/mod.rs | 2 +- server/src/db/moderator.rs | 66 +++++++++++++++++----------------- server/src/db/post.rs | 24 ++++++------- server/src/db/user.rs | 8 ++--- server/src/lib.rs | 2 +- server/src/websocket/server.rs | 18 +++++----- 12 files changed, 106 insertions(+), 105 deletions(-) diff --git a/server/Cargo.toml b/server/Cargo.toml index 5ee8b8a63..58984502c 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -2,6 +2,7 @@ name = "lemmy_server" version = "0.0.1" authors = ["Dessalines "] +edition = "2018" [dependencies] diesel = { version = "1.4.2", features = ["postgres","chrono"] } diff --git a/server/src/api/mod.rs b/server/src/api/mod.rs index 6e3e8269d..e10770b4d 100644 --- a/server/src/api/mod.rs +++ b/server/src/api/mod.rs @@ -1,18 +1,18 @@ use serde::{Deserialize, Serialize}; use failure::Error; -use db::*; -use db::community::*; -use db::user::*; -use db::post::*; -use db::comment::*; -use db::post_view::*; -use db::comment_view::*; -use db::category::*; -use db::community_view::*; -use db::user_view::*; -use db::moderator_views::*; -use db::moderator::*; -use {has_slurs, remove_slurs, Settings, naive_now, naive_from_unix}; +use crate::db::*; +use crate::db::community::*; +use crate::db::user::*; +use crate::db::post::*; +use crate::db::comment::*; +use crate::db::post_view::*; +use crate::db::comment_view::*; +use crate::db::category::*; +use crate::db::community_view::*; +use crate::db::user_view::*; +use crate::db::moderator_views::*; +use crate::db::moderator::*; +use crate::{has_slurs, remove_slurs, Settings, naive_now, naive_from_unix}; pub mod user; pub mod community; diff --git a/server/src/apub.rs b/server/src/apub.rs index 3d9595c81..23735e63f 100644 --- a/server/src/apub.rs +++ b/server/src/apub.rs @@ -1,10 +1,10 @@ extern crate activitypub; use self::activitypub::{context, actor::Person}; -use db::user::User_; +use crate::db::user::User_; impl User_ { pub fn person(&self) -> Person { - use {Settings, to_datetime_utc}; + use crate::{Settings, to_datetime_utc}; let base_url = &format!("{}/user/{}", Settings::get().api_endpoint(), self.name); let mut person = Person::default(); person.object_props.set_context_object(context()).ok(); @@ -31,7 +31,7 @@ impl User_ { #[cfg(test)] mod tests { use super::User_; - use naive_now; + use crate::naive_now; #[test] fn test_person() { diff --git a/server/src/db/category.rs b/server/src/db/category.rs index 99f906d41..eb8225801 100644 --- a/server/src/db/category.rs +++ b/server/src/db/category.rs @@ -1,5 +1,5 @@ -use schema::{category}; -use schema::category::dsl::*; +use crate::schema::{category}; +use crate::schema::category::dsl::*; use super::*; #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)] diff --git a/server/src/db/comment.rs b/server/src/db/comment.rs index a924bd4c8..d125124ce 100644 --- a/server/src/db/comment.rs +++ b/server/src/db/comment.rs @@ -1,4 +1,4 @@ -use schema::{comment, comment_like, comment_saved}; +use crate::schema::{comment, comment_like, comment_saved}; use super::*; use super::post::Post; @@ -40,26 +40,26 @@ pub struct CommentForm { impl Crud for Comment { fn read(conn: &PgConnection, comment_id: i32) -> Result { - use schema::comment::dsl::*; + use crate::schema::comment::dsl::*; comment.find(comment_id) .first::(conn) } fn delete(conn: &PgConnection, comment_id: i32) -> Result { - use schema::comment::dsl::*; + use crate::schema::comment::dsl::*; diesel::delete(comment.find(comment_id)) .execute(conn) } fn create(conn: &PgConnection, comment_form: &CommentForm) -> Result { - use schema::comment::dsl::*; + use crate::schema::comment::dsl::*; insert_into(comment) .values(comment_form) .get_result::(conn) } fn update(conn: &PgConnection, comment_id: i32, comment_form: &CommentForm) -> Result { - use schema::comment::dsl::*; + use crate::schema::comment::dsl::*; diesel::update(comment.find(comment_id)) .set(comment_form) .get_result::(conn) @@ -89,20 +89,20 @@ pub struct CommentLikeForm { impl Likeable for CommentLike { fn read(conn: &PgConnection, comment_id_from: i32) -> Result, Error> { - use schema::comment_like::dsl::*; + use crate::schema::comment_like::dsl::*; comment_like .filter(comment_id.eq(comment_id_from)) .load::(conn) } fn like(conn: &PgConnection, comment_like_form: &CommentLikeForm) -> Result { - use schema::comment_like::dsl::*; + use crate::schema::comment_like::dsl::*; insert_into(comment_like) .values(comment_like_form) .get_result::(conn) } fn remove(conn: &PgConnection, comment_like_form: &CommentLikeForm) -> Result { - use schema::comment_like::dsl::*; + use crate::schema::comment_like::dsl::*; diesel::delete(comment_like .filter(comment_id.eq(comment_like_form.comment_id)) .filter(user_id.eq(comment_like_form.user_id))) @@ -112,7 +112,7 @@ impl Likeable for CommentLike { impl CommentLike { pub fn from_post(conn: &PgConnection, post_id_from: i32) -> Result, Error> { - use schema::comment_like::dsl::*; + use crate::schema::comment_like::dsl::*; comment_like .filter(post_id.eq(post_id_from)) .load::(conn) @@ -138,13 +138,13 @@ pub struct CommentSavedForm { impl Saveable for CommentSaved { fn save(conn: &PgConnection, comment_saved_form: &CommentSavedForm) -> Result { - use schema::comment_saved::dsl::*; + use crate::schema::comment_saved::dsl::*; insert_into(comment_saved) .values(comment_saved_form) .get_result::(conn) } fn unsave(conn: &PgConnection, comment_saved_form: &CommentSavedForm) -> Result { - use schema::comment_saved::dsl::*; + use crate::schema::comment_saved::dsl::*; diesel::delete(comment_saved .filter(comment_id.eq(comment_saved_form.comment_id)) .filter(user_id.eq(comment_saved_form.user_id))) diff --git a/server/src/db/community.rs b/server/src/db/community.rs index 4540f731a..b32230b9c 100644 --- a/server/src/db/community.rs +++ b/server/src/db/community.rs @@ -1,4 +1,4 @@ -use schema::{community, community_moderator, community_follower, community_user_ban, site}; +use crate::schema::{community, community_moderator, community_follower, community_user_ban, site}; use super::*; #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)] @@ -31,26 +31,26 @@ pub struct CommunityForm { impl Crud for Community { fn read(conn: &PgConnection, community_id: i32) -> Result { - use schema::community::dsl::*; + use crate::schema::community::dsl::*; community.find(community_id) .first::(conn) } fn delete(conn: &PgConnection, community_id: i32) -> Result { - use schema::community::dsl::*; + use crate::schema::community::dsl::*; diesel::delete(community.find(community_id)) .execute(conn) } fn create(conn: &PgConnection, new_community: &CommunityForm) -> Result { - use schema::community::dsl::*; + use crate::schema::community::dsl::*; insert_into(community) .values(new_community) .get_result::(conn) } fn update(conn: &PgConnection, community_id: i32, new_community: &CommunityForm) -> Result { - use schema::community::dsl::*; + use crate::schema::community::dsl::*; diesel::update(community.find(community_id)) .set(new_community) .get_result::(conn) @@ -59,7 +59,7 @@ impl Crud for Community { impl Community { pub fn read_from_name(conn: &PgConnection, community_name: String) -> Result { - use schema::community::dsl::*; + use crate::schema::community::dsl::*; community.filter(name.eq(community_name)) .first::(conn) } @@ -84,14 +84,14 @@ pub struct CommunityModeratorForm { impl Joinable for CommunityModerator { fn join(conn: &PgConnection, community_user_form: &CommunityModeratorForm) -> Result { - use schema::community_moderator::dsl::*; + use crate::schema::community_moderator::dsl::*; insert_into(community_moderator) .values(community_user_form) .get_result::(conn) } fn leave(conn: &PgConnection, community_user_form: &CommunityModeratorForm) -> Result { - use schema::community_moderator::dsl::*; + use crate::schema::community_moderator::dsl::*; diesel::delete(community_moderator .filter(community_id.eq(community_user_form.community_id)) .filter(user_id.eq(community_user_form.user_id))) @@ -118,14 +118,14 @@ pub struct CommunityUserBanForm { impl Bannable for CommunityUserBan { fn ban(conn: &PgConnection, community_user_ban_form: &CommunityUserBanForm) -> Result { - use schema::community_user_ban::dsl::*; + use crate::schema::community_user_ban::dsl::*; insert_into(community_user_ban) .values(community_user_ban_form) .get_result::(conn) } fn unban(conn: &PgConnection, community_user_ban_form: &CommunityUserBanForm) -> Result { - use schema::community_user_ban::dsl::*; + use crate::schema::community_user_ban::dsl::*; diesel::delete(community_user_ban .filter(community_id.eq(community_user_ban_form.community_id)) .filter(user_id.eq(community_user_ban_form.user_id))) @@ -152,13 +152,13 @@ pub struct CommunityFollowerForm { impl Followable for CommunityFollower { fn follow(conn: &PgConnection, community_follower_form: &CommunityFollowerForm) -> Result { - use schema::community_follower::dsl::*; + use crate::schema::community_follower::dsl::*; insert_into(community_follower) .values(community_follower_form) .get_result::(conn) } fn ignore(conn: &PgConnection, community_follower_form: &CommunityFollowerForm) -> Result { - use schema::community_follower::dsl::*; + use crate::schema::community_follower::dsl::*; diesel::delete(community_follower .filter(community_id.eq(&community_follower_form.community_id)) .filter(user_id.eq(&community_follower_form.user_id))) @@ -188,25 +188,25 @@ pub struct SiteForm { impl Crud for Site { fn read(conn: &PgConnection, _site_id: i32) -> Result { - use schema::site::dsl::*; + use crate::schema::site::dsl::*; site.first::(conn) } fn delete(conn: &PgConnection, site_id: i32) -> Result { - use schema::site::dsl::*; + use crate::schema::site::dsl::*; diesel::delete(site.find(site_id)) .execute(conn) } fn create(conn: &PgConnection, new_site: &SiteForm) -> Result { - use schema::site::dsl::*; + use crate::schema::site::dsl::*; insert_into(site) .values(new_site) .get_result::(conn) } fn update(conn: &PgConnection, site_id: i32, new_site: &SiteForm) -> Result { - use schema::site::dsl::*; + use crate::schema::site::dsl::*; diesel::update(site.find(site_id)) .set(new_site) .get_result::(conn) diff --git a/server/src/db/mod.rs b/server/src/db/mod.rs index c3587c476..e0b7c8567 100644 --- a/server/src/db/mod.rs +++ b/server/src/db/mod.rs @@ -1,7 +1,7 @@ use diesel::*; use diesel::dsl::*; use diesel::result::Error; -use {Settings}; +use crate::{Settings}; use serde::{Deserialize, Serialize}; pub mod user; diff --git a/server/src/db/moderator.rs b/server/src/db/moderator.rs index 8b85e6631..56cf2f471 100644 --- a/server/src/db/moderator.rs +++ b/server/src/db/moderator.rs @@ -1,4 +1,4 @@ -use schema::{mod_remove_post, mod_lock_post, mod_remove_comment, mod_remove_community, mod_ban_from_community, mod_ban, mod_add_community, mod_add}; +use crate::schema::{mod_remove_post, mod_lock_post, mod_remove_comment, mod_remove_community, mod_ban_from_community, mod_ban, mod_add_community, mod_add}; use super::*; #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)] @@ -23,26 +23,26 @@ pub struct ModRemovePostForm { impl Crud for ModRemovePost { fn read(conn: &PgConnection, from_id: i32) -> Result { - use schema::mod_remove_post::dsl::*; + use crate::schema::mod_remove_post::dsl::*; mod_remove_post.find(from_id) .first::(conn) } fn delete(conn: &PgConnection, from_id: i32) -> Result { - use schema::mod_remove_post::dsl::*; + use crate::schema::mod_remove_post::dsl::*; diesel::delete(mod_remove_post.find(from_id)) .execute(conn) } fn create(conn: &PgConnection, form: &ModRemovePostForm) -> Result { - use schema::mod_remove_post::dsl::*; + use crate::schema::mod_remove_post::dsl::*; insert_into(mod_remove_post) .values(form) .get_result::(conn) } fn update(conn: &PgConnection, from_id: i32, form: &ModRemovePostForm) -> Result { - use schema::mod_remove_post::dsl::*; + use crate::schema::mod_remove_post::dsl::*; diesel::update(mod_remove_post.find(from_id)) .set(form) .get_result::(conn) @@ -71,26 +71,26 @@ pub struct ModLockPostForm { impl Crud for ModLockPost { fn read(conn: &PgConnection, from_id: i32) -> Result { - use schema::mod_lock_post::dsl::*; + use crate::schema::mod_lock_post::dsl::*; mod_lock_post.find(from_id) .first::(conn) } fn delete(conn: &PgConnection, from_id: i32) -> Result { - use schema::mod_lock_post::dsl::*; + use crate::schema::mod_lock_post::dsl::*; diesel::delete(mod_lock_post.find(from_id)) .execute(conn) } fn create(conn: &PgConnection, form: &ModLockPostForm) -> Result { - use schema::mod_lock_post::dsl::*; + use crate::schema::mod_lock_post::dsl::*; insert_into(mod_lock_post) .values(form) .get_result::(conn) } fn update(conn: &PgConnection, from_id: i32, form: &ModLockPostForm) -> Result { - use schema::mod_lock_post::dsl::*; + use crate::schema::mod_lock_post::dsl::*; diesel::update(mod_lock_post.find(from_id)) .set(form) .get_result::(conn) @@ -119,26 +119,26 @@ pub struct ModRemoveCommentForm { impl Crud for ModRemoveComment { fn read(conn: &PgConnection, from_id: i32) -> Result { - use schema::mod_remove_comment::dsl::*; + use crate::schema::mod_remove_comment::dsl::*; mod_remove_comment.find(from_id) .first::(conn) } fn delete(conn: &PgConnection, from_id: i32) -> Result { - use schema::mod_remove_comment::dsl::*; + use crate::schema::mod_remove_comment::dsl::*; diesel::delete(mod_remove_comment.find(from_id)) .execute(conn) } fn create(conn: &PgConnection, form: &ModRemoveCommentForm) -> Result { - use schema::mod_remove_comment::dsl::*; + use crate::schema::mod_remove_comment::dsl::*; insert_into(mod_remove_comment) .values(form) .get_result::(conn) } fn update(conn: &PgConnection, from_id: i32, form: &ModRemoveCommentForm) -> Result { - use schema::mod_remove_comment::dsl::*; + use crate::schema::mod_remove_comment::dsl::*; diesel::update(mod_remove_comment.find(from_id)) .set(form) .get_result::(conn) @@ -169,26 +169,26 @@ pub struct ModRemoveCommunityForm { impl Crud for ModRemoveCommunity { fn read(conn: &PgConnection, from_id: i32) -> Result { - use schema::mod_remove_community::dsl::*; + use crate::schema::mod_remove_community::dsl::*; mod_remove_community.find(from_id) .first::(conn) } fn delete(conn: &PgConnection, from_id: i32) -> Result { - use schema::mod_remove_community::dsl::*; + use crate::schema::mod_remove_community::dsl::*; diesel::delete(mod_remove_community.find(from_id)) .execute(conn) } fn create(conn: &PgConnection, form: &ModRemoveCommunityForm) -> Result { - use schema::mod_remove_community::dsl::*; + use crate::schema::mod_remove_community::dsl::*; insert_into(mod_remove_community) .values(form) .get_result::(conn) } fn update(conn: &PgConnection, from_id: i32, form: &ModRemoveCommunityForm) -> Result { - use schema::mod_remove_community::dsl::*; + use crate::schema::mod_remove_community::dsl::*; diesel::update(mod_remove_community.find(from_id)) .set(form) .get_result::(conn) @@ -221,26 +221,26 @@ pub struct ModBanFromCommunityForm { impl Crud for ModBanFromCommunity { fn read(conn: &PgConnection, from_id: i32) -> Result { - use schema::mod_ban_from_community::dsl::*; + use crate::schema::mod_ban_from_community::dsl::*; mod_ban_from_community.find(from_id) .first::(conn) } fn delete(conn: &PgConnection, from_id: i32) -> Result { - use schema::mod_ban_from_community::dsl::*; + use crate::schema::mod_ban_from_community::dsl::*; diesel::delete(mod_ban_from_community.find(from_id)) .execute(conn) } fn create(conn: &PgConnection, form: &ModBanFromCommunityForm) -> Result { - use schema::mod_ban_from_community::dsl::*; + use crate::schema::mod_ban_from_community::dsl::*; insert_into(mod_ban_from_community) .values(form) .get_result::(conn) } fn update(conn: &PgConnection, from_id: i32, form: &ModBanFromCommunityForm) -> Result { - use schema::mod_ban_from_community::dsl::*; + use crate::schema::mod_ban_from_community::dsl::*; diesel::update(mod_ban_from_community.find(from_id)) .set(form) .get_result::(conn) @@ -272,26 +272,26 @@ pub struct ModBanForm { impl Crud for ModBan { fn read(conn: &PgConnection, from_id: i32) -> Result { - use schema::mod_ban::dsl::*; + use crate::schema::mod_ban::dsl::*; mod_ban.find(from_id) .first::(conn) } fn delete(conn: &PgConnection, from_id: i32) -> Result { - use schema::mod_ban::dsl::*; + use crate::schema::mod_ban::dsl::*; diesel::delete(mod_ban.find(from_id)) .execute(conn) } fn create(conn: &PgConnection, form: &ModBanForm) -> Result { - use schema::mod_ban::dsl::*; + use crate::schema::mod_ban::dsl::*; insert_into(mod_ban) .values(form) .get_result::(conn) } fn update(conn: &PgConnection, from_id: i32, form: &ModBanForm) -> Result { - use schema::mod_ban::dsl::*; + use crate::schema::mod_ban::dsl::*; diesel::update(mod_ban.find(from_id)) .set(form) .get_result::(conn) @@ -320,26 +320,26 @@ pub struct ModAddCommunityForm { impl Crud for ModAddCommunity { fn read(conn: &PgConnection, from_id: i32) -> Result { - use schema::mod_add_community::dsl::*; + use crate::schema::mod_add_community::dsl::*; mod_add_community.find(from_id) .first::(conn) } fn delete(conn: &PgConnection, from_id: i32) -> Result { - use schema::mod_add_community::dsl::*; + use crate::schema::mod_add_community::dsl::*; diesel::delete(mod_add_community.find(from_id)) .execute(conn) } fn create(conn: &PgConnection, form: &ModAddCommunityForm) -> Result { - use schema::mod_add_community::dsl::*; + use crate::schema::mod_add_community::dsl::*; insert_into(mod_add_community) .values(form) .get_result::(conn) } fn update(conn: &PgConnection, from_id: i32, form: &ModAddCommunityForm) -> Result { - use schema::mod_add_community::dsl::*; + use crate::schema::mod_add_community::dsl::*; diesel::update(mod_add_community.find(from_id)) .set(form) .get_result::(conn) @@ -366,26 +366,26 @@ pub struct ModAddForm { impl Crud for ModAdd { fn read(conn: &PgConnection, from_id: i32) -> Result { - use schema::mod_add::dsl::*; + use crate::schema::mod_add::dsl::*; mod_add.find(from_id) .first::(conn) } fn delete(conn: &PgConnection, from_id: i32) -> Result { - use schema::mod_add::dsl::*; + use crate::schema::mod_add::dsl::*; diesel::delete(mod_add.find(from_id)) .execute(conn) } fn create(conn: &PgConnection, form: &ModAddForm) -> Result { - use schema::mod_add::dsl::*; + use crate::schema::mod_add::dsl::*; insert_into(mod_add) .values(form) .get_result::(conn) } fn update(conn: &PgConnection, from_id: i32, form: &ModAddForm) -> Result { - use schema::mod_add::dsl::*; + use crate::schema::mod_add::dsl::*; diesel::update(mod_add.find(from_id)) .set(form) .get_result::(conn) diff --git a/server/src/db/post.rs b/server/src/db/post.rs index f03022717..d8fd27b0a 100644 --- a/server/src/db/post.rs +++ b/server/src/db/post.rs @@ -1,4 +1,4 @@ -use schema::{post, post_like, post_saved, post_read}; +use crate::schema::{post, post_like, post_saved, post_read}; use super::*; #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)] @@ -33,26 +33,26 @@ pub struct PostForm { impl Crud for Post { fn read(conn: &PgConnection, post_id: i32) -> Result { - use schema::post::dsl::*; + use crate::schema::post::dsl::*; post.find(post_id) .first::(conn) } fn delete(conn: &PgConnection, post_id: i32) -> Result { - use schema::post::dsl::*; + use crate::schema::post::dsl::*; diesel::delete(post.find(post_id)) .execute(conn) } fn create(conn: &PgConnection, new_post: &PostForm) -> Result { - use schema::post::dsl::*; + use crate::schema::post::dsl::*; insert_into(post) .values(new_post) .get_result::(conn) } fn update(conn: &PgConnection, post_id: i32, new_post: &PostForm) -> Result { - use schema::post::dsl::*; + use crate::schema::post::dsl::*; diesel::update(post.find(post_id)) .set(new_post) .get_result::(conn) @@ -80,19 +80,19 @@ pub struct PostLikeForm { impl Likeable for PostLike { fn read(conn: &PgConnection, post_id_from: i32) -> Result, Error> { - use schema::post_like::dsl::*; + use crate::schema::post_like::dsl::*; post_like .filter(post_id.eq(post_id_from)) .load::(conn) } fn like(conn: &PgConnection, post_like_form: &PostLikeForm) -> Result { - use schema::post_like::dsl::*; + use crate::schema::post_like::dsl::*; insert_into(post_like) .values(post_like_form) .get_result::(conn) } fn remove(conn: &PgConnection, post_like_form: &PostLikeForm) -> Result { - use schema::post_like::dsl::*; + use crate::schema::post_like::dsl::*; diesel::delete(post_like .filter(post_id.eq(post_like_form.post_id)) .filter(user_id.eq(post_like_form.user_id))) @@ -119,13 +119,13 @@ pub struct PostSavedForm { impl Saveable for PostSaved { fn save(conn: &PgConnection, post_saved_form: &PostSavedForm) -> Result { - use schema::post_saved::dsl::*; + use crate::schema::post_saved::dsl::*; insert_into(post_saved) .values(post_saved_form) .get_result::(conn) } fn unsave(conn: &PgConnection, post_saved_form: &PostSavedForm) -> Result { - use schema::post_saved::dsl::*; + use crate::schema::post_saved::dsl::*; diesel::delete(post_saved .filter(post_id.eq(post_saved_form.post_id)) .filter(user_id.eq(post_saved_form.user_id))) @@ -152,13 +152,13 @@ pub struct PostReadForm { impl Readable for PostRead { fn mark_as_read(conn: &PgConnection, post_read_form: &PostReadForm) -> Result { - use schema::post_read::dsl::*; + use crate::schema::post_read::dsl::*; insert_into(post_read) .values(post_read_form) .get_result::(conn) } fn mark_as_unread(conn: &PgConnection, post_read_form: &PostReadForm) -> Result { - use schema::post_read::dsl::*; + use crate::schema::post_read::dsl::*; diesel::delete(post_read .filter(post_id.eq(post_read_form.post_id)) .filter(user_id.eq(post_read_form.user_id))) diff --git a/server/src/db/user.rs b/server/src/db/user.rs index a4a7be43f..aed5e8909 100644 --- a/server/src/db/user.rs +++ b/server/src/db/user.rs @@ -1,7 +1,7 @@ -use schema::user_; -use schema::user_::dsl::*; +use crate::schema::user_; +use crate::schema::user_::dsl::*; use super::*; -use {Settings, is_email_regex}; +use crate::{Settings, is_email_regex}; use jsonwebtoken::{encode, decode, Header, Validation, TokenData}; use bcrypt::{DEFAULT_COST, hash}; @@ -36,7 +36,7 @@ pub struct UserForm { impl Crud for User_ { fn read(conn: &PgConnection, user_id: i32) -> Result { - use schema::user_::dsl::*; + use crate::schema::user_::dsl::*; user_.find(user_id) .first::(conn) } diff --git a/server/src/lib.rs b/server/src/lib.rs index 7dd090d67..143be36ea 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -72,7 +72,7 @@ pub fn has_slurs(test: &str) -> bool { #[cfg(test)] mod tests { - use {Settings, is_email_regex, remove_slurs, has_slurs}; + use crate::{Settings, is_email_regex, remove_slurs, has_slurs}; #[test] fn test_api() { assert_eq!(Settings::get().api_endpoint(), "rrr/api/v1"); diff --git a/server/src/websocket/server.rs b/server/src/websocket/server.rs index abdf9ea9b..7088f3d5a 100644 --- a/server/src/websocket/server.rs +++ b/server/src/websocket/server.rs @@ -11,12 +11,12 @@ use std::str::FromStr; use failure::Error; use std::time::{SystemTime}; -use api::*; -use api::user::*; -use api::community::*; -use api::post::*; -use api::comment::*; -use api::site::*; +use crate::api::*; +use crate::api::user::*; +use crate::api::community::*; +use crate::api::post::*; +use crate::api::comment::*; +use crate::api::site::*; const RATE_LIMIT_MESSAGES: i32 = 30; const RATE_LIMIT_PER_SECOND: i32 = 60; @@ -118,7 +118,7 @@ impl ChatServer { fn join_room(&mut self, room_id: i32, id: usize) { // remove session from all rooms - for (_n, mut sessions) in &mut self.rooms { + for (_n, sessions) in &mut self.rooms { sessions.remove(&id); } @@ -131,8 +131,8 @@ impl ChatServer { } fn send_community_message(&self, community_id: &i32, message: &str, skip_id: usize) -> Result<(), Error> { - use db::*; - use db::post_view::*; + use crate::db::*; + use crate::db::post_view::*; let conn = establish_connection(); let posts = PostView::list(&conn, PostListingType::Community,