Split up lemmy_db_views, put lemmy_rate_limit into lemmy_utils

This commit is contained in:
Felix Ableitner 2020-12-22 00:27:42 +01:00
parent d5efebbf47
commit 95e30f0e08
99 changed files with 294 additions and 253 deletions

50
Cargo.lock generated
View file

@ -1720,7 +1720,8 @@ dependencies = [
"lemmy_db_queries", "lemmy_db_queries",
"lemmy_db_schema", "lemmy_db_schema",
"lemmy_db_views", "lemmy_db_views",
"lemmy_rate_limit", "lemmy_db_views_actor",
"lemmy_db_views_moderator",
"lemmy_structs", "lemmy_structs",
"lemmy_utils", "lemmy_utils",
"lemmy_websocket", "lemmy_websocket",
@ -1766,6 +1767,7 @@ dependencies = [
"lemmy_db_queries", "lemmy_db_queries",
"lemmy_db_schema", "lemmy_db_schema",
"lemmy_db_views", "lemmy_db_views",
"lemmy_db_views_actor",
"lemmy_structs", "lemmy_structs",
"lemmy_utils", "lemmy_utils",
"lemmy_websocket", "lemmy_websocket",
@ -1785,17 +1787,6 @@ dependencies = [
"uuid", "uuid",
] ]
[[package]]
name = "lemmy_db_aggregates"
version = "0.1.0"
dependencies = [
"chrono",
"diesel",
"lemmy_db_queries",
"lemmy_db_schema",
"serde 1.0.118",
]
[[package]] [[package]]
name = "lemmy_db_queries" name = "lemmy_db_queries"
version = "0.1.0" version = "0.1.0"
@ -1834,23 +1825,29 @@ name = "lemmy_db_views"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"diesel", "diesel",
"lemmy_db_aggregates",
"lemmy_db_queries", "lemmy_db_queries",
"lemmy_db_schema", "lemmy_db_schema",
"serde 1.0.118", "serde 1.0.118",
] ]
[[package]] [[package]]
name = "lemmy_rate_limit" name = "lemmy_db_views_actor"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"actix-web", "diesel",
"futures", "lemmy_db_queries",
"lemmy_utils", "lemmy_db_schema",
"log", "serde 1.0.118",
"strum", ]
"strum_macros",
"tokio 0.3.6", [[package]]
name = "lemmy_db_views_moderator"
version = "0.1.0"
dependencies = [
"diesel",
"lemmy_db_queries",
"lemmy_db_schema",
"serde 1.0.118",
] ]
[[package]] [[package]]
@ -1874,11 +1871,11 @@ dependencies = [
"lazy_static", "lazy_static",
"lemmy_api", "lemmy_api",
"lemmy_apub", "lemmy_apub",
"lemmy_db_aggregates",
"lemmy_db_queries", "lemmy_db_queries",
"lemmy_db_schema", "lemmy_db_schema",
"lemmy_db_views", "lemmy_db_views",
"lemmy_rate_limit", "lemmy_db_views_actor",
"lemmy_db_views_moderator",
"lemmy_structs", "lemmy_structs",
"lemmy_utils", "lemmy_utils",
"lemmy_websocket", "lemmy_websocket",
@ -1904,6 +1901,8 @@ dependencies = [
"lemmy_db_queries", "lemmy_db_queries",
"lemmy_db_schema", "lemmy_db_schema",
"lemmy_db_views", "lemmy_db_views",
"lemmy_db_views_actor",
"lemmy_db_views_moderator",
"lemmy_utils", "lemmy_utils",
"log", "log",
"serde 1.0.118", "serde 1.0.118",
@ -1920,6 +1919,7 @@ dependencies = [
"chrono", "chrono",
"comrak", "comrak",
"config", "config",
"futures",
"itertools", "itertools",
"lazy_static", "lazy_static",
"lettre", "lettre",
@ -1931,7 +1931,10 @@ dependencies = [
"reqwest", "reqwest",
"serde 1.0.118", "serde 1.0.118",
"serde_json", "serde_json",
"strum",
"strum_macros",
"thiserror", "thiserror",
"tokio 0.3.6",
"url", "url",
] ]
@ -1946,7 +1949,6 @@ dependencies = [
"diesel", "diesel",
"lemmy_db_queries", "lemmy_db_queries",
"lemmy_db_schema", "lemmy_db_schema",
"lemmy_rate_limit",
"lemmy_structs", "lemmy_structs",
"lemmy_utils", "lemmy_utils",
"log", "log",

View file

@ -13,8 +13,10 @@ members = [
"lemmy_utils", "lemmy_utils",
"lemmy_db_queries", "lemmy_db_queries",
"lemmy_db_schema", "lemmy_db_schema",
"lemmy_db_views",
"lemmy_db_views_actor",
"lemmy_db_views_actor",
"lemmy_structs", "lemmy_structs",
"lemmy_rate_limit",
"lemmy_websocket", "lemmy_websocket",
] ]
@ -25,9 +27,9 @@ lemmy_utils = { path = "./lemmy_utils" }
lemmy_db_schema = { path = "./lemmy_db_schema" } lemmy_db_schema = { path = "./lemmy_db_schema" }
lemmy_db_queries = { path = "lemmy_db_queries" } lemmy_db_queries = { path = "lemmy_db_queries" }
lemmy_db_views = { path = "./lemmy_db_views" } lemmy_db_views = { path = "./lemmy_db_views" }
lemmy_db_aggregates = { path = "./lemmy_db_aggregates" } lemmy_db_views_moderator = { path = "./lemmy_db_views_moderator" }
lemmy_db_views_actor = { path = "lemmy_db_views_actor" }
lemmy_structs = { path = "./lemmy_structs" } lemmy_structs = { path = "./lemmy_structs" }
lemmy_rate_limit = { path = "./lemmy_rate_limit" }
lemmy_websocket = { path = "./lemmy_websocket" } lemmy_websocket = { path = "./lemmy_websocket" }
diesel = "1.4.5" diesel = "1.4.5"
diesel_migrations = "1.4.0" diesel_migrations = "1.4.0"

View file

@ -14,8 +14,9 @@ lemmy_utils = { path = "../lemmy_utils" }
lemmy_db_queries = { path = "../lemmy_db_queries" } lemmy_db_queries = { path = "../lemmy_db_queries" }
lemmy_db_schema = { path = "../lemmy_db_schema" } lemmy_db_schema = { path = "../lemmy_db_schema" }
lemmy_db_views = { path = "../lemmy_db_views" } lemmy_db_views = { path = "../lemmy_db_views" }
lemmy_db_views_moderator = { path = "../lemmy_db_views_moderator" }
lemmy_db_views_actor = { path = "../lemmy_db_views_actor" }
lemmy_structs = { path = "../lemmy_structs" } lemmy_structs = { path = "../lemmy_structs" }
lemmy_rate_limit = { path = "../lemmy_rate_limit" }
lemmy_websocket = { path = "../lemmy_websocket" } lemmy_websocket = { path = "../lemmy_websocket" }
diesel = "1.4.5" diesel = "1.4.5"
bcrypt = "0.9.0" bcrypt = "0.9.0"

View file

@ -10,7 +10,7 @@ use crate::{
}; };
use actix_web::web::Data; use actix_web::web::Data;
use lemmy_apub::{ApubLikeableType, ApubObjectType}; use lemmy_apub::{ApubLikeableType, ApubObjectType};
use lemmy_db::{ use lemmy_db_queries::{
source::comment::Comment_, source::comment::Comment_,
Crud, Crud,
Likeable, Likeable,

View file

@ -9,7 +9,7 @@ use crate::{
use actix_web::web::Data; use actix_web::web::Data;
use anyhow::Context; use anyhow::Context;
use lemmy_apub::ActorType; use lemmy_apub::ActorType;
use lemmy_db::{ use lemmy_db_queries::{
diesel_option_overwrite, diesel_option_overwrite,
source::{ source::{
comment::Comment_, comment::Comment_,
@ -27,13 +27,11 @@ use lemmy_db_schema::{
naive_now, naive_now,
source::{comment::Comment, community::*, moderator::*, post::Post, site::*}, source::{comment::Comment, community::*, moderator::*, post::Post, site::*},
}; };
use lemmy_db_views::{ use lemmy_db_views::comment_view::CommentQueryBuilder;
comment_view::CommentQueryBuilder, use lemmy_db_views_actor::{
community::{ community_follower_view::CommunityFollowerView,
community_follower_view::CommunityFollowerView, community_moderator_view::CommunityModeratorView,
community_moderator_view::CommunityModeratorView, community_view::{CommunityQueryBuilder, CommunityView},
community_view::{CommunityQueryBuilder, CommunityView},
},
user_view::UserViewSafe, user_view::UserViewSafe,
}; };
use lemmy_structs::{blocking, community::*}; use lemmy_structs::{blocking, community::*};

View file

@ -1,6 +1,6 @@
use crate::claims::Claims; use crate::claims::Claims;
use actix_web::{web, web::Data}; use actix_web::{web, web::Data};
use lemmy_db::{ use lemmy_db_queries::{
source::{ source::{
community::{CommunityModerator_, Community_}, community::{CommunityModerator_, Community_},
site::Site_, site::Site_,
@ -14,7 +14,7 @@ use lemmy_db_schema::source::{
site::Site, site::Site,
user::User_, user::User_,
}; };
use lemmy_db_views::community::{ use lemmy_db_views_actor::{
community_user_ban_view::CommunityUserBanView, community_user_ban_view::CommunityUserBanView,
community_view::CommunityView, community_view::CommunityView,
}; };

View file

@ -10,7 +10,15 @@ use crate::{
}; };
use actix_web::web::Data; use actix_web::web::Data;
use lemmy_apub::{ApubLikeableType, ApubObjectType}; use lemmy_apub::{ApubLikeableType, ApubObjectType};
use lemmy_db::{source::post::Post_, Crud, Likeable, ListingType, Reportable, Saveable, SortType}; use lemmy_db_queries::{
source::post::Post_,
Crud,
Likeable,
ListingType,
Reportable,
Saveable,
SortType,
};
use lemmy_db_schema::{ use lemmy_db_schema::{
naive_now, naive_now,
source::{ source::{
@ -21,10 +29,10 @@ use lemmy_db_schema::{
}; };
use lemmy_db_views::{ use lemmy_db_views::{
comment_view::CommentQueryBuilder, comment_view::CommentQueryBuilder,
community::community_moderator_view::CommunityModeratorView,
post_report_view::{PostReportQueryBuilder, PostReportView}, post_report_view::{PostReportQueryBuilder, PostReportView},
post_view::{PostQueryBuilder, PostView}, post_view::{PostQueryBuilder, PostView},
}; };
use lemmy_db_views_actor::community_moderator_view::CommunityModeratorView;
use lemmy_structs::{blocking, post::*}; use lemmy_structs::{blocking, post::*};
use lemmy_utils::{ use lemmy_utils::{
apub::{make_apub_endpoint, EndpointType}, apub::{make_apub_endpoint, EndpointType},

View file

@ -9,7 +9,7 @@ use crate::{
use actix_web::web::Data; use actix_web::web::Data;
use anyhow::Context; use anyhow::Context;
use lemmy_apub::fetcher::search_by_apub_id; use lemmy_apub::fetcher::search_by_apub_id;
use lemmy_db::{ use lemmy_db_queries::{
diesel_option_overwrite, diesel_option_overwrite,
source::{category::Category_, site::Site_}, source::{category::Category_, site::Site_},
Crud, Crud,
@ -26,22 +26,24 @@ use lemmy_db_schema::{
}; };
use lemmy_db_views::{ use lemmy_db_views::{
comment_view::CommentQueryBuilder, comment_view::CommentQueryBuilder,
community::community_view::CommunityQueryBuilder,
moderator::{
mod_add_community_view::ModAddCommunityView,
mod_add_view::ModAddView,
mod_ban_from_community_view::ModBanFromCommunityView,
mod_ban_view::ModBanView,
mod_lock_post_view::ModLockPostView,
mod_remove_comment_view::ModRemoveCommentView,
mod_remove_community_view::ModRemoveCommunityView,
mod_remove_post_view::ModRemovePostView,
mod_sticky_post_view::ModStickyPostView,
},
post_view::PostQueryBuilder, post_view::PostQueryBuilder,
site_view::SiteView, site_view::SiteView,
};
use lemmy_db_views_actor::{
community_view::CommunityQueryBuilder,
user_view::{UserQueryBuilder, UserViewSafe}, user_view::{UserQueryBuilder, UserViewSafe},
}; };
use lemmy_db_views_moderator::{
mod_add_community_view::ModAddCommunityView,
mod_add_view::ModAddView,
mod_ban_from_community_view::ModBanFromCommunityView,
mod_ban_view::ModBanView,
mod_lock_post_view::ModLockPostView,
mod_remove_comment_view::ModRemoveCommentView,
mod_remove_community_view::ModRemoveCommunityView,
mod_remove_post_view::ModRemovePostView,
mod_sticky_post_view::ModStickyPostView,
};
use lemmy_structs::{blocking, site::*, user::Register}; use lemmy_structs::{blocking, site::*, user::Register};
use lemmy_utils::{ use lemmy_utils::{
location_info, location_info,

View file

@ -14,7 +14,7 @@ use bcrypt::verify;
use captcha::{gen, Difficulty}; use captcha::{gen, Difficulty};
use chrono::Duration; use chrono::Duration;
use lemmy_apub::ApubObjectType; use lemmy_apub::ApubObjectType;
use lemmy_db::{ use lemmy_db_queries::{
diesel_option_overwrite, diesel_option_overwrite,
source::{ source::{
comment::Comment_, comment::Comment_,
@ -49,13 +49,13 @@ use lemmy_db_schema::{
use lemmy_db_views::{ use lemmy_db_views::{
comment_report_view::CommentReportView, comment_report_view::CommentReportView,
comment_view::CommentQueryBuilder, comment_view::CommentQueryBuilder,
community::{
community_follower_view::CommunityFollowerView,
community_moderator_view::CommunityModeratorView,
},
post_report_view::PostReportView, post_report_view::PostReportView,
post_view::PostQueryBuilder, post_view::PostQueryBuilder,
private_message_view::{PrivateMessageQueryBuilder, PrivateMessageView}, private_message_view::{PrivateMessageQueryBuilder, PrivateMessageView},
};
use lemmy_db_views_actor::{
community_follower_view::CommunityFollowerView,
community_moderator_view::CommunityModeratorView,
user_mention_view::{UserMentionQueryBuilder, UserMentionView}, user_mention_view::{UserMentionQueryBuilder, UserMentionView},
user_view::{UserViewDangerous, UserViewSafe}, user_view::{UserViewDangerous, UserViewSafe},
}; };

View file

@ -13,6 +13,7 @@ lemmy_utils = { path = "../lemmy_utils" }
lemmy_db_queries = { path = "../lemmy_db_queries" } lemmy_db_queries = { path = "../lemmy_db_queries" }
lemmy_db_schema = { path = "../lemmy_db_schema" } lemmy_db_schema = { path = "../lemmy_db_schema" }
lemmy_db_views = { path = "../lemmy_db_views" } lemmy_db_views = { path = "../lemmy_db_views" }
lemmy_db_views_actor = { path = "../lemmy_db_views_actor" }
lemmy_structs = { path = "../lemmy_structs" } lemmy_structs = { path = "../lemmy_structs" }
lemmy_websocket = { path = "../lemmy_websocket" } lemmy_websocket = { path = "../lemmy_websocket" }
diesel = "1.4.5" diesel = "1.4.5"

View file

@ -4,7 +4,7 @@ use activitystreams::{
base::ExtendsExt, base::ExtendsExt,
}; };
use anyhow::Context; use anyhow::Context;
use lemmy_db::{source::comment::Comment_, Crud, Likeable}; use lemmy_db_queries::{source::comment::Comment_, Crud, Likeable};
use lemmy_db_schema::source::{ use lemmy_db_schema::source::{
comment::{Comment, CommentLike, CommentLikeForm}, comment::{Comment, CommentLike, CommentLikeForm},
post::Post, post::Post,

View file

@ -1,6 +1,6 @@
use crate::activities::receive::get_actor_as_user; use crate::activities::receive::get_actor_as_user;
use activitystreams::activity::{Dislike, Like}; use activitystreams::activity::{Dislike, Like};
use lemmy_db::{source::comment::Comment_, Likeable}; use lemmy_db_queries::{source::comment::Comment_, Likeable};
use lemmy_db_schema::source::comment::{Comment, CommentLike}; use lemmy_db_schema::source::comment::{Comment, CommentLike};
use lemmy_db_views::comment_view::CommentView; use lemmy_db_views::comment_view::CommentView;
use lemmy_structs::{blocking, comment::CommentResponse}; use lemmy_structs::{blocking, comment::CommentResponse};

View file

@ -4,9 +4,9 @@ use activitystreams::{
base::{AnyBase, ExtendsExt}, base::{AnyBase, ExtendsExt},
}; };
use anyhow::Context; use anyhow::Context;
use lemmy_db::{source::community::Community_, ApubObject}; use lemmy_db_queries::{source::community::Community_, ApubObject};
use lemmy_db_schema::source::community::Community; use lemmy_db_schema::source::community::Community;
use lemmy_db_views::community::community_view::CommunityView; use lemmy_db_views_actor::community_view::CommunityView;
use lemmy_structs::{blocking, community::CommunityResponse}; use lemmy_structs::{blocking, community::CommunityResponse};
use lemmy_utils::{location_info, LemmyError}; use lemmy_utils::{location_info, LemmyError};
use lemmy_websocket::{messages::SendCommunityRoomMessage, LemmyContext, UserOperation}; use lemmy_websocket::{messages::SendCommunityRoomMessage, LemmyContext, UserOperation};

View file

@ -4,7 +4,7 @@ use activitystreams::{
prelude::*, prelude::*,
}; };
use anyhow::Context; use anyhow::Context;
use lemmy_db::{source::post::Post_, Likeable}; use lemmy_db_queries::{source::post::Post_, Likeable};
use lemmy_db_schema::source::post::{Post, PostLike, PostLikeForm}; use lemmy_db_schema::source::post::{Post, PostLike, PostLikeForm};
use lemmy_db_views::post_view::PostView; use lemmy_db_views::post_view::PostView;
use lemmy_structs::{blocking, post::PostResponse}; use lemmy_structs::{blocking, post::PostResponse};

View file

@ -1,6 +1,6 @@
use crate::activities::receive::get_actor_as_user; use crate::activities::receive::get_actor_as_user;
use activitystreams::activity::{Dislike, Like}; use activitystreams::activity::{Dislike, Like};
use lemmy_db::{source::post::Post_, Likeable}; use lemmy_db_queries::{source::post::Post_, Likeable};
use lemmy_db_schema::source::post::{Post, PostLike}; use lemmy_db_schema::source::post::{Post, PostLike};
use lemmy_db_views::post_view::PostView; use lemmy_db_views::post_view::PostView;
use lemmy_structs::{blocking, post::PostResponse}; use lemmy_structs::{blocking, post::PostResponse};

View file

@ -13,7 +13,7 @@ use activitystreams::{
public, public,
}; };
use anyhow::{anyhow, Context}; use anyhow::{anyhow, Context};
use lemmy_db::source::private_message::PrivateMessage_; use lemmy_db_queries::source::private_message::PrivateMessage_;
use lemmy_db_schema::source::private_message::PrivateMessage; use lemmy_db_schema::source::private_message::PrivateMessage;
use lemmy_db_views::private_message_view::PrivateMessageView; use lemmy_db_views::private_message_view::PrivateMessageView;
use lemmy_structs::{blocking, user::PrivateMessageResponse}; use lemmy_structs::{blocking, user::PrivateMessageResponse};

View file

@ -26,7 +26,7 @@ use activitystreams::{
}; };
use anyhow::anyhow; use anyhow::anyhow;
use itertools::Itertools; use itertools::Itertools;
use lemmy_db::{Crud, DbPool}; use lemmy_db_queries::{Crud, DbPool};
use lemmy_db_schema::source::{comment::Comment, community::Community, post::Post, user::User_}; use lemmy_db_schema::source::{comment::Comment, community::Community, post::Post, user::User_};
use lemmy_structs::{blocking, WebFingerResponse}; use lemmy_structs::{blocking, WebFingerResponse};
use lemmy_utils::{ use lemmy_utils::{

View file

@ -23,9 +23,9 @@ use activitystreams::{
}; };
use anyhow::Context; use anyhow::Context;
use itertools::Itertools; use itertools::Itertools;
use lemmy_db::DbPool; use lemmy_db_queries::DbPool;
use lemmy_db_schema::source::community::Community; use lemmy_db_schema::source::community::Community;
use lemmy_db_views::community::community_follower_view::CommunityFollowerView; use lemmy_db_views_actor::community_follower_view::CommunityFollowerView;
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::{location_info, settings::Settings, LemmyError}; use lemmy_utils::{location_info, settings::Settings, LemmyError};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;

View file

@ -21,7 +21,7 @@ use activitystreams::{
prelude::*, prelude::*,
public, public,
}; };
use lemmy_db::Crud; use lemmy_db_queries::Crud;
use lemmy_db_schema::source::{community::Community, post::Post, user::User_}; use lemmy_db_schema::source::{community::Community, post::Post, user::User_};
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::LemmyError; use lemmy_utils::LemmyError;

View file

@ -16,7 +16,7 @@ use activitystreams::{
}, },
prelude::*, prelude::*,
}; };
use lemmy_db::Crud; use lemmy_db_queries::Crud;
use lemmy_db_schema::source::{private_message::PrivateMessage, user::User_}; use lemmy_db_schema::source::{private_message::PrivateMessage, user::User_};
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::LemmyError; use lemmy_utils::LemmyError;

View file

@ -13,7 +13,7 @@ use activitystreams::{
base::{AnyBase, BaseExt, ExtendsExt}, base::{AnyBase, BaseExt, ExtendsExt},
object::ObjectExt, object::ObjectExt,
}; };
use lemmy_db::{ApubObject, DbPool, Followable}; use lemmy_db_queries::{ApubObject, DbPool, Followable};
use lemmy_db_schema::source::{ use lemmy_db_schema::source::{
community::{Community, CommunityFollower, CommunityFollowerForm}, community::{Community, CommunityFollower, CommunityFollowerForm},
user::User_, user::User_,

View file

@ -19,7 +19,7 @@ use background_jobs::{
WorkerConfig, WorkerConfig,
}; };
use itertools::Itertools; use itertools::Itertools;
use lemmy_db::DbPool; use lemmy_db_queries::DbPool;
use lemmy_db_schema::source::{community::Community, user::User_}; use lemmy_db_schema::source::{community::Community, user::User_};
use lemmy_utils::{location_info, settings::Settings, LemmyError}; use lemmy_utils::{location_info, settings::Settings, LemmyError};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;

View file

@ -1,7 +1,7 @@
use activitystreams::unparsed::UnparsedMutExt; use activitystreams::unparsed::UnparsedMutExt;
use activitystreams_ext::UnparsedExtension; use activitystreams_ext::UnparsedExtension;
use diesel::PgConnection; use diesel::PgConnection;
use lemmy_db::Crud; use lemmy_db_queries::Crud;
use lemmy_db_schema::source::category::Category; use lemmy_db_schema::source::category::Category;
use lemmy_utils::LemmyError; use lemmy_utils::LemmyError;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View file

@ -12,7 +12,7 @@ use activitystreams::{base::BaseExt, collection::OrderedCollection, prelude::*};
use anyhow::{anyhow, Context}; use anyhow::{anyhow, Context};
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use diesel::result::Error::NotFound; use diesel::result::Error::NotFound;
use lemmy_db::{source::user::User, ApubObject, Crud, Joinable, SearchType}; use lemmy_db_queries::{source::user::User, ApubObject, Crud, Joinable, SearchType};
use lemmy_db_schema::{ use lemmy_db_schema::{
naive_now, naive_now,
source::{ source::{
@ -22,12 +22,8 @@ use lemmy_db_schema::{
user::User_, user::User_,
}, },
}; };
use lemmy_db_views::{ use lemmy_db_views::{comment_view::CommentView, post_view::PostView};
comment_view::CommentView, use lemmy_db_views_actor::{community_view::CommunityView, user_view::UserViewSafe};
community::community_view::CommunityView,
post_view::PostView,
user_view::UserViewSafe,
};
use lemmy_structs::{blocking, site::SearchResponse}; use lemmy_structs::{blocking, site::SearchResponse};
use lemmy_utils::{ use lemmy_utils::{
location_info, location_info,

View file

@ -4,7 +4,7 @@ use crate::{
}; };
use actix_web::{body::Body, web, web::Path, HttpResponse}; use actix_web::{body::Body, web, web::Path, HttpResponse};
use diesel::result::Error::NotFound; use diesel::result::Error::NotFound;
use lemmy_db::Crud; use lemmy_db_queries::Crud;
use lemmy_db_schema::source::comment::Comment; use lemmy_db_schema::source::comment::Comment;
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::LemmyError; use lemmy_utils::LemmyError;

View file

@ -9,9 +9,9 @@ use activitystreams::{
collection::{CollectionExt, OrderedCollection, UnorderedCollection}, collection::{CollectionExt, OrderedCollection, UnorderedCollection},
}; };
use actix_web::{body::Body, web, HttpResponse}; use actix_web::{body::Body, web, HttpResponse};
use lemmy_db::source::{community::Community_, post::Post_}; use lemmy_db_queries::source::{community::Community_, post::Post_};
use lemmy_db_schema::source::{community::Community, post::Post}; use lemmy_db_schema::source::{community::Community, post::Post};
use lemmy_db_views::community::community_follower_view::CommunityFollowerView; use lemmy_db_views_actor::community_follower_view::CommunityFollowerView;
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::LemmyError; use lemmy_utils::LemmyError;
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;

View file

@ -1,6 +1,6 @@
use crate::APUB_JSON_CONTENT_TYPE; use crate::APUB_JSON_CONTENT_TYPE;
use actix_web::{body::Body, web, HttpResponse}; use actix_web::{body::Body, web, HttpResponse};
use lemmy_db::source::activity::Activity_; use lemmy_db_queries::source::activity::Activity_;
use lemmy_db_schema::source::activity::Activity; use lemmy_db_schema::source::activity::Activity;
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::{settings::Settings, LemmyError}; use lemmy_utils::{settings::Settings, LemmyError};

View file

@ -4,7 +4,7 @@ use crate::{
}; };
use actix_web::{body::Body, web, HttpResponse}; use actix_web::{body::Body, web, HttpResponse};
use diesel::result::Error::NotFound; use diesel::result::Error::NotFound;
use lemmy_db::Crud; use lemmy_db_queries::Crud;
use lemmy_db_schema::source::post::Post; use lemmy_db_schema::source::post::Post;
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::LemmyError; use lemmy_utils::LemmyError;

View file

@ -9,7 +9,7 @@ use activitystreams::{
collection::{CollectionExt, OrderedCollection}, collection::{CollectionExt, OrderedCollection},
}; };
use actix_web::{body::Body, web, HttpResponse}; use actix_web::{body::Body, web, HttpResponse};
use lemmy_db::source::user::User; use lemmy_db_queries::source::user::User;
use lemmy_db_schema::source::user::User_; use lemmy_db_schema::source::user::User_;
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::LemmyError; use lemmy_utils::LemmyError;

View file

@ -26,12 +26,12 @@ use activitystreams::{
}; };
use actix_web::{web, HttpRequest, HttpResponse}; use actix_web::{web, HttpRequest, HttpResponse};
use anyhow::{anyhow, Context}; use anyhow::{anyhow, Context};
use lemmy_db::{source::community::Community_, ApubObject, DbPool, Followable}; use lemmy_db_queries::{source::community::Community_, ApubObject, DbPool, Followable};
use lemmy_db_schema::source::{ use lemmy_db_schema::source::{
community::{Community, CommunityFollower, CommunityFollowerForm}, community::{Community, CommunityFollower, CommunityFollowerForm},
user::User_, user::User_,
}; };
use lemmy_db_views::community::community_user_ban_view::CommunityUserBanView; use lemmy_db_views_actor::community_user_ban_view::CommunityUserBanView;
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::{location_info, LemmyError}; use lemmy_utils::{location_info, LemmyError};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;

View file

@ -12,7 +12,7 @@ use activitystreams::{
}; };
use actix_web::HttpRequest; use actix_web::HttpRequest;
use anyhow::{anyhow, Context}; use anyhow::{anyhow, Context};
use lemmy_db::{source::activity::Activity_, ApubObject, DbPool}; use lemmy_db_queries::{source::activity::Activity_, ApubObject, DbPool};
use lemmy_db_schema::source::{activity::Activity, community::Community, user::User_}; use lemmy_db_schema::source::{activity::Activity, community::Community, user::User_};
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::{location_info, settings::Settings, LemmyError}; use lemmy_utils::{location_info, settings::Settings, LemmyError};

View file

@ -41,7 +41,7 @@ use activitystreams::{
}; };
use anyhow::Context; use anyhow::Context;
use diesel::result::Error::NotFound; use diesel::result::Error::NotFound;
use lemmy_db::{ApubObject, Crud}; use lemmy_db_queries::{ApubObject, Crud};
use lemmy_db_schema::source::{comment::Comment, post::Post, site::Site}; use lemmy_db_schema::source::{comment::Comment, post::Post, site::Site};
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::{location_info, LemmyError}; use lemmy_utils::{location_info, LemmyError};

View file

@ -15,7 +15,7 @@ use crate::{
use activitystreams::{activity::ActorAndObject, prelude::*}; use activitystreams::{activity::ActorAndObject, prelude::*};
use actix_web::{web, HttpRequest, HttpResponse}; use actix_web::{web, HttpRequest, HttpResponse};
use anyhow::Context; use anyhow::Context;
use lemmy_db::{ApubObject, DbPool}; use lemmy_db_queries::{ApubObject, DbPool};
use lemmy_db_schema::source::community::Community; use lemmy_db_schema::source::community::Community;
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::{location_info, LemmyError}; use lemmy_utils::{location_info, LemmyError};

View file

@ -48,7 +48,7 @@ use activitystreams::{
use actix_web::{web, HttpRequest, HttpResponse}; use actix_web::{web, HttpRequest, HttpResponse};
use anyhow::{anyhow, Context}; use anyhow::{anyhow, Context};
use diesel::NotFound; use diesel::NotFound;
use lemmy_db::{source::user::User, ApubObject, Followable}; use lemmy_db_queries::{source::user::User, ApubObject, Followable};
use lemmy_db_schema::source::{ use lemmy_db_schema::source::{
community::{Community, CommunityFollower}, community::{Community, CommunityFollower},
private_message::PrivateMessage, private_message::PrivateMessage,

View file

@ -22,7 +22,7 @@ use activitystreams::{
}; };
use activitystreams_ext::{Ext1, Ext2}; use activitystreams_ext::{Ext1, Ext2};
use anyhow::{anyhow, Context}; use anyhow::{anyhow, Context};
use lemmy_db::{source::activity::Activity_, DbPool}; use lemmy_db_queries::{source::activity::Activity_, DbPool};
use lemmy_db_schema::source::{activity::Activity, user::User_}; use lemmy_db_schema::source::{activity::Activity, user::User_};
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::{location_info, settings::Settings, LemmyError}; use lemmy_utils::{location_info, settings::Settings, LemmyError};

View file

@ -23,7 +23,7 @@ use activitystreams::{
prelude::*, prelude::*,
}; };
use anyhow::{anyhow, Context}; use anyhow::{anyhow, Context};
use lemmy_db::{Crud, DbPool}; use lemmy_db_queries::{Crud, DbPool};
use lemmy_db_schema::source::{ use lemmy_db_schema::source::{
comment::{Comment, CommentForm}, comment::{Comment, CommentForm},
community::Community, community::Community,

View file

@ -22,12 +22,12 @@ use activitystreams::{
}; };
use activitystreams_ext::Ext2; use activitystreams_ext::Ext2;
use anyhow::Context; use anyhow::Context;
use lemmy_db::DbPool; use lemmy_db_queries::DbPool;
use lemmy_db_schema::{ use lemmy_db_schema::{
naive_now, naive_now,
source::community::{Community, CommunityForm}, source::community::{Community, CommunityForm},
}; };
use lemmy_db_views::community::community_moderator_view::CommunityModeratorView; use lemmy_db_views_actor::community_moderator_view::CommunityModeratorView;
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::{ use lemmy_utils::{
location_info, location_info,

View file

@ -11,7 +11,7 @@ use activitystreams::{
}; };
use anyhow::{anyhow, Context}; use anyhow::{anyhow, Context};
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use lemmy_db::{ApubObject, Crud, DbPool}; use lemmy_db_queries::{ApubObject, Crud, DbPool};
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::{location_info, settings::Settings, utils::convert_datetime, LemmyError}; use lemmy_utils::{location_info, settings::Settings, utils::convert_datetime, LemmyError};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;

View file

@ -20,7 +20,7 @@ use activitystreams::{
}; };
use activitystreams_ext::Ext1; use activitystreams_ext::Ext1;
use anyhow::Context; use anyhow::Context;
use lemmy_db::{Crud, DbPool}; use lemmy_db_queries::{Crud, DbPool};
use lemmy_db_schema::source::{ use lemmy_db_schema::source::{
community::Community, community::Community,
post::{Post, PostForm}, post::{Post, PostForm},

View file

@ -19,7 +19,7 @@ use activitystreams::{
prelude::*, prelude::*,
}; };
use anyhow::Context; use anyhow::Context;
use lemmy_db::{Crud, DbPool}; use lemmy_db_queries::{Crud, DbPool};
use lemmy_db_schema::source::{ use lemmy_db_schema::source::{
private_message::{PrivateMessage, PrivateMessageForm}, private_message::{PrivateMessage, PrivateMessageForm},
user::User_, user::User_,

View file

@ -18,7 +18,7 @@ use activitystreams::{
}; };
use activitystreams_ext::Ext1; use activitystreams_ext::Ext1;
use anyhow::Context; use anyhow::Context;
use lemmy_db::{ApubObject, DbPool}; use lemmy_db_queries::{ApubObject, DbPool};
use lemmy_db_schema::{ use lemmy_db_schema::{
naive_now, naive_now,
source::user::{UserForm, User_}, source::user::{UserForm, User_},

View file

@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2018" edition = "2018"
[lib] [lib]
name = "lemmy_db" name = "lemmy_db_queries"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]

View file

@ -22,8 +22,14 @@ impl CommentAggregates {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::comment_aggregates::CommentAggregates; use crate::{
use lemmy_db::{establish_unpooled_connection, Crud, Likeable, ListingType, SortType}; aggregates::comment_aggregates::CommentAggregates,
establish_unpooled_connection,
Crud,
Likeable,
ListingType,
SortType,
};
use lemmy_db_schema::source::{ use lemmy_db_schema::source::{
comment::{Comment, CommentForm, CommentLike, CommentLikeForm}, comment::{Comment, CommentForm, CommentLike, CommentLikeForm},
community::{Community, CommunityForm}, community::{Community, CommunityForm},

View file

@ -22,8 +22,14 @@ impl CommunityAggregates {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::community_aggregates::CommunityAggregates; use crate::{
use lemmy_db::{establish_unpooled_connection, Crud, Followable, ListingType, SortType}; aggregates::community_aggregates::CommunityAggregates,
establish_unpooled_connection,
Crud,
Followable,
ListingType,
SortType,
};
use lemmy_db_schema::source::{ use lemmy_db_schema::source::{
comment::{Comment, CommentForm}, comment::{Comment, CommentForm},
community::{Community, CommunityFollower, CommunityFollowerForm, CommunityForm}, community::{Community, CommunityFollower, CommunityFollowerForm, CommunityForm},

View file

@ -24,8 +24,14 @@ impl PostAggregates {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::post_aggregates::PostAggregates; use crate::{
use lemmy_db::{establish_unpooled_connection, Crud, Likeable, ListingType, SortType}; aggregates::post_aggregates::PostAggregates,
establish_unpooled_connection,
Crud,
Likeable,
ListingType,
SortType,
};
use lemmy_db_schema::source::{ use lemmy_db_schema::source::{
comment::{Comment, CommentForm}, comment::{Comment, CommentForm},
community::{Community, CommunityForm}, community::{Community, CommunityForm},

View file

@ -21,8 +21,13 @@ impl SiteAggregates {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::site_aggregates::SiteAggregates; use crate::{
use lemmy_db::{establish_unpooled_connection, Crud, ListingType, SortType}; aggregates::site_aggregates::SiteAggregates,
establish_unpooled_connection,
Crud,
ListingType,
SortType,
};
use lemmy_db_schema::source::{ use lemmy_db_schema::source::{
comment::{Comment, CommentForm}, comment::{Comment, CommentForm},
community::{Community, CommunityForm}, community::{Community, CommunityForm},

View file

@ -23,8 +23,14 @@ impl UserAggregates {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::user_aggregates::UserAggregates; use crate::{
use lemmy_db::{establish_unpooled_connection, Crud, Likeable, ListingType, SortType}; aggregates::user_aggregates::UserAggregates,
establish_unpooled_connection,
Crud,
Likeable,
ListingType,
SortType,
};
use lemmy_db_schema::source::{ use lemmy_db_schema::source::{
comment::{Comment, CommentForm, CommentLike, CommentLikeForm}, comment::{Comment, CommentForm, CommentLike, CommentLikeForm},
community::{Community, CommunityForm}, community::{Community, CommunityForm},

View file

@ -14,6 +14,7 @@ use regex::Regex;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{env, env::VarError}; use std::{env, env::VarError};
pub mod aggregates;
pub mod source; pub mod source;
pub type DbPool = diesel::r2d2::Pool<diesel::r2d2::ConnectionManager<diesel::PgConnection>>; pub type DbPool = diesel::r2d2::Pool<diesel::r2d2::ConnectionManager<diesel::PgConnection>>;
@ -136,6 +137,13 @@ pub trait ToSafe {
fn safe_columns_tuple() -> Self::SafeColumns; fn safe_columns_tuple() -> Self::SafeColumns;
} }
pub trait ViewToVec {
type DbTuple;
fn to_vec(tuple: Vec<Self::DbTuple>) -> Vec<Self>
where
Self: Sized;
}
pub fn get_database_url_from_env() -> Result<String, VarError> { pub fn get_database_url_from_env() -> Result<String, VarError> {
env::var("LEMMY_DATABASE_URL") env::var("LEMMY_DATABASE_URL")
} }

View file

@ -1,7 +1,9 @@
use crate::{schema::comment_report, source::comment::Comment}; use crate::{schema::comment_report, source::comment::Comment};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Identifiable, Queryable, Associations, PartialEq, Serialize, Deserialize, Debug, Clone)] #[derive(
Identifiable, Queryable, Associations, PartialEq, Serialize, Deserialize, Debug, Clone,
)]
#[belongs_to(Comment)] #[belongs_to(Comment)]
#[table_name = "comment_report"] #[table_name = "comment_report"]
pub struct CommentReport { pub struct CommentReport {

View file

@ -1,7 +1,9 @@
use crate::{schema::post_report, source::post::Post}; use crate::{schema::post_report, source::post::Post};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Identifiable, Queryable, Associations, PartialEq, Serialize, Deserialize, Debug, Clone)] #[derive(
Identifiable, Queryable, Associations, PartialEq, Serialize, Deserialize, Debug, Clone,
)]
#[belongs_to(Post)] #[belongs_to(Post)]
#[table_name = "post_report"] #[table_name = "post_report"]
pub struct PostReport { pub struct PostReport {

View file

@ -6,6 +6,5 @@ edition = "2018"
[dependencies] [dependencies]
lemmy_db_queries = { path = "../lemmy_db_queries" } lemmy_db_queries = { path = "../lemmy_db_queries" }
lemmy_db_schema = { path = "../lemmy_db_schema" } lemmy_db_schema = { path = "../lemmy_db_schema" }
lemmy_db_aggregates = { path = "../lemmy_db_aggregates" }
diesel = { version = "1.4.5", features = ["postgres","chrono","r2d2","serde_json"] } diesel = { version = "1.4.5", features = ["postgres","chrono","r2d2","serde_json"] }
serde = { version = "1.0.118", features = ["derive"] } serde = { version = "1.0.118", features = ["derive"] }

View file

@ -1,6 +1,5 @@
use crate::ViewToVec;
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db::{limit_and_offset, MaybeOptional, ToSafe}; use lemmy_db_queries::{limit_and_offset, MaybeOptional, ToSafe, ViewToVec};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{comment, comment_report, community, post, user_, user_alias_1, user_alias_2}, schema::{comment, comment_report, community, post, user_, user_alias_1, user_alias_2},
source::{ source::{

View file

@ -1,6 +1,6 @@
use crate::ViewToVec;
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db::{ use lemmy_db_queries::{
aggregates::comment_aggregates::CommentAggregates,
functions::hot_rank, functions::hot_rank,
fuzzy_search, fuzzy_search,
limit_and_offset, limit_and_offset,
@ -8,8 +8,8 @@ use lemmy_db::{
MaybeOptional, MaybeOptional,
SortType, SortType,
ToSafe, ToSafe,
ViewToVec,
}; };
use lemmy_db_aggregates::comment_aggregates::CommentAggregates;
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{ schema::{
comment, comment,
@ -419,8 +419,14 @@ impl ViewToVec for CommentView {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::comment_view::*; use crate::comment_view::*;
use lemmy_db::{establish_unpooled_connection, Crud, Likeable, ListingType, SortType}; use lemmy_db_queries::{
use lemmy_db_aggregates::comment_aggregates::CommentAggregates; aggregates::comment_aggregates::CommentAggregates,
establish_unpooled_connection,
Crud,
Likeable,
ListingType,
SortType,
};
use lemmy_db_schema::source::{comment::*, community::*, post::*, user::*}; use lemmy_db_schema::source::{comment::*, community::*, post::*, user::*};
#[test] #[test]

View file

@ -1,17 +1,6 @@
pub mod comment_report_view; pub mod comment_report_view;
pub mod comment_view; pub mod comment_view;
pub mod community;
pub mod moderator;
pub mod post_report_view; pub mod post_report_view;
pub mod post_view; pub mod post_view;
pub mod private_message_view; pub mod private_message_view;
pub mod site_view; pub mod site_view;
pub mod user_mention_view;
pub mod user_view;
pub(crate) trait ViewToVec {
type DbTuple;
fn to_vec(tuple: Vec<Self::DbTuple>) -> Vec<Self>
where
Self: Sized;
}

View file

@ -1,6 +1,5 @@
use crate::ViewToVec;
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db::{limit_and_offset, MaybeOptional, ToSafe}; use lemmy_db_queries::{limit_and_offset, MaybeOptional, ToSafe, ViewToVec};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{community, post, post_report, user_, user_alias_1, user_alias_2}, schema::{community, post, post_report, user_, user_alias_1, user_alias_2},
source::{ source::{

View file

@ -1,6 +1,6 @@
use crate::ViewToVec;
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db::{ use lemmy_db_queries::{
aggregates::post_aggregates::PostAggregates,
functions::hot_rank, functions::hot_rank,
fuzzy_search, fuzzy_search,
limit_and_offset, limit_and_offset,
@ -8,8 +8,8 @@ use lemmy_db::{
MaybeOptional, MaybeOptional,
SortType, SortType,
ToSafe, ToSafe,
ViewToVec,
}; };
use lemmy_db_aggregates::post_aggregates::PostAggregates;
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{ schema::{
community, community,
@ -407,8 +407,14 @@ impl ViewToVec for PostView {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::post_view::{PostQueryBuilder, PostView}; use crate::post_view::{PostQueryBuilder, PostView};
use lemmy_db::{establish_unpooled_connection, Crud, Likeable, ListingType, SortType}; use lemmy_db_queries::{
use lemmy_db_aggregates::post_aggregates::PostAggregates; aggregates::post_aggregates::PostAggregates,
establish_unpooled_connection,
Crud,
Likeable,
ListingType,
SortType,
};
use lemmy_db_schema::source::{community::*, post::*, user::*}; use lemmy_db_schema::source::{community::*, post::*, user::*};
#[test] #[test]

View file

@ -1,6 +1,5 @@
use crate::ViewToVec;
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db::{limit_and_offset, MaybeOptional, ToSafe}; use lemmy_db_queries::{limit_and_offset, MaybeOptional, ToSafe, ViewToVec};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{private_message, user_, user_alias_1}, schema::{private_message, user_, user_alias_1},
source::{ source::{

View file

@ -1,6 +1,5 @@
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db::ToSafe; use lemmy_db_queries::{aggregates::site_aggregates::SiteAggregates, ToSafe};
use lemmy_db_aggregates::site_aggregates::SiteAggregates;
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{site, site_aggregates, user_}, schema::{site, site_aggregates, user_},
source::{ source::{

View file

@ -1,11 +1,10 @@
[package] [package]
name = "lemmy_db_aggregates" name = "lemmy_db_views_actor"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
[dependencies] [dependencies]
lemmy_db_schema = { path = "../lemmy_db_schema" }
lemmy_db_queries = { path = "../lemmy_db_queries" } lemmy_db_queries = { path = "../lemmy_db_queries" }
lemmy_db_schema = { path = "../lemmy_db_schema" }
diesel = { version = "1.4.5", features = ["postgres","chrono","r2d2","serde_json"] } diesel = { version = "1.4.5", features = ["postgres","chrono","r2d2","serde_json"] }
serde = { version = "1.0.118", features = ["derive"] } serde = { version = "1.0.118", features = ["derive"] }
chrono = { version = "0.4.19", features = ["serde"] }

View file

@ -1,6 +1,5 @@
use crate::ViewToVec;
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db::ToSafe; use lemmy_db_queries::{ToSafe, ViewToVec};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{community, community_follower, user_}, schema::{community, community_follower, user_},
source::{ source::{

View file

@ -1,6 +1,5 @@
use crate::ViewToVec;
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db::ToSafe; use lemmy_db_queries::{ToSafe, ViewToVec};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{community, community_moderator, user_}, schema::{community, community_moderator, user_},
source::{ source::{

View file

@ -1,5 +1,5 @@
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db::ToSafe; use lemmy_db_queries::ToSafe;
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{community, community_user_ban, user_}, schema::{community, community_user_ban, user_},
source::{ source::{

View file

@ -1,18 +1,15 @@
use crate::{ use crate::{community_moderator_view::CommunityModeratorView, user_view::UserViewSafe};
community::community_moderator_view::CommunityModeratorView,
user_view::UserViewSafe,
ViewToVec,
};
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db::{ use lemmy_db_queries::{
aggregates::community_aggregates::CommunityAggregates,
functions::hot_rank, functions::hot_rank,
fuzzy_search, fuzzy_search,
limit_and_offset, limit_and_offset,
MaybeOptional, MaybeOptional,
SortType, SortType,
ToSafe, ToSafe,
ViewToVec,
}; };
use lemmy_db_aggregates::community_aggregates::CommunityAggregates;
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{category, community, community_aggregates, community_follower, user_}, schema::{category, community, community_aggregates, community_follower, user_},
source::{ source::{

View file

@ -2,3 +2,5 @@ pub mod community_follower_view;
pub mod community_moderator_view; pub mod community_moderator_view;
pub mod community_user_ban_view; pub mod community_user_ban_view;
pub mod community_view; pub mod community_view;
pub mod user_mention_view;
pub mod user_view;

View file

@ -1,7 +1,13 @@
use crate::ViewToVec;
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db::{functions::hot_rank, limit_and_offset, MaybeOptional, SortType, ToSafe}; use lemmy_db_queries::{
use lemmy_db_aggregates::comment_aggregates::CommentAggregates; aggregates::comment_aggregates::CommentAggregates,
functions::hot_rank,
limit_and_offset,
MaybeOptional,
SortType,
ToSafe,
ViewToVec,
};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{ schema::{
comment, comment,

View file

@ -1,7 +1,13 @@
use crate::ViewToVec;
use diesel::{dsl::*, result::Error, *}; use diesel::{dsl::*, result::Error, *};
use lemmy_db::{fuzzy_search, limit_and_offset, MaybeOptional, SortType, ToSafe}; use lemmy_db_queries::{
use lemmy_db_aggregates::user_aggregates::UserAggregates; aggregates::user_aggregates::UserAggregates,
fuzzy_search,
limit_and_offset,
MaybeOptional,
SortType,
ToSafe,
ViewToVec,
};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{user_, user_aggregates}, schema::{user_, user_aggregates},
source::user::{UserSafe, User_}, source::user::{UserSafe, User_},

View file

@ -0,0 +1,10 @@
[package]
name = "lemmy_db_views_moderator"
version = "0.1.0"
edition = "2018"
[dependencies]
lemmy_db_queries = { path = "../lemmy_db_queries" }
lemmy_db_schema = { path = "../lemmy_db_schema" }
diesel = { version = "1.4.5", features = ["postgres","chrono","r2d2","serde_json"] }
serde = { version = "1.0.118", features = ["derive"] }

View file

@ -1,6 +1,5 @@
use crate::ViewToVec;
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db::{limit_and_offset, ToSafe}; use lemmy_db_queries::{limit_and_offset, ToSafe, ViewToVec};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{community, mod_add_community, user_, user_alias_1}, schema::{community, mod_add_community, user_, user_alias_1},
source::{ source::{

View file

@ -1,6 +1,5 @@
use crate::ViewToVec;
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db::{limit_and_offset, ToSafe}; use lemmy_db_queries::{limit_and_offset, ToSafe, ViewToVec};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{mod_add, user_, user_alias_1}, schema::{mod_add, user_, user_alias_1},
source::{ source::{

View file

@ -1,6 +1,5 @@
use crate::ViewToVec;
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db::{limit_and_offset, ToSafe}; use lemmy_db_queries::{limit_and_offset, ToSafe, ViewToVec};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{community, mod_ban_from_community, user_, user_alias_1}, schema::{community, mod_ban_from_community, user_, user_alias_1},
source::{ source::{

View file

@ -1,6 +1,5 @@
use crate::ViewToVec;
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db::{limit_and_offset, ToSafe}; use lemmy_db_queries::{limit_and_offset, ToSafe, ViewToVec};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{mod_ban, user_, user_alias_1}, schema::{mod_ban, user_, user_alias_1},
source::{ source::{

View file

@ -1,6 +1,5 @@
use crate::ViewToVec;
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db::{limit_and_offset, ToSafe}; use lemmy_db_queries::{limit_and_offset, ToSafe, ViewToVec};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{community, mod_lock_post, post, user_}, schema::{community, mod_lock_post, post, user_},
source::{ source::{

View file

@ -1,6 +1,5 @@
use crate::ViewToVec;
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db::{limit_and_offset, ToSafe}; use lemmy_db_queries::{limit_and_offset, ToSafe, ViewToVec};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{comment, community, mod_remove_comment, post, user_, user_alias_1}, schema::{comment, community, mod_remove_comment, post, user_, user_alias_1},
source::{ source::{

View file

@ -1,6 +1,5 @@
use crate::ViewToVec;
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db::{limit_and_offset, ToSafe}; use lemmy_db_queries::{limit_and_offset, ToSafe, ViewToVec};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{community, mod_remove_community, user_}, schema::{community, mod_remove_community, user_},
source::{ source::{

View file

@ -1,6 +1,5 @@
use crate::ViewToVec;
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db::{limit_and_offset, ToSafe}; use lemmy_db_queries::{limit_and_offset, ToSafe, ViewToVec};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{community, mod_remove_post, post, user_}, schema::{community, mod_remove_post, post, user_},
source::{ source::{

View file

@ -1,6 +1,5 @@
use crate::ViewToVec;
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db::{limit_and_offset, ToSafe}; use lemmy_db_queries::{limit_and_offset, ToSafe, ViewToVec};
use lemmy_db_schema::{ use lemmy_db_schema::{
schema::{community, mod_sticky_post, post, user_}, schema::{community, mod_sticky_post, post, user_},
source::{ source::{

View file

@ -1,18 +0,0 @@
[package]
name = "lemmy_rate_limit"
version = "0.1.0"
authors = ["Felix Ableitner <me@nutomic.com>"]
edition = "2018"
[lib]
name = "lemmy_rate_limit"
path = "src/lib.rs"
[dependencies]
lemmy_utils = { path = "../lemmy_utils" }
tokio = { version = "0.3.6", features = ["sync"] }
strum = "0.20.0"
strum_macros = "0.20.1"
futures = "0.3.8"
actix-web = { version = "3.3.2", default-features = false, features = ["rustls"] }
log = "0.4.11"

View file

@ -11,6 +11,8 @@ path = "src/lib.rs"
[dependencies] [dependencies]
lemmy_db_queries = { path = "../lemmy_db_queries" } lemmy_db_queries = { path = "../lemmy_db_queries" }
lemmy_db_views = { path = "../lemmy_db_views" } lemmy_db_views = { path = "../lemmy_db_views" }
lemmy_db_views_moderator = { path = "../lemmy_db_views_moderator" }
lemmy_db_views_actor = { path = "../lemmy_db_views_actor" }
lemmy_db_schema = { path = "../lemmy_db_schema" } lemmy_db_schema = { path = "../lemmy_db_schema" }
lemmy_utils = { path = "../lemmy_utils" } lemmy_utils = { path = "../lemmy_utils" }
serde = { version = "1.0.118", features = ["derive"] } serde = { version = "1.0.118", features = ["derive"] }

View file

@ -1,9 +1,7 @@
use lemmy_db_views::{ use lemmy_db_views_actor::{
community::{ community_follower_view::CommunityFollowerView,
community_follower_view::CommunityFollowerView, community_moderator_view::CommunityModeratorView,
community_moderator_view::CommunityModeratorView, community_view::CommunityView,
community_view::CommunityView,
},
user_view::UserViewSafe, user_view::UserViewSafe,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View file

@ -5,7 +5,7 @@ pub mod site;
pub mod user; pub mod user;
use diesel::PgConnection; use diesel::PgConnection;
use lemmy_db::{source::user::User, Crud, DbPool}; use lemmy_db_queries::{source::user::User, Crud, DbPool};
use lemmy_db_schema::source::{ use lemmy_db_schema::source::{
comment::Comment, comment::Comment,
post::Post, post::Post,

View file

@ -1,9 +1,9 @@
use lemmy_db_views::{ use lemmy_db_views::{
comment_view::CommentView, comment_view::CommentView,
community::community_moderator_view::CommunityModeratorView,
post_report_view::PostReportView, post_report_view::PostReportView,
post_view::PostView, post_view::PostView,
}; };
use lemmy_db_views_actor::community_moderator_view::CommunityModeratorView;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]

View file

@ -1,21 +1,16 @@
use lemmy_db_schema::source::{category::*, user::User_}; use lemmy_db_schema::source::{category::*, user::User_};
use lemmy_db_views::{ use lemmy_db_views::{comment_view::CommentView, post_view::PostView, site_view::SiteView};
comment_view::CommentView, use lemmy_db_views_actor::{community_view::CommunityView, user_view::UserViewSafe};
community::community_view::CommunityView, use lemmy_db_views_moderator::{
moderator::{ mod_add_community_view::ModAddCommunityView,
mod_add_community_view::ModAddCommunityView, mod_add_view::ModAddView,
mod_add_view::ModAddView, mod_ban_from_community_view::ModBanFromCommunityView,
mod_ban_from_community_view::ModBanFromCommunityView, mod_ban_view::ModBanView,
mod_ban_view::ModBanView, mod_lock_post_view::ModLockPostView,
mod_lock_post_view::ModLockPostView, mod_remove_comment_view::ModRemoveCommentView,
mod_remove_comment_view::ModRemoveCommentView, mod_remove_community_view::ModRemoveCommunityView,
mod_remove_community_view::ModRemoveCommunityView, mod_remove_post_view::ModRemovePostView,
mod_remove_post_view::ModRemovePostView, mod_sticky_post_view::ModStickyPostView,
mod_sticky_post_view::ModStickyPostView,
},
post_view::PostView,
site_view::SiteView,
user_view::UserViewSafe,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View file

@ -1,11 +1,11 @@
use lemmy_db_views::{ use lemmy_db_views::{
comment_view::CommentView, comment_view::CommentView,
community::{
community_follower_view::CommunityFollowerView,
community_moderator_view::CommunityModeratorView,
},
post_view::PostView, post_view::PostView,
private_message_view::PrivateMessageView, private_message_view::PrivateMessageView,
};
use lemmy_db_views_actor::{
community_follower_view::CommunityFollowerView,
community_moderator_view::CommunityModeratorView,
user_mention_view::UserMentionView, user_mention_view::UserMentionView,
user_view::{UserViewDangerous, UserViewSafe}, user_view::{UserViewDangerous, UserViewSafe},
}; };

View file

@ -27,3 +27,7 @@ actix-web = { version = "3.3.2", default-features = false, features = ["rustls"]
actix-rt = { version = "1.1.1", default-features = false } actix-rt = { version = "1.1.1", default-features = false }
anyhow = "1.0.36" anyhow = "1.0.36"
reqwest = { version = "0.10.10", features = ["json"] } reqwest = { version = "0.10.10", features = ["json"] }
tokio = { version = "0.3.6", features = ["sync"] }
strum = "0.20.0"
strum_macros = "0.20.1"
futures = "0.3.8"

View file

@ -1,8 +1,11 @@
#[macro_use] #[macro_use]
extern crate lazy_static; extern crate lazy_static;
#[macro_use]
extern crate strum_macros;
pub mod apub; pub mod apub;
pub mod email; pub mod email;
pub mod rate_limit;
pub mod request; pub mod request;
pub mod settings; pub mod settings;
#[cfg(test)] #[cfg(test)]

View file

@ -1,13 +1,10 @@
#[macro_use] use crate::{
extern crate strum_macros;
use actix_web::dev::{Service, ServiceRequest, ServiceResponse, Transform};
use futures::future::{ok, Ready};
use lemmy_utils::{
settings::{RateLimitConfig, Settings}, settings::{RateLimitConfig, Settings},
utils::get_ip, utils::get_ip,
LemmyError, LemmyError,
}; };
use actix_web::dev::{Service, ServiceRequest, ServiceResponse, Transform};
use futures::future::{ok, Ready};
use rate_limiter::{RateLimitType, RateLimiter}; use rate_limiter::{RateLimitType, RateLimiter};
use std::{ use std::{
future::Future, future::Future,

View file

@ -1,4 +1,4 @@
use lemmy_utils::{APIError, IPAddr, LemmyError}; use crate::{APIError, IPAddr, LemmyError};
use log::debug; use log::debug;
use std::{collections::HashMap, time::SystemTime}; use std::{collections::HashMap, time::SystemTime};
use strum::IntoEnumIterator; use strum::IntoEnumIterator;

View file

@ -13,7 +13,6 @@ lemmy_utils = { path = "../lemmy_utils" }
lemmy_structs = { path = "../lemmy_structs" } lemmy_structs = { path = "../lemmy_structs" }
lemmy_db_queries = { path = "../lemmy_db_queries" } lemmy_db_queries = { path = "../lemmy_db_queries" }
lemmy_db_schema = { path = "../lemmy_db_schema" } lemmy_db_schema = { path = "../lemmy_db_schema" }
lemmy_rate_limit = { path = "../lemmy_rate_limit" }
reqwest = { version = "0.10.10", features = ["json"] } reqwest = { version = "0.10.10", features = ["json"] }
log = "0.4.11" log = "0.4.11"
rand = "0.8.0" rand = "0.8.0"

View file

@ -6,10 +6,10 @@ use diesel::{
r2d2::{ConnectionManager, Pool}, r2d2::{ConnectionManager, Pool},
PgConnection, PgConnection,
}; };
use lemmy_rate_limit::RateLimit;
use lemmy_structs::{comment::*, post::*}; use lemmy_structs::{comment::*, post::*};
use lemmy_utils::{ use lemmy_utils::{
location_info, location_info,
rate_limit::RateLimit,
APIError, APIError,
CommunityId, CommunityId,
ConnectionId, ConnectionId,

View file

@ -4,7 +4,7 @@ extern crate strum_macros;
use crate::chat_server::ChatServer; use crate::chat_server::ChatServer;
use actix::Addr; use actix::Addr;
use background_jobs::QueueHandle; use background_jobs::QueueHandle;
use lemmy_db::DbPool; use lemmy_db_queries::DbPool;
use lemmy_utils::LemmyError; use lemmy_utils::LemmyError;
use reqwest::Client; use reqwest::Client;
use serde::Serialize; use serde::Serialize;

View file

@ -3,7 +3,7 @@ use diesel::{
sql_types::{Nullable, Text}, sql_types::{Nullable, Text},
*, *,
}; };
use lemmy_db::{ use lemmy_db_queries::{
source::{comment::Comment_, post::Post_, private_message::PrivateMessage_}, source::{comment::Comment_, post::Post_, private_message::PrivateMessage_},
Crud, Crud,
}; };

View file

@ -9,11 +9,14 @@ use diesel::{
}; };
use lemmy_api::match_websocket_operation; use lemmy_api::match_websocket_operation;
use lemmy_apub::activity_queue::create_activity_queue; use lemmy_apub::activity_queue::create_activity_queue;
use lemmy_db::get_database_url_from_env; use lemmy_db_queries::get_database_url_from_env;
use lemmy_rate_limit::{rate_limiter::RateLimiter, RateLimit};
use lemmy_server::{code_migrations::run_advanced_migrations, routes::*}; use lemmy_server::{code_migrations::run_advanced_migrations, routes::*};
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::{settings::Settings, LemmyError}; use lemmy_utils::{
rate_limit::{rate_limiter::RateLimiter, RateLimit},
settings::Settings,
LemmyError,
};
use lemmy_websocket::{chat_server::ChatServer, LemmyContext}; use lemmy_websocket::{chat_server::ChatServer, LemmyContext};
use reqwest::Client; use reqwest::Client;
use std::sync::Arc; use std::sync::Arc;

View file

@ -1,7 +1,7 @@
use actix_web::{error::ErrorBadRequest, *}; use actix_web::{error::ErrorBadRequest, *};
use lemmy_api::Perform; use lemmy_api::Perform;
use lemmy_rate_limit::RateLimit;
use lemmy_structs::{comment::*, community::*, post::*, site::*, user::*}; use lemmy_structs::{comment::*, community::*, post::*, site::*, user::*};
use lemmy_utils::rate_limit::RateLimit;
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
use serde::Deserialize; use serde::Deserialize;

View file

@ -3,7 +3,7 @@ use anyhow::anyhow;
use chrono::{DateTime, NaiveDateTime, Utc}; use chrono::{DateTime, NaiveDateTime, Utc};
use diesel::PgConnection; use diesel::PgConnection;
use lemmy_api::claims::Claims; use lemmy_api::claims::Claims;
use lemmy_db::{ use lemmy_db_queries::{
source::{community::Community_, user::User}, source::{community::Community_, user::User},
ListingType, ListingType,
SortType, SortType,
@ -13,8 +13,8 @@ use lemmy_db_views::{
comment_view::{CommentQueryBuilder, CommentView}, comment_view::{CommentQueryBuilder, CommentView},
post_view::{PostQueryBuilder, PostView}, post_view::{PostQueryBuilder, PostView},
site_view::SiteView, site_view::SiteView,
user_mention_view::{UserMentionQueryBuilder, UserMentionView},
}; };
use lemmy_db_views_actor::user_mention_view::{UserMentionQueryBuilder, UserMentionView};
use lemmy_structs::blocking; use lemmy_structs::blocking;
use lemmy_utils::{settings::Settings, utils::markdown_to_html, LemmyError}; use lemmy_utils::{settings::Settings, utils::markdown_to_html, LemmyError};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;

View file

@ -2,8 +2,7 @@ use actix::clock::Duration;
use actix_web::{body::BodyStream, http::StatusCode, *}; use actix_web::{body::BodyStream, http::StatusCode, *};
use awc::Client; use awc::Client;
use lemmy_api::claims::Claims; use lemmy_api::claims::Claims;
use lemmy_rate_limit::RateLimit; use lemmy_utils::{rate_limit::RateLimit, settings::Settings};
use lemmy_utils::settings::Settings;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) { pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {

View file

@ -1,6 +1,6 @@
use actix_web::{error::ErrorBadRequest, web::Query, *}; use actix_web::{error::ErrorBadRequest, web::Query, *};
use anyhow::anyhow; use anyhow::anyhow;
use lemmy_db::source::{community::Community_, user::User}; use lemmy_db_queries::source::{community::Community_, user::User};
use lemmy_db_schema::source::{community::Community, user::User_}; use lemmy_db_schema::source::{community::Community, user::User_};
use lemmy_structs::{blocking, WebFingerLink, WebFingerResponse}; use lemmy_structs::{blocking, WebFingerLink, WebFingerResponse};
use lemmy_utils::{ use lemmy_utils::{

View file

@ -28,13 +28,16 @@ use lemmy_apub::{
user_inbox::user_inbox, user_inbox::user_inbox,
}, },
}; };
use lemmy_db::{Crud, ListingType, SortType}; use lemmy_db_queries::{Crud, ListingType, SortType};
use lemmy_db_schema::source::{ use lemmy_db_schema::source::{
community::{Community, CommunityForm}, community::{Community, CommunityForm},
user::{UserForm, User_}, user::{UserForm, User_},
}; };
use lemmy_rate_limit::{rate_limiter::RateLimiter, RateLimit}; use lemmy_utils::{
use lemmy_utils::{apub::generate_actor_keypair, settings::Settings}; apub::generate_actor_keypair,
rate_limit::{rate_limiter::RateLimiter, RateLimit},
settings::Settings,
};
use lemmy_websocket::{chat_server::ChatServer, LemmyContext}; use lemmy_websocket::{chat_server::ChatServer, LemmyContext};
use reqwest::Client; use reqwest::Client;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};