]> Untitled Git - lemmy.git/commitdiff
Move comment, post definitions into lemmy_db_schema
authorFelix Ableitner <me@nutomic.com>
Fri, 18 Dec 2020 17:27:25 +0000 (18:27 +0100)
committerFelix Ableitner <me@nutomic.com>
Fri, 18 Dec 2020 17:27:25 +0000 (18:27 +0100)
58 files changed:
Cargo.lock
lemmy_api/Cargo.toml
lemmy_api/src/comment.rs
lemmy_api/src/community.rs
lemmy_api/src/lib.rs
lemmy_api/src/post.rs
lemmy_api/src/site.rs
lemmy_api/src/user.rs
lemmy_apub/Cargo.toml
lemmy_apub/src/activities/receive/comment.rs
lemmy_apub/src/activities/receive/comment_undo.rs
lemmy_apub/src/activities/receive/post.rs
lemmy_apub/src/activities/receive/post_undo.rs
lemmy_apub/src/activities/send/comment.rs
lemmy_apub/src/activities/send/post.rs
lemmy_apub/src/fetcher.rs
lemmy_apub/src/http/comment.rs
lemmy_apub/src/http/community.rs
lemmy_apub/src/http/post.rs
lemmy_apub/src/inbox/receive_for_community.rs
lemmy_apub/src/objects/comment.rs
lemmy_apub/src/objects/community.rs
lemmy_apub/src/objects/post.rs
lemmy_apub/src/objects/user.rs
lemmy_db/src/aggregates/community_aggregates.rs
lemmy_db/src/aggregates/post_aggregates.rs
lemmy_db/src/aggregates/site_aggregates.rs
lemmy_db/src/aggregates/user_aggregates.rs
lemmy_db/src/lib.rs
lemmy_db/src/source/comment.rs
lemmy_db/src/source/comment_report.rs
lemmy_db/src/source/community.rs
lemmy_db/src/source/moderator.rs
lemmy_db/src/source/post.rs
lemmy_db/src/source/post_report.rs
lemmy_db/src/source/private_message.rs
lemmy_db/src/source/site.rs
lemmy_db/src/source/user.rs
lemmy_db/src/source/user_mention.rs
lemmy_db/src/views/comment_report_view.rs
lemmy_db/src/views/comment_view.rs
lemmy_db/src/views/moderator/mod_lock_post_view.rs
lemmy_db/src/views/moderator/mod_remove_comment_view.rs
lemmy_db/src/views/moderator/mod_remove_post_view.rs
lemmy_db/src/views/moderator/mod_sticky_post_view.rs
lemmy_db/src/views/post_report_view.rs
lemmy_db/src/views/post_view.rs
lemmy_db/src/views/user_mention_view.rs
lemmy_db_schema/Cargo.toml
lemmy_db_schema/src/lib.rs
lemmy_db_schema/src/source/comment.rs [new file with mode: 0644]
lemmy_db_schema/src/source/mod.rs [new file with mode: 0644]
lemmy_db_schema/src/source/post.rs [new file with mode: 0644]
lemmy_structs/Cargo.toml
lemmy_structs/src/lib.rs
lemmy_websocket/Cargo.toml
lemmy_websocket/src/handlers.rs
src/code_migrations.rs

