]> Untitled Git - lemmy.git/commitdiff
Using Rust 2018 now.
authorDessalines <tyhou13@gmx.com>
Mon, 3 Jun 2019 17:47:12 +0000 (10:47 -0700)
committerDessalines <tyhou13@gmx.com>
Mon, 3 Jun 2019 17:47:12 +0000 (10:47 -0700)
- Fixes #170

12 files changed:
server/Cargo.toml
server/src/api/mod.rs
server/src/apub.rs
server/src/db/category.rs
server/src/db/comment.rs
server/src/db/community.rs
server/src/db/mod.rs
server/src/db/moderator.rs
server/src/db/post.rs
server/src/db/user.rs
server/src/lib.rs
server/src/websocket/server.rs

index 5ee8b8a636a7f428d9351788c871ab15ef211b63..58984502c2170063b7295f61055f98172a742510 100644 (file)
@@ -2,6 +2,7 @@
 name = "lemmy_server"
 version = "0.0.1"
 authors = ["Dessalines <happydooby@gmail.com>"]
+edition = "2018"
 
 [dependencies]
 diesel = { version = "1.4.2", features = ["postgres","chrono"] }
index 6e3e8269da4b7f393713bce48809149635891c63..e10770b4df8bf4015f4827925f3703c0659ab716 100644 (file)
@@ -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;
index 3d9595c810bbfc5f5409182f8c8c114da1d902da..23735e63f1e215a92cc0d9eba56b76b7e6fde555 100644 (file)
@@ -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() {
index 99f906d41988b86b786bfedae1a3c99fcccc4d56..eb82258016a3388babbee2de60c6c6cfce1e85fc 100644 (file)
@@ -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)]
index a924bd4c86f4ae09d42e7cb1772a4f93249f970a..d125124ce4c81ea7058a22abc168960236120117 100644 (file)
@@ -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<CommentForm> for Comment {
   fn read(conn: &PgConnection, comment_id: i32) -> Result<Self, Error> {
-    use schema::comment::dsl::*;
+    use crate::schema::comment::dsl::*;
     comment.find(comment_id)
       .first::<Self>(conn)
   }
 
   fn delete(conn: &PgConnection, comment_id: i32) -> Result<usize, Error> {
-    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<Self, Error> {
-    use schema::comment::dsl::*;
+    use crate::schema::comment::dsl::*;
     insert_into(comment)
       .values(comment_form)
       .get_result::<Self>(conn)
   }
 
   fn update(conn: &PgConnection, comment_id: i32, comment_form: &CommentForm) -> Result<Self, Error> {
-    use schema::comment::dsl::*;
+    use crate::schema::comment::dsl::*;
     diesel::update(comment.find(comment_id))
       .set(comment_form)
       .get_result::<Self>(conn)
@@ -89,20 +89,20 @@ pub struct CommentLikeForm {
 
 impl Likeable <CommentLikeForm> for CommentLike {
   fn read(conn: &PgConnection, comment_id_from: i32) -> Result<Vec<Self>, Error> {
-    use schema::comment_like::dsl::*;
+    use crate::schema::comment_like::dsl::*;
     comment_like
       .filter(comment_id.eq(comment_id_from))
       .load::<Self>(conn) 
   }
 
   fn like(conn: &PgConnection, comment_like_form: &CommentLikeForm) -> Result<Self, Error> {
-    use schema::comment_like::dsl::*;
+    use crate::schema::comment_like::dsl::*;
     insert_into(comment_like)
       .values(comment_like_form)
       .get_result::<Self>(conn)
   }
   fn remove(conn: &PgConnection, comment_like_form: &CommentLikeForm) -> Result<usize, Error> {
-    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 <CommentLikeForm> for CommentLike {
 
 impl CommentLike {
   pub fn from_post(conn: &PgConnection, post_id_from: i32) -> Result<Vec<Self>, Error> {
-    use schema::comment_like::dsl::*;
+    use crate::schema::comment_like::dsl::*;
     comment_like
       .filter(post_id.eq(post_id_from))
       .load::<Self>(conn) 
@@ -138,13 +138,13 @@ pub struct CommentSavedForm {
 
 impl Saveable <CommentSavedForm> for CommentSaved {
   fn save(conn: &PgConnection, comment_saved_form: &CommentSavedForm) -> Result<Self, Error> {
-    use schema::comment_saved::dsl::*;
+    use crate::schema::comment_saved::dsl::*;
     insert_into(comment_saved)
       .values(comment_saved_form)
       .get_result::<Self>(conn)
   }
   fn unsave(conn: &PgConnection, comment_saved_form: &CommentSavedForm) -> Result<usize, Error> {
-    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)))
index 4540f731afa82ca7aeadc9d835bc9ef0779802af..b32230b9c9410240f74476fed4dc91598cb0be1e 100644 (file)
@@ -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<CommunityForm> for Community {
   fn read(conn: &PgConnection, community_id: i32) -> Result<Self, Error> {
-    use schema::community::dsl::*;
+    use crate::schema::community::dsl::*;
     community.find(community_id)
       .first::<Self>(conn)
   }
 
   fn delete(conn: &PgConnection, community_id: i32) -> Result<usize, Error> {
-    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<Self, Error> {
-    use schema::community::dsl::*;
+    use crate::schema::community::dsl::*;
       insert_into(community)
         .values(new_community)
         .get_result::<Self>(conn)
   }
 
   fn update(conn: &PgConnection, community_id: i32, new_community: &CommunityForm) -> Result<Self, Error> {
-    use schema::community::dsl::*;
+    use crate::schema::community::dsl::*;
     diesel::update(community.find(community_id))
       .set(new_community)
       .get_result::<Self>(conn)
@@ -59,7 +59,7 @@ impl Crud<CommunityForm> for Community {
 
 impl Community {
   pub fn read_from_name(conn: &PgConnection, community_name: String) -> Result<Self, Error> {
-    use schema::community::dsl::*;
+    use crate::schema::community::dsl::*;
     community.filter(name.eq(community_name))
       .first::<Self>(conn)
   }
@@ -84,14 +84,14 @@ pub struct CommunityModeratorForm {
 
 impl Joinable<CommunityModeratorForm> for CommunityModerator {
   fn join(conn: &PgConnection, community_user_form: &CommunityModeratorForm) -> Result<Self, Error> {
-    use schema::community_moderator::dsl::*;
+    use crate::schema::community_moderator::dsl::*;
     insert_into(community_moderator)
       .values(community_user_form)
       .get_result::<Self>(conn)
   }
 
   fn leave(conn: &PgConnection, community_user_form: &CommunityModeratorForm) -> Result<usize, Error> {
-    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<CommunityUserBanForm> for CommunityUserBan {
   fn ban(conn: &PgConnection, community_user_ban_form: &CommunityUserBanForm) -> Result<Self, Error> {
-    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::<Self>(conn)
   }
 
   fn unban(conn: &PgConnection, community_user_ban_form: &CommunityUserBanForm) -> Result<usize, Error> {
-    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<CommunityFollowerForm> for CommunityFollower {
   fn follow(conn: &PgConnection, community_follower_form: &CommunityFollowerForm) -> Result<Self, Error> {
-    use schema::community_follower::dsl::*;
+    use crate::schema::community_follower::dsl::*;
     insert_into(community_follower)
       .values(community_follower_form)
       .get_result::<Self>(conn)
   }
   fn ignore(conn: &PgConnection, community_follower_form: &CommunityFollowerForm) -> Result<usize, Error> {
-    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<SiteForm> for Site {
   fn read(conn: &PgConnection, _site_id: i32) -> Result<Self, Error> {
-    use schema::site::dsl::*;
+    use crate::schema::site::dsl::*;
     site.first::<Self>(conn)
   }
 
   fn delete(conn: &PgConnection, site_id: i32) -> Result<usize, Error> {
-    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<Self, Error> {
-    use schema::site::dsl::*;
+    use crate::schema::site::dsl::*;
       insert_into(site)
         .values(new_site)
         .get_result::<Self>(conn)
   }
 
   fn update(conn: &PgConnection, site_id: i32, new_site: &SiteForm) -> Result<Self, Error> {
-    use schema::site::dsl::*;
+    use crate::schema::site::dsl::*;
     diesel::update(site.find(site_id))
       .set(new_site)
       .get_result::<Self>(conn)
index c3587c476ef5a7099c557c86ffeb81e53dd67cbc..e0b7c8567c24399a407817380eb6a4d26c6778b2 100644 (file)
@@ -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;
index 8b85e66318626c9415ca79cb65c50d7936330921..56cf2f4719b6ff24d67f78a1f598e65b9dfda6a5 100644 (file)
@@ -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<ModRemovePostForm> for ModRemovePost {
   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
-    use schema::mod_remove_post::dsl::*;
+    use crate::schema::mod_remove_post::dsl::*;
     mod_remove_post.find(from_id)
       .first::<Self>(conn)
   }
 
   fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
-    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<Self, Error> {
-    use schema::mod_remove_post::dsl::*;
+    use crate::schema::mod_remove_post::dsl::*;
       insert_into(mod_remove_post)
         .values(form)
         .get_result::<Self>(conn)
   }
 
   fn update(conn: &PgConnection, from_id: i32, form: &ModRemovePostForm) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -71,26 +71,26 @@ pub struct ModLockPostForm {
 
 impl Crud<ModLockPostForm> for ModLockPost {
   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
-    use schema::mod_lock_post::dsl::*;
+    use crate::schema::mod_lock_post::dsl::*;
     mod_lock_post.find(from_id)
       .first::<Self>(conn)
   }
 
   fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
-    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<Self, Error> {
-    use schema::mod_lock_post::dsl::*;
+    use crate::schema::mod_lock_post::dsl::*;
       insert_into(mod_lock_post)
         .values(form)
         .get_result::<Self>(conn)
   }
 
   fn update(conn: &PgConnection, from_id: i32, form: &ModLockPostForm) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -119,26 +119,26 @@ pub struct ModRemoveCommentForm {
 
 impl Crud<ModRemoveCommentForm> for ModRemoveComment {
   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
-    use schema::mod_remove_comment::dsl::*;
+    use crate::schema::mod_remove_comment::dsl::*;
     mod_remove_comment.find(from_id)
       .first::<Self>(conn)
   }
 
   fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
-    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<Self, Error> {
-    use schema::mod_remove_comment::dsl::*;
+    use crate::schema::mod_remove_comment::dsl::*;
       insert_into(mod_remove_comment)
         .values(form)
         .get_result::<Self>(conn)
   }
 
   fn update(conn: &PgConnection, from_id: i32, form: &ModRemoveCommentForm) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -169,26 +169,26 @@ pub struct ModRemoveCommunityForm {
 
 impl Crud<ModRemoveCommunityForm> for ModRemoveCommunity {
   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
-    use schema::mod_remove_community::dsl::*;
+    use crate::schema::mod_remove_community::dsl::*;
     mod_remove_community.find(from_id)
       .first::<Self>(conn)
   }
 
   fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
-    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<Self, Error> {
-    use schema::mod_remove_community::dsl::*;
+    use crate::schema::mod_remove_community::dsl::*;
       insert_into(mod_remove_community)
         .values(form)
         .get_result::<Self>(conn)
   }
 
   fn update(conn: &PgConnection, from_id: i32, form: &ModRemoveCommunityForm) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -221,26 +221,26 @@ pub struct ModBanFromCommunityForm {
 
 impl Crud<ModBanFromCommunityForm> for ModBanFromCommunity {
   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
-    use schema::mod_ban_from_community::dsl::*;
+    use crate::schema::mod_ban_from_community::dsl::*;
     mod_ban_from_community.find(from_id)
       .first::<Self>(conn)
   }
 
   fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
-    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<Self, Error> {
-    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::<Self>(conn)
   }
 
   fn update(conn: &PgConnection, from_id: i32, form: &ModBanFromCommunityForm) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -272,26 +272,26 @@ pub struct ModBanForm {
 
 impl Crud<ModBanForm> for ModBan {
   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
-    use schema::mod_ban::dsl::*;
+    use crate::schema::mod_ban::dsl::*;
     mod_ban.find(from_id)
       .first::<Self>(conn)
   }
 
   fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
-    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<Self, Error> {
-    use schema::mod_ban::dsl::*;
+    use crate::schema::mod_ban::dsl::*;
       insert_into(mod_ban)
         .values(form)
         .get_result::<Self>(conn)
   }
 
   fn update(conn: &PgConnection, from_id: i32, form: &ModBanForm) -> Result<Self, Error> {
-    use schema::mod_ban::dsl::*;
+    use crate::schema::mod_ban::dsl::*;
     diesel::update(mod_ban.find(from_id))
       .set(form)
       .get_result::<Self>(conn)
@@ -320,26 +320,26 @@ pub struct ModAddCommunityForm {
 
 impl Crud<ModAddCommunityForm> for ModAddCommunity {
   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
-    use schema::mod_add_community::dsl::*;
+    use crate::schema::mod_add_community::dsl::*;
     mod_add_community.find(from_id)
       .first::<Self>(conn)
   }
 
   fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
-    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<Self, Error> {
-    use schema::mod_add_community::dsl::*;
+    use crate::schema::mod_add_community::dsl::*;
       insert_into(mod_add_community)
         .values(form)
         .get_result::<Self>(conn)
   }
 
   fn update(conn: &PgConnection, from_id: i32, form: &ModAddCommunityForm) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -366,26 +366,26 @@ pub struct ModAddForm {
 
 impl Crud<ModAddForm> for ModAdd {
   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
-    use schema::mod_add::dsl::*;
+    use crate::schema::mod_add::dsl::*;
     mod_add.find(from_id)
       .first::<Self>(conn)
   }
 
   fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
-    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<Self, Error> {
-    use schema::mod_add::dsl::*;
+    use crate::schema::mod_add::dsl::*;
       insert_into(mod_add)
         .values(form)
         .get_result::<Self>(conn)
   }
 
   fn update(conn: &PgConnection, from_id: i32, form: &ModAddForm) -> Result<Self, Error> {
-    use schema::mod_add::dsl::*;
+    use crate::schema::mod_add::dsl::*;
     diesel::update(mod_add.find(from_id))
       .set(form)
       .get_result::<Self>(conn)
index f030227171217dbeeb657e67b1c475b1ae2cb5b5..d8fd27b0a92b43d4fbd456812e2699583d2502e3 100644 (file)
@@ -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<PostForm> for Post {
   fn read(conn: &PgConnection, post_id: i32) -> Result<Self, Error> {
-    use schema::post::dsl::*;
+    use crate::schema::post::dsl::*;
     post.find(post_id)
       .first::<Self>(conn)
   }
 
   fn delete(conn: &PgConnection, post_id: i32) -> Result<usize, Error> {
-    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<Self, Error> {
-    use schema::post::dsl::*;
+    use crate::schema::post::dsl::*;
       insert_into(post)
         .values(new_post)
         .get_result::<Self>(conn)
   }
 
   fn update(conn: &PgConnection, post_id: i32, new_post: &PostForm) -> Result<Self, Error> {
-    use schema::post::dsl::*;
+    use crate::schema::post::dsl::*;
     diesel::update(post.find(post_id))
       .set(new_post)
       .get_result::<Self>(conn)
@@ -80,19 +80,19 @@ pub struct PostLikeForm {
 
 impl Likeable <PostLikeForm> for PostLike {
   fn read(conn: &PgConnection, post_id_from: i32) -> Result<Vec<Self>, Error> {
-    use schema::post_like::dsl::*;
+    use crate::schema::post_like::dsl::*;
     post_like
       .filter(post_id.eq(post_id_from))
       .load::<Self>(conn) 
   }
   fn like(conn: &PgConnection, post_like_form: &PostLikeForm) -> Result<Self, Error> {
-    use schema::post_like::dsl::*;
+    use crate::schema::post_like::dsl::*;
     insert_into(post_like)
       .values(post_like_form)
       .get_result::<Self>(conn)
   }
   fn remove(conn: &PgConnection, post_like_form: &PostLikeForm) -> Result<usize, Error> {
-    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 <PostSavedForm> for PostSaved {
   fn save(conn: &PgConnection, post_saved_form: &PostSavedForm) -> Result<Self, Error> {
-    use schema::post_saved::dsl::*;
+    use crate::schema::post_saved::dsl::*;
     insert_into(post_saved)
       .values(post_saved_form)
       .get_result::<Self>(conn)
   }
   fn unsave(conn: &PgConnection, post_saved_form: &PostSavedForm) -> Result<usize, Error> {
-    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 <PostReadForm> for PostRead {
   fn mark_as_read(conn: &PgConnection, post_read_form: &PostReadForm) -> Result<Self, Error> {
-    use schema::post_read::dsl::*;
+    use crate::schema::post_read::dsl::*;
     insert_into(post_read)
       .values(post_read_form)
       .get_result::<Self>(conn)
   }
   fn mark_as_unread(conn: &PgConnection, post_read_form: &PostReadForm) -> Result<usize, Error> {
-    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)))
index a4a7be43f58c1036a855d6ddbc70d2d3515151fa..aed5e89092732cb3c9575fc6e32f4f2c5f7fa96e 100644 (file)
@@ -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<UserForm> for User_ {
   fn read(conn: &PgConnection, user_id: i32) -> Result<Self, Error> {
-    use schema::user_::dsl::*;
+    use crate::schema::user_::dsl::*;
     user_.find(user_id)
       .first::<Self>(conn)
   }
index 7dd090d6749df7c7af99d844b933f449c6277c31..143be36ea52b37267336dbb3733414a87ae1bf73 100644 (file)
@@ -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");
index abdf9ea9bb1b6bb9aa8cdc74e92d273a622b89c3..7088f3d5ac99d333456e1a8d78d57161cfa2ae00 100644 (file)
@@ -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,