index 850a19e5eb31910efeca12501ba74fa72ba92c7c..6cc79feddc9a7d301c5290f5644c42018253d29f 100644 (file)
@@ -1718,6 +1718,7 @@ dependencies = [
  "lazy_static",
  "lemmy_apub",
  "lemmy_db",
+ "lemmy_db_schema",
  "lemmy_rate_limit",
  "lemmy_structs",
  "lemmy_utils",
@@ -1762,6 +1763,7 @@ dependencies = [
  "itertools",
  "lazy_static",
  "lemmy_db",
+ "lemmy_db_schema",
  "lemmy_structs",
  "lemmy_utils",
  "lemmy_websocket",
@@ -1805,7 +1807,12 @@ dependencies = [
 name = "lemmy_db_schema"
 version = "0.1.0"
 dependencies = [
+ "chrono",
  "diesel",
+ "log",
+ "serde 1.0.118",
+ "serde_json",
+ "url",
 ]
 
 [[package]]
@@ -1868,6 +1875,7 @@ dependencies = [
  "chrono",
  "diesel",
  "lemmy_db",
+ "lemmy_db_schema",
  "lemmy_utils",
  "log",
  "serde 1.0.118",
@@ -1909,6 +1917,7 @@ dependencies = [
  "chrono",
  "diesel",
  "lemmy_db",
+ "lemmy_db_schema",
  "lemmy_rate_limit",
  "lemmy_structs",
  "lemmy_utils",
index 94fd2d500892b73360ed9c34cbe86bc945c4adaa..f4a10924c6d4c7acc98bb9bd9fc70331b4cae79f 100644 (file)
@@ -12,6 +12,7 @@ path = "src/lib.rs"
 lemmy_apub = { path = "../lemmy_apub" }
 lemmy_utils = { path = "../lemmy_utils" }
 lemmy_db = { path = "../lemmy_db" }
+lemmy_db_schema = { path = "../lemmy_db_schema" }
 lemmy_structs = { path = "../lemmy_structs" }
 lemmy_rate_limit = { path = "../lemmy_rate_limit" }
 lemmy_websocket = { path = "../lemmy_websocket" }
index 689fe4b8abb0da3e47c801344046db7e23c80dad..acff6004246ee0500321bb7ee2ec2b3b696e13c8 100644 (file)
@@ -11,10 +11,8 @@ use actix_web::web::Data;
 use lemmy_apub::{ApubLikeableType, ApubObjectType};
 use lemmy_db::{
   source::{
-    comment::*,
     comment_report::{CommentReport, CommentReportForm},
     moderator::*,
-    post::*,
     user::*,
   },
   views::{
@@ -29,6 +27,10 @@ use lemmy_db::{
   Saveable,
   SortType,
 };
+use lemmy_db_schema::source::{
+  comment::{Comment, CommentForm, CommentLike, CommentLikeForm, CommentSaved, CommentSavedForm},
+  post::Post,
+};
 use lemmy_structs::{blocking, comment::*, send_local_notifs};
 use lemmy_utils::{
   apub::{make_apub_endpoint, EndpointType},
index 6e20a30ba3ef8bda2092119b3e42f1e7b6196cf6..35aafc88ea741ac94c0d1491cd24f41aa18e2ac0 100644 (file)
@@ -11,8 +11,7 @@ use anyhow::Context;
 use lemmy_apub::ActorType;
 use lemmy_db::{
   diesel_option_overwrite,
-  naive_now,
-  source::{comment::Comment, community::*, moderator::*, post::Post, site::*},
+  source::{community::*, moderator::*, site::*},
   views::{
     comment_view::CommentQueryBuilder,
     community::{
@@ -29,6 +28,10 @@ use lemmy_db::{
   Joinable,
   SortType,
 };
+use lemmy_db_schema::{
+  naive_now,
+  source::{comment::Comment, post::Post},
+};
 use lemmy_structs::{blocking, community::*};
 use lemmy_utils::{
   apub::{generate_actor_keypair, make_apub_endpoint, EndpointType},
index ad7355e1cb59326ecbcdd59c0529a68137cedbcc..927846c0a45d74dc50d6d74888bf1e0160ce0279 100644 (file)
@@ -3,13 +3,13 @@ use actix_web::{web, web::Data};
 use lemmy_db::{
   source::{
     community::{Community, CommunityModerator},
-    post::Post,
     user::User_,
   },
   views::community::community_user_ban_view::CommunityUserBanView,
   Crud,
   DbPool,
 };
+use lemmy_db_schema::source::post::Post;
 use lemmy_structs::{blocking, comment::*, community::*, post::*, site::*, user::*};
 use lemmy_utils::{settings::Settings, APIError, ConnectionId, LemmyError};
 use lemmy_websocket::{serialize_websocket_message, LemmyContext, UserOperation};
index 22f95877a294ae5e4e7bc1cdf3c25f267ea411cd..ee09059a5dedb63d31e42f52b57ee0268859aa56 100644 (file)
@@ -10,10 +10,8 @@ use crate::{
 use actix_web::web::Data;
 use lemmy_apub::{ApubLikeableType, ApubObjectType};
 use lemmy_db::{
-  naive_now,
   source::{
     moderator::*,
-    post::*,
     post_report::{PostReport, PostReportForm},
   },
   views::{
@@ -30,6 +28,10 @@ use lemmy_db::{
   Saveable,
   SortType,
 };
+use lemmy_db_schema::{
+  naive_now,
+  source::post::{Post, PostForm, PostLike, PostLikeForm, PostSaved, PostSavedForm},
+};
 use lemmy_structs::{blocking, post::*};
 use lemmy_utils::{
   apub::{make_apub_endpoint, EndpointType},
index 138cc8751edaa4bbcc14d0f9e435c67504d1cdb3..8eda284f6fb4d5ff96077762a8ae575197c5dde9 100644 (file)
@@ -12,7 +12,6 @@ use lemmy_apub::fetcher::search_by_apub_id;
 use lemmy_db::{
   aggregates::site_aggregates::SiteAggregates,
   diesel_option_overwrite,
-  naive_now,
   source::{category::*, moderator::*, site::*},
   views::{
     comment_view::CommentQueryBuilder,
@@ -36,6 +35,7 @@ use lemmy_db::{
   SearchType,
   SortType,
 };
+use lemmy_db_schema::naive_now;
 use lemmy_structs::{blocking, site::*, user::Register};
 use lemmy_utils::{
   location_info,
index f31e42e5a9cf12b095b32092dfa055275e601448..680910b849af0364cdede3074a4cf458bfe7d20a 100644 (file)
@@ -16,13 +16,10 @@ use chrono::Duration;
 use lemmy_apub::ApubObjectType;
 use lemmy_db::{
   diesel_option_overwrite,
-  naive_now,
   source::{
-    comment::*,
     community::*,
     moderator::*,
     password_reset_request::*,
-    post::*,
     private_message::*,
     site::*,
     user::*,
@@ -48,6 +45,10 @@ use lemmy_db::{
   ListingType,
   SortType,
 };
+use lemmy_db_schema::{
+  naive_now,
+  source::{comment::Comment, post::Post},
+};
 use lemmy_structs::{blocking, send_email_to_user, user::*};
 use lemmy_utils::{
   apub::{generate_actor_keypair, make_apub_endpoint, EndpointType},
index 2dd9a64a47bf45e5e16ac6546e2623d56168f120..e62ae9f0ca9b3b007181c111c3156d9d86e1efa7 100644 (file)
@@ -11,6 +11,7 @@ path = "src/lib.rs"
 [dependencies]
 lemmy_utils = { path = "../lemmy_utils" }
 lemmy_db = { path = "../lemmy_db" }
+lemmy_db_schema = { path = "../lemmy_db_schema" }
 lemmy_structs = { path = "../lemmy_structs" }
 lemmy_websocket = { path = "../lemmy_websocket" }
 diesel = "1.4.5"
index 700a2653c130a4f617e830d3b664b0c097d8fa01..76337c4fddbaab2aaafd34ed176fef554c92ed49 100644 (file)
@@ -4,13 +4,10 @@ use activitystreams::{
   base::ExtendsExt,
 };
 use anyhow::Context;
-use lemmy_db::{
-  source::{
-    comment::{Comment, CommentLike, CommentLikeForm},
-    post::Post,
-  },
-  views::comment_view::CommentView,
-  Likeable,
+use lemmy_db::{views::comment_view::CommentView, Likeable};
+use lemmy_db_schema::source::{
+  comment::{Comment, CommentLike, CommentLikeForm},
+  post::Post,
 };
 use lemmy_structs::{blocking, comment::CommentResponse, send_local_notifs};
 use lemmy_utils::{location_info, utils::scrape_text_for_mentions, LemmyError};
index 85dcc143d8989e60c7badb68773ef18cfbf3dfff..f446b28604e646bb3312bf361e607cea64b9a033 100644 (file)
@@ -1,10 +1,7 @@
 use crate::activities::receive::get_actor_as_user;
 use activitystreams::activity::{Dislike, Like};
-use lemmy_db::{
-  source::comment::{Comment, CommentLike},
-  views::comment_view::CommentView,
-  Likeable,
-};
+use lemmy_db::{views::comment_view::CommentView, Likeable};
+use lemmy_db_schema::source::comment::{Comment, CommentLike};
 use lemmy_structs::{blocking, comment::CommentResponse};
 use lemmy_utils::LemmyError;
 use lemmy_websocket::{messages::SendComment, LemmyContext, UserOperation};
index f09071129773077dcde6506cb992b9888f0c0017..4a3cc13f75614e563e68cb72c955db6f49bd5bab 100644 (file)
@@ -4,11 +4,8 @@ use activitystreams::{
   prelude::*,
 };
 use anyhow::Context;
-use lemmy_db::{
-  source::post::{Post, PostLike, PostLikeForm},
-  views::post_view::PostView,
-  Likeable,
-};
+use lemmy_db::{views::post_view::PostView, Likeable};
+use lemmy_db_schema::source::post::{Post, PostLike, PostLikeForm};
 use lemmy_structs::{blocking, post::PostResponse};
 use lemmy_utils::{location_info, LemmyError};
 use lemmy_websocket::{messages::SendPost, LemmyContext, UserOperation};
index 6827ded05f325bd8c8c95e1f9b092904c7f2d459..817a74e4105746db3ba74a3f38a3f75051db97e6 100644 (file)
@@ -1,10 +1,7 @@
 use crate::activities::receive::get_actor_as_user;
 use activitystreams::activity::{Dislike, Like};
-use lemmy_db::{
-  source::post::{Post, PostLike},
-  views::post_view::PostView,
-  Likeable,
-};
+use lemmy_db::{views::post_view::PostView, Likeable};
+use lemmy_db_schema::source::post::{Post, PostLike};
 use lemmy_structs::{blocking, post::PostResponse};
 use lemmy_utils::LemmyError;
 use lemmy_websocket::{messages::SendPost, LemmyContext, UserOperation};
index 6b417c2591b7062eee496370aef6f35f109a86b4..358e5020a805d2502fc5d2f70cf832a0e50c9949 100644 (file)
@@ -27,10 +27,11 @@ use activitystreams::{
 use anyhow::anyhow;
 use itertools::Itertools;
 use lemmy_db::{
-  source::{comment::Comment, community::Community, post::Post, user::User_},
+  source::{community::Community, user::User_},
   Crud,
   DbPool,
 };
+use lemmy_db_schema::source::{comment::Comment, post::Post};
 use lemmy_structs::{blocking, WebFingerResponse};
 use lemmy_utils::{
   request::{retry, RecvError},
index ec1ca67deb97f36f7a7b0fb9b947568d3db5d539..fd7f7c12ac90b1d3a027bf70fdbf340bcd38192c 100644 (file)
@@ -22,9 +22,10 @@ use activitystreams::{
   public,
 };
 use lemmy_db::{
-  source::{community::Community, post::Post, user::User_},
+  source::{community::Community, user::User_},
   Crud,
 };
+use lemmy_db_schema::source::post::Post;
 use lemmy_structs::blocking;
 use lemmy_utils::LemmyError;
 use lemmy_websocket::LemmyContext;
index 61cdbd47ab4b63e5c8d696e1452a20b1fe38013f..d06b221e25e3dedd7f22e371221b1589ef376de4 100644 (file)
@@ -13,11 +13,8 @@ use anyhow::{anyhow, Context};
 use chrono::NaiveDateTime;
 use diesel::result::Error::NotFound;
 use lemmy_db::{
-  naive_now,
   source::{
-    comment::Comment,
     community::{Community, CommunityModerator, CommunityModeratorForm},
-    post::Post,
     user::User_,
   },
   views::{
@@ -30,6 +27,10 @@ use lemmy_db::{
   Joinable,
   SearchType,
 };
+use lemmy_db_schema::{
+  naive_now,
+  source::{comment::Comment, post::Post},
+};
 use lemmy_structs::{blocking, site::SearchResponse};
 use lemmy_utils::{
   location_info,
index 16f4119027dafda6cfadd6b8a02f29630d9191f6..f71d542b063f85fb957c08b01028af7abab0b6ca 100644 (file)
@@ -4,7 +4,8 @@ use crate::{
 };
 use actix_web::{body::Body, web, web::Path, HttpResponse};
 use diesel::result::Error::NotFound;
-use lemmy_db::{source::comment::Comment, Crud};
+use lemmy_db::Crud;
+use lemmy_db_schema::source::comment::Comment;
 use lemmy_structs::blocking;
 use lemmy_utils::LemmyError;
 use lemmy_websocket::LemmyContext;
index a17e2abf91e5b71bccbbe7a2a173e1d9a7feec80..a1a7870f02e610f0c8d1c46608178a1bad190686 100644 (file)
@@ -10,9 +10,10 @@ use activitystreams::{
 };
 use actix_web::{body::Body, web, HttpResponse};
 use lemmy_db::{
-  source::{community::Community, post::Post},
+  source::community::Community,
   views::community::community_follower_view::CommunityFollowerView,
 };
+use lemmy_db_schema::source::post::Post;
 use lemmy_structs::blocking;
 use lemmy_utils::LemmyError;
 use lemmy_websocket::LemmyContext;
index 563af8456d9d4234739979aeb942a6cd2b983bb1..ad8464076e22eb70fc292c1618e660a3cb7603f5 100644 (file)
@@ -4,7 +4,7 @@ use crate::{
 };
 use actix_web::{body::Body, web, HttpResponse};
 use diesel::result::Error::NotFound;
-use lemmy_db::source::post::Post;
+use lemmy_db_schema::source::post::Post;
 use lemmy_structs::blocking;
 use lemmy_utils::LemmyError;
 use lemmy_websocket::LemmyContext;
index 73deb97176e832b1c89e134c975e12828f1dfce9..995a13995b68a9b456eb4db1f764b80bca0ef053 100644 (file)
@@ -41,11 +41,8 @@ use activitystreams::{
 };
 use anyhow::Context;
 use diesel::result::Error::NotFound;
-use lemmy_db::{
-  source::{comment::Comment, post::Post, site::Site},
-  ApubObject,
-  Crud,
-};
+use lemmy_db::{source::site::Site, ApubObject, Crud};
+use lemmy_db_schema::source::{comment::Comment, post::Post};
 use lemmy_structs::blocking;
 use lemmy_utils::{location_info, LemmyError};
 use lemmy_websocket::LemmyContext;
index 957966d7fe2abac86318ce596a6b01d11b60e361..9dd035c5d1f95ce77aa46954a8aa495c09297dd2 100644 (file)
@@ -24,15 +24,14 @@ use activitystreams::{
 };
 use anyhow::{anyhow, Context};
 use lemmy_db::{
-  source::{
-    comment::{Comment, CommentForm},
-    community::Community,
-    post::Post,
-    user::User_,
-  },
+  source::{community::Community, user::User_},
   Crud,
   DbPool,
 };
+use lemmy_db_schema::source::{
+  comment::{Comment, CommentForm},
+  post::Post,
+};
 use lemmy_structs::blocking;
 use lemmy_utils::{
   location_info,
index 9d8210a6ac0112ce466868c12179ee1022fab67e..f5fa2c31898e74f134621524915388cc812c598d 100644 (file)
@@ -23,11 +23,11 @@ use activitystreams::{
 use activitystreams_ext::Ext2;
 use anyhow::Context;
 use lemmy_db::{
-  naive_now,
   source::community::{Community, CommunityForm},
   views::community::community_moderator_view::CommunityModeratorView,
   DbPool,
 };
+use lemmy_db_schema::naive_now;
 use lemmy_structs::blocking;
 use lemmy_utils::{
   location_info,
index 9c9df5b1962cb3a2a97519f59d34d46b3bbcea90..7090cd163ef22573d7382ab0eaa8153dea14a2d9 100644 (file)
@@ -21,14 +21,11 @@ use activitystreams::{
 use activitystreams_ext::Ext1;
 use anyhow::Context;
 use lemmy_db::{
-  source::{
-    community::Community,
-    post::{Post, PostForm},
-    user::User_,
-  },
+  source::{community::Community, user::User_},
   Crud,
   DbPool,
 };
+use lemmy_db_schema::source::post::{Post, PostForm};
 use lemmy_structs::blocking;
 use lemmy_utils::{
   location_info,
index 8c3312d1f8f8a27ac79e303f4ae479f5fb94e8c1..6862867a5ee4ec9f94e308c28e1ba8cf8577d050 100644 (file)
@@ -19,11 +19,11 @@ use activitystreams::{
 use activitystreams_ext::Ext1;
 use anyhow::Context;
 use lemmy_db::{
-  naive_now,
   source::user::{UserForm, User_},
   ApubObject,
   DbPool,
 };
+use lemmy_db_schema::naive_now;
 use lemmy_structs::blocking;
 use lemmy_utils::{
   location_info,
index 47c40f7bc79be2cae8e780010ae244616044f5ff..cb94e6325e56a75cbf4fbc94be3f75e342c2cef7 100644 (file)
@@ -25,9 +25,7 @@ mod tests {
   use crate::{
     aggregates::community_aggregates::CommunityAggregates,
     source::{
-      comment::{Comment, CommentForm},
       community::{Community, CommunityFollower, CommunityFollowerForm, CommunityForm},
-      post::{Post, PostForm},
       user::{UserForm, User_},
     },
     tests::establish_unpooled_connection,
@@ -36,6 +34,10 @@ mod tests {
     ListingType,
     SortType,
   };
+  use lemmy_db_schema::source::{
+    comment::{Comment, CommentForm},
+    post::{Post, PostForm},
+  };
 
   #[test]
   fn test_crud() {
index 6cb3a7406721ae941f7abf10c8626c42cab61eb4..0b9bfa5fa12badc7cab4829de51fa191f3e3e533 100644 (file)
@@ -27,9 +27,7 @@ mod tests {
   use crate::{
     aggregates::post_aggregates::PostAggregates,
     source::{
-      comment::{Comment, CommentForm},
       community::{Community, CommunityForm},
-      post::{Post, PostForm, PostLike, PostLikeForm},
       user::{UserForm, User_},
     },
     tests::establish_unpooled_connection,
@@ -38,6 +36,10 @@ mod tests {
     ListingType,
     SortType,
   };
+  use lemmy_db_schema::source::{
+    comment::{Comment, CommentForm},
+    post::{Post, PostForm, PostLike, PostLikeForm},
+  };
 
   #[test]
   fn test_crud() {
index a3bd199c15b52e24552cb25952dda3bac5acc640..ea58b216692a2cf236aa974bb2a68ba3e3dad01d 100644 (file)
@@ -23,9 +23,7 @@ mod tests {
   use crate::{
     aggregates::site_aggregates::SiteAggregates,
     source::{
-      comment::{Comment, CommentForm},
       community::{Community, CommunityForm},
-      post::{Post, PostForm},
       user::{UserForm, User_},
     },
     tests::establish_unpooled_connection,
@@ -33,6 +31,10 @@ mod tests {
     ListingType,
     SortType,
   };
+  use lemmy_db_schema::source::{
+    comment::{Comment, CommentForm},
+    post::{Post, PostForm},
+  };
 
   #[test]
   fn test_crud() {
index f6eab46792e6299fbd3c429de74738c72d8cf591..91fa7460d20b59f746bc83c89a8af8d0aea56bf9 100644 (file)
@@ -26,9 +26,7 @@ mod tests {
   use crate::{
     aggregates::user_aggregates::UserAggregates,
     source::{
-      comment::{Comment, CommentForm, CommentLike, CommentLikeForm},
       community::{Community, CommunityForm},
-      post::{Post, PostForm, PostLike, PostLikeForm},
       user::{UserForm, User_},
     },
     tests::establish_unpooled_connection,
@@ -37,6 +35,10 @@ mod tests {
     ListingType,
     SortType,
   };
+  use lemmy_db_schema::source::{
+    comment::{Comment, CommentForm, CommentLike, CommentLikeForm},
+    post::{Post, PostForm, PostLike, PostLikeForm},
+  };
 
   #[test]
   fn test_crud() {
index 52180fb72f069d69b56dd81053576f367a4afc2a..9afb76191accc0f738fa4355eca1b6ca76189e84 100644 (file)
@@ -5,7 +5,6 @@ extern crate strum_macros;
 #[macro_use]
 extern crate lazy_static;
 
-use chrono::NaiveDateTime;
 use diesel::{result::Error, *};
 use regex::Regex;
 use serde::{Deserialize, Serialize};
@@ -181,10 +180,6 @@ pub fn limit_and_offset(page: Option<i64>, limit: Option<i64>) -> (i64, i64) {
   (limit, offset)
 }
 
-pub fn naive_now() -> NaiveDateTime {
-  chrono::prelude::Utc::now().naive_utc()
-}
-
 pub fn is_email_regex(test: &str) -> bool {
   EMAIL_REGEX.is_match(test)
 }
index 76cd9133d09828d37008aa54d8f144f34f194e98..17e9d637a76391eef6fc1d04f780655712718c6e 100644 (file)
@@ -1,74 +1,13 @@
-use super::post::Post;
-use crate::{naive_now, ApubObject, Crud, Likeable, Saveable};
+use crate::{ApubObject, Crud, Likeable, Saveable};
 use diesel::{dsl::*, result::Error, *};
-use lemmy_db_schema::schema::{comment, comment_alias_1, comment_like, comment_saved};
-use serde::Serialize;
-use url::{ParseError, Url};
-
-// WITH RECURSIVE MyTree AS (
-//     SELECT * FROM comment WHERE parent_id IS NULL
-//     UNION ALL
-//     SELECT m.* FROM comment AS m JOIN MyTree AS t ON m.parent_id = t.id
-// )
-// SELECT * FROM MyTree;
-
-#[derive(Clone, Queryable, Associations, Identifiable, PartialEq, Debug, Serialize)]
-#[belongs_to(Post)]
-#[table_name = "comment"]
-pub struct Comment {
-  pub id: i32,
-  pub creator_id: i32,
-  pub post_id: i32,
-  pub parent_id: Option<i32>,
-  pub content: String,
-  pub removed: bool,
-  pub read: bool, // Whether the recipient has read the comment or not
-  pub published: chrono::NaiveDateTime,
-  pub updated: Option<chrono::NaiveDateTime>,
-  pub deleted: bool,
-  pub ap_id: String,
-  pub local: bool,
-}
-
-#[derive(Clone, Queryable, Associations, Identifiable, PartialEq, Debug, Serialize)]
-#[belongs_to(Post)]
-#[table_name = "comment_alias_1"]
-pub struct CommentAlias1 {
-  pub id: i32,
-  pub creator_id: i32,
-  pub post_id: i32,
-  pub parent_id: Option<i32>,
-  pub content: String,
-  pub removed: bool,
-  pub read: bool, // Whether the recipient has read the comment or not
-  pub published: chrono::NaiveDateTime,
-  pub updated: Option<chrono::NaiveDateTime>,
-  pub deleted: bool,
-  pub ap_id: String,
-  pub local: bool,
-}
-
-#[derive(Insertable, AsChangeset, Clone)]
-#[table_name = "comment"]
-pub struct CommentForm {
-  pub creator_id: i32,
-  pub post_id: i32,
-  pub parent_id: Option<i32>,
-  pub content: String,
-  pub removed: Option<bool>,
-  pub read: Option<bool>,
-  pub published: Option<chrono::NaiveDateTime>,
-  pub updated: Option<chrono::NaiveDateTime>,
-  pub deleted: Option<bool>,
-  pub ap_id: Option<String>,
-  pub local: bool,
-}
-
-impl CommentForm {
-  pub fn get_ap_id(&self) -> Result<Url, ParseError> {
-    Url::parse(&self.ap_id.as_ref().unwrap_or(&"not_a_url".to_string()))
-  }
-}
+use lemmy_db_schema::source::comment::{
+  Comment,
+  CommentForm,
+  CommentLike,
+  CommentLikeForm,
+  CommentSaved,
+  CommentSavedForm,
+};
 
 impl Crud<CommentForm> for Comment {
   fn read(conn: &PgConnection, comment_id: i32) -> Result<Self, Error> {
@@ -117,106 +56,6 @@ impl ApubObject<CommentForm> for Comment {
   }
 }
 
-impl Comment {
-  pub fn update_ap_id(
-    conn: &PgConnection,
-    comment_id: i32,
-    apub_id: String,
-  ) -> Result<Self, Error> {
-    use lemmy_db_schema::schema::comment::dsl::*;
-
-    diesel::update(comment.find(comment_id))
-      .set(ap_id.eq(apub_id))
-      .get_result::<Self>(conn)
-  }
-
-  pub fn permadelete_for_creator(
-    conn: &PgConnection,
-    for_creator_id: i32,
-  ) -> Result<Vec<Self>, Error> {
-    use lemmy_db_schema::schema::comment::dsl::*;
-    diesel::update(comment.filter(creator_id.eq(for_creator_id)))
-      .set((
-        content.eq("*Permananently Deleted*"),
-        deleted.eq(true),
-        updated.eq(naive_now()),
-      ))
-      .get_results::<Self>(conn)
-  }
-
-  pub fn update_deleted(
-    conn: &PgConnection,
-    comment_id: i32,
-    new_deleted: bool,
-  ) -> Result<Self, Error> {
-    use lemmy_db_schema::schema::comment::dsl::*;
-    diesel::update(comment.find(comment_id))
-      .set((deleted.eq(new_deleted), updated.eq(naive_now())))
-      .get_result::<Self>(conn)
-  }
-
-  pub fn update_removed(
-    conn: &PgConnection,
-    comment_id: i32,
-    new_removed: bool,
-  ) -> Result<Self, Error> {
-    use lemmy_db_schema::schema::comment::dsl::*;
-    diesel::update(comment.find(comment_id))
-      .set((removed.eq(new_removed), updated.eq(naive_now())))
-      .get_result::<Self>(conn)
-  }
-
-  pub fn update_removed_for_creator(
-    conn: &PgConnection,
-    for_creator_id: i32,
-    new_removed: bool,
-  ) -> Result<Vec<Self>, Error> {
-    use lemmy_db_schema::schema::comment::dsl::*;
-    diesel::update(comment.filter(creator_id.eq(for_creator_id)))
-      .set((removed.eq(new_removed), updated.eq(naive_now())))
-      .get_results::<Self>(conn)
-  }
-
-  pub fn update_read(conn: &PgConnection, comment_id: i32, new_read: bool) -> Result<Self, Error> {
-    use lemmy_db_schema::schema::comment::dsl::*;
-    diesel::update(comment.find(comment_id))
-      .set(read.eq(new_read))
-      .get_result::<Self>(conn)
-  }
-
-  pub fn update_content(
-    conn: &PgConnection,
-    comment_id: i32,
-    new_content: &str,
-  ) -> Result<Self, Error> {
-    use lemmy_db_schema::schema::comment::dsl::*;
-    diesel::update(comment.find(comment_id))
-      .set((content.eq(new_content), updated.eq(naive_now())))
-      .get_result::<Self>(conn)
-  }
-}
-
-#[derive(Identifiable, Queryable, Associations, PartialEq, Debug, Clone)]
-#[belongs_to(Comment)]
-#[table_name = "comment_like"]
-pub struct CommentLike {
-  pub id: i32,
-  pub user_id: i32,
-  pub comment_id: i32,
-  pub post_id: i32, // TODO this is redundant
-  pub score: i16,
-  pub published: chrono::NaiveDateTime,
-}
-
-#[derive(Insertable, AsChangeset, Clone)]
-#[table_name = "comment_like"]
-pub struct CommentLikeForm {
-  pub user_id: i32,
-  pub comment_id: i32,
-  pub post_id: i32, // TODO this is redundant
-  pub score: i16,
-}
-
 impl Likeable<CommentLikeForm> for CommentLike {
   fn like(conn: &PgConnection, comment_like_form: &CommentLikeForm) -> Result<Self, Error> {
     use lemmy_db_schema::schema::comment_like::dsl::*;
@@ -238,23 +77,6 @@ impl Likeable<CommentLikeForm> for CommentLike {
   }
 }
 
-#[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
-#[belongs_to(Comment)]
-#[table_name = "comment_saved"]
-pub struct CommentSaved {
-  pub id: i32,
-  pub comment_id: i32,
-  pub user_id: i32,
-  pub published: chrono::NaiveDateTime,
-}
-
-#[derive(Insertable, AsChangeset)]
-#[table_name = "comment_saved"]
-pub struct CommentSavedForm {
-  pub comment_id: i32,
-  pub user_id: i32,
-}
-
 impl Saveable<CommentSavedForm> for CommentSaved {
   fn save(conn: &PgConnection, comment_saved_form: &CommentSavedForm) -> Result<Self, Error> {
     use lemmy_db_schema::schema::comment_saved::dsl::*;
@@ -279,12 +101,15 @@ impl Saveable<CommentSavedForm> for CommentSaved {
 #[cfg(test)]
 mod tests {
   use crate::{
-    source::{comment::*, community::*, post::*, user::*},
+    source::{community::*, user::*},
     tests::establish_unpooled_connection,
     Crud,
+    Likeable,
     ListingType,
+    Saveable,
     SortType,
   };
+  use lemmy_db_schema::source::{comment::*, post::*};
 
   #[test]
   fn test_crud() {
index 2937e6315cc34859419611fefbfcb57cf643b6de..d05d9e039ae261570eda9776c5f415bb90d1781f 100644 (file)
@@ -1,6 +1,6 @@
-use crate::{naive_now, source::comment::Comment, Reportable};
+use crate::Reportable;
 use diesel::{dsl::*, result::Error, *};
-use lemmy_db_schema::schema::comment_report;
+use lemmy_db_schema::{naive_now, schema::comment_report, source::comment::Comment};
 use serde::{Deserialize, Serialize};
 
 #[derive(Identifiable, Queryable, Associations, PartialEq, Serialize, Deserialize, Debug, Clone)]
index 05bc3c5c7193be9e64d2a13a68538f4fa8f1ddb7..13045cca7e1579a1e5d41812ac09163fd1309a20 100644 (file)
@@ -1,5 +1,4 @@
 use crate::{
-  naive_now,
   views::{community::community_moderator_view::CommunityModeratorView, user_view::UserViewSafe},
   ApubObject,
   Bannable,
@@ -8,11 +7,9 @@ use crate::{
   Joinable,
 };
 use diesel::{dsl::*, result::Error, *};
-use lemmy_db_schema::schema::{
-  community,
-  community_follower,
-  community_moderator,
-  community_user_ban,
+use lemmy_db_schema::{
+  naive_now,
+  schema::{community, community_follower, community_moderator, community_user_ban},
 };
 use serde::Serialize;
 
index 0766f49cd9951d125b120b351e4ea7de93a36bb7..eb6c2d5667f54ee6a220865c5b66ca05b3821154 100644 (file)
@@ -391,11 +391,12 @@ impl Crud<ModAddForm> for ModAdd {
 #[cfg(test)]
 mod tests {
   use crate::{
-    source::{comment::*, community::*, moderator::*, post::*, user::*},
+    source::{community::*, moderator::*, user::*},
     tests::establish_unpooled_connection,
     ListingType,
     SortType,
   };
+  use lemmy_db_schema::source::{comment::*, post::*};
 
   // use Crud;
   #[test]
index 181157a21da064f3840aaa8a25e0b73b6c37c0bc..5e8dc1cce2215c66031672273973cfa9d4f92df1 100644 (file)
@@ -1,61 +1,15 @@
-use crate::{naive_now, ApubObject, Crud, Likeable, Readable, Saveable};
+use crate::{ApubObject, Crud, Likeable, Readable, Saveable};
 use diesel::{dsl::*, result::Error, *};
-use lemmy_db_schema::schema::{post, post_like, post_read, post_saved};
-use serde::Serialize;
-use url::{ParseError, Url};
-
-#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
-#[table_name = "post"]
-pub struct Post {
-  pub id: i32,
-  pub name: String,
-  pub url: Option<String>,
-  pub body: Option<String>,
-  pub creator_id: i32,
-  pub community_id: i32,
-  pub removed: bool,
-  pub locked: bool,
-  pub published: chrono::NaiveDateTime,
-  pub updated: Option<chrono::NaiveDateTime>,
-  pub deleted: bool,
-  pub nsfw: bool,
-  pub stickied: bool,
-  pub embed_title: Option<String>,
-  pub embed_description: Option<String>,
-  pub embed_html: Option<String>,
-  pub thumbnail_url: Option<String>,
-  pub ap_id: String,
-  pub local: bool,
-}
-
-#[derive(Insertable, AsChangeset)]
-#[table_name = "post"]
-pub struct PostForm {
-  pub name: String,
-  pub url: Option<String>,
-  pub body: Option<String>,
-  pub creator_id: i32,
-  pub community_id: i32,
-  pub removed: Option<bool>,
-  pub locked: Option<bool>,
-  pub published: Option<chrono::NaiveDateTime>,
-  pub updated: Option<chrono::NaiveDateTime>,
-  pub deleted: Option<bool>,
-  pub nsfw: bool,
-  pub stickied: Option<bool>,
-  pub embed_title: Option<String>,
-  pub embed_description: Option<String>,
-  pub embed_html: Option<String>,
-  pub thumbnail_url: Option<String>,
-  pub ap_id: Option<String>,
-  pub local: bool,
-}
-
-impl PostForm {
-  pub fn get_ap_id(&self) -> Result<Url, ParseError> {
-    Url::parse(&self.ap_id.as_ref().unwrap_or(&"not_a_url".to_string()))
-  }
-}
+use lemmy_db_schema::source::post::{
+  Post,
+  PostForm,
+  PostLike,
+  PostLikeForm,
+  PostRead,
+  PostReadForm,
+  PostSaved,
+  PostSavedForm,
+};
 
 impl Crud<PostForm> for Post {
   fn read(conn: &PgConnection, post_id: i32) -> Result<Self, Error> {
@@ -98,137 +52,6 @@ impl ApubObject<PostForm> for Post {
   }
 }
 
-impl Post {
-  pub fn read(conn: &PgConnection, post_id: i32) -> Result<Self, Error> {
-    use lemmy_db_schema::schema::post::dsl::*;
-    post.filter(id.eq(post_id)).first::<Self>(conn)
-  }
-
-  pub fn list_for_community(
-    conn: &PgConnection,
-    the_community_id: i32,
-  ) -> Result<Vec<Self>, Error> {
-    use lemmy_db_schema::schema::post::dsl::*;
-    post
-      .filter(community_id.eq(the_community_id))
-      .then_order_by(published.desc())
-      .then_order_by(stickied.desc())
-      .limit(20)
-      .load::<Self>(conn)
-  }
-
-  pub fn update_ap_id(conn: &PgConnection, post_id: i32, apub_id: String) -> Result<Self, Error> {
-    use lemmy_db_schema::schema::post::dsl::*;
-
-    diesel::update(post.find(post_id))
-      .set(ap_id.eq(apub_id))
-      .get_result::<Self>(conn)
-  }
-
-  pub fn permadelete_for_creator(
-    conn: &PgConnection,
-    for_creator_id: i32,
-  ) -> Result<Vec<Self>, Error> {
-    use lemmy_db_schema::schema::post::dsl::*;
-
-    let perma_deleted = "*Permananently Deleted*";
-    let perma_deleted_url = "https://deleted.com";
-
-    diesel::update(post.filter(creator_id.eq(for_creator_id)))
-      .set((
-        name.eq(perma_deleted),
-        url.eq(perma_deleted_url),
-        body.eq(perma_deleted),
-        deleted.eq(true),
-        updated.eq(naive_now()),
-      ))
-      .get_results::<Self>(conn)
-  }
-
-  pub fn update_deleted(
-    conn: &PgConnection,
-    post_id: i32,
-    new_deleted: bool,
-  ) -> Result<Self, Error> {
-    use lemmy_db_schema::schema::post::dsl::*;
-    diesel::update(post.find(post_id))
-      .set((deleted.eq(new_deleted), updated.eq(naive_now())))
-      .get_result::<Self>(conn)
-  }
-
-  pub fn update_removed(
-    conn: &PgConnection,
-    post_id: i32,
-    new_removed: bool,
-  ) -> Result<Self, Error> {
-    use lemmy_db_schema::schema::post::dsl::*;
-    diesel::update(post.find(post_id))
-      .set((removed.eq(new_removed), updated.eq(naive_now())))
-      .get_result::<Self>(conn)
-  }
-
-  pub fn update_removed_for_creator(
-    conn: &PgConnection,
-    for_creator_id: i32,
-    for_community_id: Option<i32>,
-    new_removed: bool,
-  ) -> Result<Vec<Self>, Error> {
-    use lemmy_db_schema::schema::post::dsl::*;
-
-    let mut update = diesel::update(post).into_boxed();
-    update = update.filter(creator_id.eq(for_creator_id));
-
-    if let Some(for_community_id) = for_community_id {
-      update = update.filter(community_id.eq(for_community_id));
-    }
-
-    update
-      .set((removed.eq(new_removed), updated.eq(naive_now())))
-      .get_results::<Self>(conn)
-  }
-
-  pub fn update_locked(conn: &PgConnection, post_id: i32, new_locked: bool) -> Result<Self, Error> {
-    use lemmy_db_schema::schema::post::dsl::*;
-    diesel::update(post.find(post_id))
-      .set(locked.eq(new_locked))
-      .get_result::<Self>(conn)
-  }
-
-  pub fn update_stickied(
-    conn: &PgConnection,
-    post_id: i32,
-    new_stickied: bool,
-  ) -> Result<Self, Error> {
-    use lemmy_db_schema::schema::post::dsl::*;
-    diesel::update(post.find(post_id))
-      .set(stickied.eq(new_stickied))
-      .get_result::<Self>(conn)
-  }
-
-  pub fn is_post_creator(user_id: i32, post_creator_id: i32) -> bool {
-    user_id == post_creator_id
-  }
-}
-
-#[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
-#[belongs_to(Post)]
-#[table_name = "post_like"]
-pub struct PostLike {
-  pub id: i32,
-  pub post_id: i32,
-  pub user_id: i32,
-  pub score: i16,
-  pub published: chrono::NaiveDateTime,
-}
-
-#[derive(Insertable, AsChangeset, Clone)]
-#[table_name = "post_like"]
-pub struct PostLikeForm {
-  pub post_id: i32,
-  pub user_id: i32,
-  pub score: i16,
-}
-
 impl Likeable<PostLikeForm> for PostLike {
   fn like(conn: &PgConnection, post_like_form: &PostLikeForm) -> Result<Self, Error> {
     use lemmy_db_schema::schema::post_like::dsl::*;
@@ -250,23 +73,6 @@ impl Likeable<PostLikeForm> for PostLike {
   }
 }
 
-#[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
-#[belongs_to(Post)]
-#[table_name = "post_saved"]
-pub struct PostSaved {
-  pub id: i32,
-  pub post_id: i32,
-  pub user_id: i32,
-  pub published: chrono::NaiveDateTime,
-}
-
-#[derive(Insertable, AsChangeset)]
-#[table_name = "post_saved"]
-pub struct PostSavedForm {
-  pub post_id: i32,
-  pub user_id: i32,
-}
-
 impl Saveable<PostSavedForm> for PostSaved {
   fn save(conn: &PgConnection, post_saved_form: &PostSavedForm) -> Result<Self, Error> {
     use lemmy_db_schema::schema::post_saved::dsl::*;
@@ -288,27 +94,6 @@ impl Saveable<PostSavedForm> for PostSaved {
   }
 }
 
-#[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
-#[belongs_to(Post)]
-#[table_name = "post_read"]
-pub struct PostRead {
-  pub id: i32,
-
-  pub post_id: i32,
-
-  pub user_id: i32,
-
-  pub published: chrono::NaiveDateTime,
-}
-
-#[derive(Insertable, AsChangeset)]
-#[table_name = "post_read"]
-pub struct PostReadForm {
-  pub post_id: i32,
-
-  pub user_id: i32,
-}
-
 impl Readable<PostReadForm> for PostRead {
   fn mark_as_read(conn: &PgConnection, post_read_form: &PostReadForm) -> Result<Self, Error> {
     use lemmy_db_schema::schema::post_read::dsl::*;
index af45aa3d03e9d792a36f8ee27fcd014f91149f99..e72e32a858a04eead9bf565ffac02932cbf4d355 100644 (file)
@@ -1,6 +1,6 @@
-use crate::{naive_now, source::post::Post, Reportable};
+use crate::Reportable;
 use diesel::{dsl::*, result::Error, *};
-use lemmy_db_schema::schema::post_report;
+use lemmy_db_schema::{naive_now, schema::post_report, source::post::Post};
 use serde::{Deserialize, Serialize};
 
 #[derive(Identifiable, Queryable, Associations, PartialEq, Serialize, Deserialize, Debug, Clone)]
index e2b55c8798eae0f83dc33229d7d8338bccf2eedd..fd73a864687f57c4e75b7562e838e6a6718d4314 100644 (file)
@@ -1,6 +1,6 @@
-use crate::{naive_now, ApubObject, Crud};
+use crate::{ApubObject, Crud};
 use diesel::{dsl::*, result::Error, *};
-use lemmy_db_schema::schema::private_message;
+use lemmy_db_schema::{naive_now, schema::private_message};
 use serde::Serialize;
 
 #[derive(Clone, Queryable, Associations, Identifiable, PartialEq, Debug, Serialize)]
index ad6f9ea6faa8428f06014477348f929344351285..a7db2ceeaac717918b50b6114013d8cd9e54a2a3 100644 (file)
@@ -1,6 +1,6 @@
-use crate::{naive_now, Crud};
+use crate::Crud;
 use diesel::{dsl::*, result::Error, *};
-use lemmy_db_schema::schema::site;
+use lemmy_db_schema::{naive_now, schema::site};
 use serde::Serialize;
 
 #[derive(Queryable, Identifiable, PartialEq, Debug, Clone, Serialize)]
index 809a579afb31f21dfb7ea32ac01df6890bd7d8c7..6bca769e86ed2030076d18db49f30146a697273e 100644 (file)
@@ -1,7 +1,10 @@
-use crate::{is_email_regex, naive_now, ApubObject, Crud};
+use crate::{is_email_regex, ApubObject, Crud};
 use bcrypt::{hash, DEFAULT_COST};
 use diesel::{dsl::*, result::Error, *};
-use lemmy_db_schema::schema::{user_, user_::dsl::*, user_alias_1, user_alias_2};
+use lemmy_db_schema::{
+  naive_now,
+  schema::{user_, user_::dsl::*, user_alias_1, user_alias_2},
+};
 use lemmy_utils::settings::Settings;
 use serde::Serialize;
 
index a61d08d2c13213322efa75d1dba891095999492e..5df17286484b1f35ec87d411b040370b322e119e 100644 (file)
@@ -1,7 +1,6 @@
-use super::comment::Comment;
 use crate::Crud;
 use diesel::{dsl::*, result::Error, *};
-use lemmy_db_schema::schema::user_mention;
+use lemmy_db_schema::{schema::user_mention, source::comment::Comment};
 use serde::Serialize;
 
 #[derive(Clone, Queryable, Associations, Identifiable, PartialEq, Debug, Serialize)]
@@ -80,11 +79,12 @@ impl UserMention {
 #[cfg(test)]
 mod tests {
   use crate::{
-    source::{comment::*, community::*, post::*, user::*, user_mention::*},
+    source::{community::*, user::*, user_mention::*},
     tests::establish_unpooled_connection,
     ListingType,
     SortType,
   };
+  use lemmy_db_schema::source::{comment::*, post::*};
 
   #[test]
   fn test_crud() {
index 0f55b43200e18bbd43a8512caad9a96b85a23198..b067a9ec1512f1496869f4036b1affeb5aafe278 100644 (file)
@@ -1,10 +1,8 @@
 use crate::{
   limit_and_offset,
   source::{
-    comment::Comment,
     comment_report::CommentReport,
     community::{Community, CommunitySafe},
-    post::Post,
     user::{UserAlias1, UserAlias2, UserSafe, UserSafeAlias1, UserSafeAlias2, User_},
   },
   views::ViewToVec,
@@ -12,14 +10,9 @@ use crate::{
   ToSafe,
 };
 use diesel::{result::Error, *};
-use lemmy_db_schema::schema::{
-  comment,
-  comment_report,
-  community,
-  post,
-  user_,
-  user_alias_1,
-  user_alias_2,
+use lemmy_db_schema::{
+  schema::{comment, comment_report, community, post, user_, user_alias_1, user_alias_2},
+  source::{comment::Comment, post::Post},
 };
 use serde::Serialize;
 
index 7f78c20f8b280456922f2cffd1aa64a608909547..d4680a3411b9b9a525942a08524c8ccd23c9ba39 100644 (file)
@@ -4,9 +4,7 @@ use crate::{
   fuzzy_search,
   limit_and_offset,
   source::{
-    comment::{Comment, CommentAlias1, CommentSaved},
     community::{Community, CommunityFollower, CommunitySafe, CommunityUserBan},
-    post::Post,
     user::{UserAlias1, UserSafe, UserSafeAlias1, User_},
   },
   views::ViewToVec,
@@ -16,18 +14,24 @@ use crate::{
   ToSafe,
 };
 use diesel::{result::Error, *};
-use lemmy_db_schema::schema::{
-  comment,
-  comment_aggregates,
-  comment_alias_1,
-  comment_like,
-  comment_saved,
-  community,
-  community_follower,
-  community_user_ban,
-  post,
-  user_,
-  user_alias_1,
+use lemmy_db_schema::{
+  schema::{
+    comment,
+    comment_aggregates,
+    comment_alias_1,
+    comment_like,
+    comment_saved,
+    community,
+    community_follower,
+    community_user_ban,
+    post,
+    user_,
+    user_alias_1,
+  },
+  source::{
+    comment::{Comment, CommentAlias1, CommentSaved},
+    post::Post,
+  },
 };
 use serde::Serialize;
 
@@ -408,13 +412,14 @@ impl ViewToVec for CommentView {
 #[cfg(test)]
 mod tests {
   use crate::{
-    source::{comment::*, community::*, post::*, user::*},
+    source::{community::*, user::*},
     tests::establish_unpooled_connection,
     views::comment_view::*,
     Crud,
     Likeable,
     *,
   };
+  use lemmy_db_schema::source::{comment::*, post::*};
 
   #[test]
   fn test_crud() {
index 2d71a8819ba309790391f6dd4e64f1c18802ad76..685d83bbcf4bd525ae3381bc8d7ecb62b3466795 100644 (file)
@@ -3,14 +3,16 @@ use crate::{
   source::{
     community::{Community, CommunitySafe},
     moderator::ModLockPost,
-    post::Post,
     user::{UserSafe, User_},
   },
   views::ViewToVec,
   ToSafe,
 };
 use diesel::{result::Error, *};
-use lemmy_db_schema::schema::{community, mod_lock_post, post, user_};
+use lemmy_db_schema::{
+  schema::{community, mod_lock_post, post, user_},
+  source::post::Post,
+};
 use serde::Serialize;
 
 #[derive(Debug, Serialize, Clone)]
index 4fa82eed2bcfb7432f79392b13e6fd0a43e63692..0c6519de076710859369f4ea073913f3969ab410 100644 (file)
@@ -1,17 +1,18 @@
 use crate::{
   limit_and_offset,
   source::{
-    comment::Comment,
     community::{Community, CommunitySafe},
     moderator::ModRemoveComment,
-    post::Post,
     user::{UserAlias1, UserSafe, UserSafeAlias1, User_},
   },
   views::ViewToVec,
   ToSafe,
 };
 use diesel::{result::Error, *};
-use lemmy_db_schema::schema::{comment, community, mod_remove_comment, post, user_, user_alias_1};
+use lemmy_db_schema::{
+  schema::{comment, community, mod_remove_comment, post, user_, user_alias_1},
+  source::{comment::Comment, post::Post},
+};
 use serde::Serialize;
 
 #[derive(Debug, Serialize, Clone)]
index d21e985cdde6a418b5af351e193dff74fa056158..98aefd211e21084e59d021e60b0c6946dbacc47e 100644 (file)
@@ -3,14 +3,16 @@ use crate::{
   source::{
     community::{Community, CommunitySafe},
     moderator::ModRemovePost,
-    post::Post,
     user::{UserSafe, User_},
   },
   views::ViewToVec,
   ToSafe,
 };
 use diesel::{result::Error, *};
-use lemmy_db_schema::schema::{community, mod_remove_post, post, user_};
+use lemmy_db_schema::{
+  schema::{community, mod_remove_post, post, user_},
+  source::post::Post,
+};
 use serde::Serialize;
 
 #[derive(Debug, Serialize, Clone)]
index ec277159297873c36a657c3ad9b100f430147c2e..40672f8b17c1b24461c4dedc6c7d6925e28b79bf 100644 (file)
@@ -3,14 +3,16 @@ use crate::{
   source::{
     community::{Community, CommunitySafe},
     moderator::ModStickyPost,
-    post::Post,
     user::{UserSafe, User_},
   },
   views::ViewToVec,
   ToSafe,
 };
 use diesel::{result::Error, *};
-use lemmy_db_schema::schema::{community, mod_sticky_post, post, user_};
+use lemmy_db_schema::{
+  schema::{community, mod_sticky_post, post, user_},
+  source::post::Post,
+};
 use serde::Serialize;
 
 #[derive(Debug, Serialize, Clone)]
index 75bfac954957c811d2e959f70ca4989b391bb67d..5e186239932108d5e0bab43284fda50cce82b538 100644 (file)
@@ -2,7 +2,6 @@ use crate::{
   limit_and_offset,
   source::{
     community::{Community, CommunitySafe},
-    post::Post,
     post_report::PostReport,
     user::{UserAlias1, UserAlias2, UserSafe, UserSafeAlias1, UserSafeAlias2, User_},
   },
@@ -11,7 +10,10 @@ use crate::{
   ToSafe,
 };
 use diesel::{result::Error, *};
-use lemmy_db_schema::schema::{community, post, post_report, user_, user_alias_1, user_alias_2};
+use lemmy_db_schema::{
+  schema::{community, post, post_report, user_, user_alias_1, user_alias_2},
+  source::post::Post,
+};
 use serde::Serialize;
 
 #[derive(Debug, PartialEq, Serialize, Clone)]
index 25d86aa1600d9e939fd69bc9a3e5fc842233d587..fb3fbbf3f679ec9f255c6d5507fb253bafd63a9a 100644 (file)
@@ -5,7 +5,6 @@ use crate::{
   limit_and_offset,
   source::{
     community::{Community, CommunityFollower, CommunitySafe, CommunityUserBan},
-    post::{Post, PostRead, PostSaved},
     user::{UserSafe, User_},
   },
   views::ViewToVec,
@@ -15,16 +14,19 @@ use crate::{
   ToSafe,
 };
 use diesel::{result::Error, *};
-use lemmy_db_schema::schema::{
-  community,
-  community_follower,
-  community_user_ban,
-  post,
-  post_aggregates,
-  post_like,
-  post_read,
-  post_saved,
-  user_,
+use lemmy_db_schema::{
+  schema::{
+    community,
+    community_follower,
+    community_user_ban,
+    post,
+    post_aggregates,
+    post_like,
+    post_read,
+    post_saved,
+    user_,
+  },
+  source::post::{Post, PostRead, PostSaved},
 };
 use serde::Serialize;
 
@@ -406,13 +408,14 @@ impl ViewToVec for PostView {
 mod tests {
   use crate::{
     aggregates::post_aggregates::PostAggregates,
-    source::{community::*, post::*, user::*},
+    source::{community::*, user::*},
     tests::establish_unpooled_connection,
     views::post_view::{PostQueryBuilder, PostView},
     Crud,
     Likeable,
     *,
   };
+  use lemmy_db_schema::source::post::*;
 
   #[test]
   fn test_crud() {
index bb5fa00931938921834bbfbd1fd0802365b02fba..61fb56260bd62fac34dccba772742957f8b60968 100644 (file)
@@ -3,9 +3,7 @@ use crate::{
   functions::hot_rank,
   limit_and_offset,
   source::{
-    comment::{Comment, CommentSaved},
     community::{Community, CommunityFollower, CommunitySafe, CommunityUserBan},
-    post::Post,
     user::{UserAlias1, UserSafe, UserSafeAlias1, User_},
     user_mention::UserMention,
   },
@@ -15,18 +13,24 @@ use crate::{
   ToSafe,
 };
 use diesel::{result::Error, *};
-use lemmy_db_schema::schema::{
-  comment,
-  comment_aggregates,
-  comment_like,
-  comment_saved,
-  community,
-  community_follower,
-  community_user_ban,
-  post,
-  user_,
-  user_alias_1,
-  user_mention,
+use lemmy_db_schema::{
+  schema::{
+    comment,
+    comment_aggregates,
+    comment_like,
+    comment_saved,
+    community,
+    community_follower,
+    community_user_ban,
+    post,
+    user_,
+    user_alias_1,
+    user_mention,
+  },
+  source::{
+    comment::{Comment, CommentSaved},
+    post::Post,
+  },
 };
 use serde::Serialize;
 
index 3ef975505abe0bc1a79325fc7ec7f5ee8c12220e..99b7399b13734293045ccede4b4518a35f05f5da 100644 (file)
@@ -5,3 +5,8 @@ edition = "2018"
 
 [dependencies]
 diesel = { version = "1.4.5", features = ["postgres","chrono","r2d2","serde_json"] }
+chrono = { version = "0.4.19", features = ["serde"] }
+serde = { version = "1.0.118", features = ["derive"] }
+serde_json = { version = "1.0.60", features = ["preserve_order"] }
+log = "0.4.11"
+url = { version = "2.2.0", features = ["serde"] }
index b37d946111c41ad8c899674cf869de4554152fda..11451d173f2e2ca67bb17860699fd4e8f6beb79b 100644 (file)
@@ -1,4 +1,11 @@
 #[macro_use]
 extern crate diesel;
 
+use chrono::NaiveDateTime;
+
 pub mod schema;
+pub mod source;
+
+pub fn naive_now() -> NaiveDateTime {
+  chrono::prelude::Utc::now().naive_utc()
+}
diff --git a/lemmy_db_schema/src/source/comment.rs b/lemmy_db_schema/src/source/comment.rs
new file mode 100644 (file)
index 0000000..3457764
--- /dev/null
@@ -0,0 +1,190 @@
+use crate::{
+  naive_now,
+  schema::{comment, comment_alias_1, comment_like, comment_saved},
+  source::post::Post,
+};
+use diesel::{result::Error, PgConnection, *};
+use serde::Serialize;
+use url::{ParseError, Url};
+
+// WITH RECURSIVE MyTree AS (
+//     SELECT * FROM comment WHERE parent_id IS NULL
+//     UNION ALL
+//     SELECT m.* FROM comment AS m JOIN MyTree AS t ON m.parent_id = t.id
+// )
+// SELECT * FROM MyTree;
+
+#[derive(Clone, Queryable, Associations, Identifiable, PartialEq, Debug, Serialize)]
+#[belongs_to(Post)]
+#[table_name = "comment"]
+pub struct Comment {
+  pub id: i32,
+  pub creator_id: i32,
+  pub post_id: i32,
+  pub parent_id: Option<i32>,
+  pub content: String,
+  pub removed: bool,
+  pub read: bool, // Whether the recipient has read the comment or not
+  pub published: chrono::NaiveDateTime,
+  pub updated: Option<chrono::NaiveDateTime>,
+  pub deleted: bool,
+  pub ap_id: String,
+  pub local: bool,
+}
+
+#[derive(Clone, Queryable, Associations, Identifiable, PartialEq, Debug, Serialize)]
+#[belongs_to(Post)]
+#[table_name = "comment_alias_1"]
+pub struct CommentAlias1 {
+  pub id: i32,
+  pub creator_id: i32,
+  pub post_id: i32,
+  pub parent_id: Option<i32>,
+  pub content: String,
+  pub removed: bool,
+  pub read: bool, // Whether the recipient has read the comment or not
+  pub published: chrono::NaiveDateTime,
+  pub updated: Option<chrono::NaiveDateTime>,
+  pub deleted: bool,
+  pub ap_id: String,
+  pub local: bool,
+}
+
+#[derive(Insertable, AsChangeset, Clone)]
+#[table_name = "comment"]
+pub struct CommentForm {
+  pub creator_id: i32,
+  pub post_id: i32,
+  pub parent_id: Option<i32>,
+  pub content: String,
+  pub removed: Option<bool>,
+  pub read: Option<bool>,
+  pub published: Option<chrono::NaiveDateTime>,
+  pub updated: Option<chrono::NaiveDateTime>,
+  pub deleted: Option<bool>,
+  pub ap_id: Option<String>,
+  pub local: bool,
+}
+
+impl Comment {
+  pub fn update_ap_id(
+    conn: &PgConnection,
+    comment_id: i32,
+    apub_id: String,
+  ) -> Result<Self, Error> {
+    use crate::schema::comment::dsl::*;
+
+    diesel::update(comment.find(comment_id))
+      .set(ap_id.eq(apub_id))
+      .get_result::<Self>(conn)
+  }
+
+  pub fn permadelete_for_creator(
+    conn: &PgConnection,
+    for_creator_id: i32,
+  ) -> Result<Vec<Self>, Error> {
+    use crate::schema::comment::dsl::*;
+    diesel::update(comment.filter(creator_id.eq(for_creator_id)))
+      .set((
+        content.eq("*Permananently Deleted*"),
+        deleted.eq(true),
+        updated.eq(naive_now()),
+      ))
+      .get_results::<Self>(conn)
+  }
+
+  pub fn update_deleted(
+    conn: &PgConnection,
+    comment_id: i32,
+    new_deleted: bool,
+  ) -> Result<Self, Error> {
+    use crate::schema::comment::dsl::*;
+    diesel::update(comment.find(comment_id))
+      .set((deleted.eq(new_deleted), updated.eq(naive_now())))
+      .get_result::<Self>(conn)
+  }
+
+  pub fn update_removed(
+    conn: &PgConnection,
+    comment_id: i32,
+    new_removed: bool,
+  ) -> Result<Self, Error> {
+    use crate::schema::comment::dsl::*;
+    diesel::update(comment.find(comment_id))
+      .set((removed.eq(new_removed), updated.eq(naive_now())))
+      .get_result::<Self>(conn)
+  }
+
+  pub fn update_removed_for_creator(
+    conn: &PgConnection,
+    for_creator_id: i32,
+    new_removed: bool,
+  ) -> Result<Vec<Self>, Error> {
+    use crate::schema::comment::dsl::*;
+    diesel::update(comment.filter(creator_id.eq(for_creator_id)))
+      .set((removed.eq(new_removed), updated.eq(naive_now())))
+      .get_results::<Self>(conn)
+  }
+
+  pub fn update_read(conn: &PgConnection, comment_id: i32, new_read: bool) -> Result<Self, Error> {
+    use crate::schema::comment::dsl::*;
+    diesel::update(comment.find(comment_id))
+      .set(read.eq(new_read))
+      .get_result::<Self>(conn)
+  }
+
+  pub fn update_content(
+    conn: &PgConnection,
+    comment_id: i32,
+    new_content: &str,
+  ) -> Result<Self, Error> {
+    use crate::schema::comment::dsl::*;
+    diesel::update(comment.find(comment_id))
+      .set((content.eq(new_content), updated.eq(naive_now())))
+      .get_result::<Self>(conn)
+  }
+}
+
+impl CommentForm {
+  pub fn get_ap_id(&self) -> Result<Url, ParseError> {
+    Url::parse(&self.ap_id.as_ref().unwrap_or(&"not_a_url".to_string()))
+  }
+}
+
+#[derive(Identifiable, Queryable, Associations, PartialEq, Debug, Clone)]
+#[belongs_to(Comment)]
+#[table_name = "comment_like"]
+pub struct CommentLike {
+  pub id: i32,
+  pub user_id: i32,
+  pub comment_id: i32,
+  pub post_id: i32, // TODO this is redundant
+  pub score: i16,
+  pub published: chrono::NaiveDateTime,
+}
+
+#[derive(Insertable, AsChangeset, Clone)]
+#[table_name = "comment_like"]
+pub struct CommentLikeForm {
+  pub user_id: i32,
+  pub comment_id: i32,
+  pub post_id: i32, // TODO this is redundant
+  pub score: i16,
+}
+
+#[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
+#[belongs_to(Comment)]
+#[table_name = "comment_saved"]
+pub struct CommentSaved {
+  pub id: i32,
+  pub comment_id: i32,
+  pub user_id: i32,
+  pub published: chrono::NaiveDateTime,
+}
+
+#[derive(Insertable, AsChangeset)]
+#[table_name = "comment_saved"]
+pub struct CommentSavedForm {
+  pub comment_id: i32,
+  pub user_id: i32,
+}
diff --git a/lemmy_db_schema/src/source/mod.rs b/lemmy_db_schema/src/source/mod.rs
new file mode 100644 (file)
index 0000000..38203b5
--- /dev/null
@@ -0,0 +1,2 @@
+pub mod comment;
+pub mod post;
diff --git a/lemmy_db_schema/src/source/post.rs b/lemmy_db_schema/src/source/post.rs
new file mode 100644 (file)
index 0000000..a0b974e
--- /dev/null
@@ -0,0 +1,229 @@
+use crate::{
+  naive_now,
+  schema::{post, post_like, post_read, post_saved},
+};
+use diesel::{result::Error, *};
+use serde::Serialize;
+use url::{ParseError, Url};
+
+#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
+#[table_name = "post"]
+pub struct Post {
+  pub id: i32,
+  pub name: String,
+  pub url: Option<String>,
+  pub body: Option<String>,
+  pub creator_id: i32,
+  pub community_id: i32,
+  pub removed: bool,
+  pub locked: bool,
+  pub published: chrono::NaiveDateTime,
+  pub updated: Option<chrono::NaiveDateTime>,
+  pub deleted: bool,
+  pub nsfw: bool,
+  pub stickied: bool,
+  pub embed_title: Option<String>,
+  pub embed_description: Option<String>,
+  pub embed_html: Option<String>,
+  pub thumbnail_url: Option<String>,
+  pub ap_id: String,
+  pub local: bool,
+}
+
+#[derive(Insertable, AsChangeset)]
+#[table_name = "post"]
+pub struct PostForm {
+  pub name: String,
+  pub url: Option<String>,
+  pub body: Option<String>,
+  pub creator_id: i32,
+  pub community_id: i32,
+  pub removed: Option<bool>,
+  pub locked: Option<bool>,
+  pub published: Option<chrono::NaiveDateTime>,
+  pub updated: Option<chrono::NaiveDateTime>,
+  pub deleted: Option<bool>,
+  pub nsfw: bool,
+  pub stickied: Option<bool>,
+  pub embed_title: Option<String>,
+  pub embed_description: Option<String>,
+  pub embed_html: Option<String>,
+  pub thumbnail_url: Option<String>,
+  pub ap_id: Option<String>,
+  pub local: bool,
+}
+
+impl Post {
+  pub fn read(conn: &PgConnection, post_id: i32) -> Result<Self, Error> {
+    use crate::schema::post::dsl::*;
+    post.filter(id.eq(post_id)).first::<Self>(conn)
+  }
+
+  pub fn list_for_community(
+    conn: &PgConnection,
+    the_community_id: i32,
+  ) -> Result<Vec<Self>, Error> {
+    use crate::schema::post::dsl::*;
+    post
+      .filter(community_id.eq(the_community_id))
+      .then_order_by(published.desc())
+      .then_order_by(stickied.desc())
+      .limit(20)
+      .load::<Self>(conn)
+  }
+
+  pub fn update_ap_id(conn: &PgConnection, post_id: i32, apub_id: String) -> Result<Self, Error> {
+    use crate::schema::post::dsl::*;
+
+    diesel::update(post.find(post_id))
+      .set(ap_id.eq(apub_id))
+      .get_result::<Self>(conn)
+  }
+
+  pub fn permadelete_for_creator(
+    conn: &PgConnection,
+    for_creator_id: i32,
+  ) -> Result<Vec<Self>, Error> {
+    use crate::schema::post::dsl::*;
+
+    let perma_deleted = "*Permananently Deleted*";
+    let perma_deleted_url = "https://deleted.com";
+
+    diesel::update(post.filter(creator_id.eq(for_creator_id)))
+      .set((
+        name.eq(perma_deleted),
+        url.eq(perma_deleted_url),
+        body.eq(perma_deleted),
+        deleted.eq(true),
+        updated.eq(naive_now()),
+      ))
+      .get_results::<Self>(conn)
+  }
+
+  pub fn update_deleted(
+    conn: &PgConnection,
+    post_id: i32,
+    new_deleted: bool,
+  ) -> Result<Self, Error> {
+    use crate::schema::post::dsl::*;
+    diesel::update(post.find(post_id))
+      .set((deleted.eq(new_deleted), updated.eq(naive_now())))
+      .get_result::<Self>(conn)
+  }
+
+  pub fn update_removed(
+    conn: &PgConnection,
+    post_id: i32,
+    new_removed: bool,
+  ) -> Result<Self, Error> {
+    use crate::schema::post::dsl::*;
+    diesel::update(post.find(post_id))
+      .set((removed.eq(new_removed), updated.eq(naive_now())))
+      .get_result::<Self>(conn)
+  }
+
+  pub fn update_removed_for_creator(
+    conn: &PgConnection,
+    for_creator_id: i32,
+    for_community_id: Option<i32>,
+    new_removed: bool,
+  ) -> Result<Vec<Self>, Error> {
+    use crate::schema::post::dsl::*;
+
+    let mut update = diesel::update(post).into_boxed();
+    update = update.filter(creator_id.eq(for_creator_id));
+
+    if let Some(for_community_id) = for_community_id {
+      update = update.filter(community_id.eq(for_community_id));
+    }
+
+    update
+      .set((removed.eq(new_removed), updated.eq(naive_now())))
+      .get_results::<Self>(conn)
+  }
+
+  pub fn update_locked(conn: &PgConnection, post_id: i32, new_locked: bool) -> Result<Self, Error> {
+    use crate::schema::post::dsl::*;
+    diesel::update(post.find(post_id))
+      .set(locked.eq(new_locked))
+      .get_result::<Self>(conn)
+  }
+
+  pub fn update_stickied(
+    conn: &PgConnection,
+    post_id: i32,
+    new_stickied: bool,
+  ) -> Result<Self, Error> {
+    use crate::schema::post::dsl::*;
+    diesel::update(post.find(post_id))
+      .set(stickied.eq(new_stickied))
+      .get_result::<Self>(conn)
+  }
+
+  pub fn is_post_creator(user_id: i32, post_creator_id: i32) -> bool {
+    user_id == post_creator_id
+  }
+}
+
+impl PostForm {
+  pub fn get_ap_id(&self) -> Result<Url, ParseError> {
+    Url::parse(&self.ap_id.as_ref().unwrap_or(&"not_a_url".to_string()))
+  }
+}
+
+#[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
+#[belongs_to(Post)]
+#[table_name = "post_like"]
+pub struct PostLike {
+  pub id: i32,
+  pub post_id: i32,
+  pub user_id: i32,
+  pub score: i16,
+  pub published: chrono::NaiveDateTime,
+}
+
+#[derive(Insertable, AsChangeset, Clone)]
+#[table_name = "post_like"]
+pub struct PostLikeForm {
+  pub post_id: i32,
+  pub user_id: i32,
+  pub score: i16,
+}
+
+#[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
+#[belongs_to(Post)]
+#[table_name = "post_saved"]
+pub struct PostSaved {
+  pub id: i32,
+  pub post_id: i32,
+  pub user_id: i32,
+  pub published: chrono::NaiveDateTime,
+}
+
+#[derive(Insertable, AsChangeset)]
+#[table_name = "post_saved"]
+pub struct PostSavedForm {
+  pub post_id: i32,
+  pub user_id: i32,
+}
+
+#[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
+#[belongs_to(Post)]
+#[table_name = "post_read"]
+pub struct PostRead {
+  pub id: i32,
+
+  pub post_id: i32,
+
+  pub user_id: i32,
+
+  pub published: chrono::NaiveDateTime,
+}
+
+#[derive(Insertable, AsChangeset)]
+#[table_name = "post_read"]
+pub struct PostReadForm {
+  pub post_id: i32,
+
+  pub user_id: i32,
+}
index e146230640265e4a8a4c697157043e6df8798ff4..329ef4139a125e9d5454498c299dce4091b11439 100644 (file)
@@ -10,6 +10,7 @@ path = "src/lib.rs"
 
 [dependencies]
 lemmy_db = { path = "../lemmy_db" }
+lemmy_db_schema = { path = "../lemmy_db_schema" }
 lemmy_utils = { path = "../lemmy_utils" }
 serde = { version = "1.0.118", features = ["derive"] }
 log = "0.4.11"
index dc06a40cd1c05415353bf5b08b203998df6c8829..595f6d0741845d9c41dc58ef763d9f06272824de 100644 (file)
@@ -8,14 +8,13 @@ pub mod websocket;
 use diesel::PgConnection;
 use lemmy_db::{
   source::{
-    comment::Comment,
-    post::Post,
     user::User_,
     user_mention::{UserMention, UserMentionForm},
   },
   Crud,
   DbPool,
 };
+use lemmy_db_schema::source::{comment::Comment, post::Post};
 use lemmy_utils::{email::send_email, settings::Settings, utils::MentionData, LemmyError};
 use log::error;
 use serde::{Deserialize, Serialize};
index ed0ba4ce0dcd9f85fe5295a78d9568423379dab2..30dbe1fbd370b20d883c86b72ac5e9e9278227db 100644 (file)
@@ -12,6 +12,7 @@ path = "src/lib.rs"
 lemmy_utils = { path = "../lemmy_utils" }
 lemmy_structs = { path = "../lemmy_structs" }
 lemmy_db = { path = "../lemmy_db" }
+lemmy_db_schema = { path = "../lemmy_db_schema" }
 lemmy_rate_limit = { path = "../lemmy_rate_limit" }
 reqwest = { version = "0.10.10", features = ["json"] }
 log = "0.4.11"
index d95dfd57fab8d82b5d882badccfbe2970b81c7a2..0762b948541ef8c06373d266eeb3019e8b2cbbbc 100644 (file)
@@ -3,7 +3,7 @@ use crate::{
   messages::*,
 };
 use actix::{Actor, Context, Handler, ResponseFuture};
-use lemmy_db::naive_now;
+use lemmy_db_schema::naive_now;
 use log::{error, info};
 use rand::Rng;
 use serde::Serialize;
index 6a39d0dadfec4bc577ba4b3493324fcccf19afd1..c294be67c60ba9121823db606c174f2f43ff67c3 100644 (file)
@@ -4,16 +4,17 @@ use diesel::{
   *,
 };
 use lemmy_db::{
-  naive_now,
   source::{
-    comment::Comment,
     community::{Community, CommunityForm},
-    post::Post,
     private_message::PrivateMessage,
     user::{UserForm, User_},
   },
   Crud,
 };
+use lemmy_db_schema::{
+  naive_now,
+  source::{comment::Comment, post::Post},
+};
 use lemmy_utils::{
   apub::{generate_actor_keypair, make_apub_endpoint, EndpointType},
   settings::Settings,