"lemmy_db_queries",
"lemmy_db_schema",
"lemmy_db_views",
- "lemmy_rate_limit",
+ "lemmy_db_views_actor",
+ "lemmy_db_views_moderator",
"lemmy_structs",
"lemmy_utils",
"lemmy_websocket",
"lemmy_db_queries",
"lemmy_db_schema",
"lemmy_db_views",
+ "lemmy_db_views_actor",
"lemmy_structs",
"lemmy_utils",
"lemmy_websocket",
"uuid",
]
-[[package]]
-name = "lemmy_db_aggregates"
-version = "0.1.0"
-dependencies = [
- "chrono",
- "diesel",
- "lemmy_db_queries",
- "lemmy_db_schema",
- "serde 1.0.118",
-]
-
[[package]]
name = "lemmy_db_queries"
version = "0.1.0"
version = "0.1.0"
dependencies = [
"diesel",
- "lemmy_db_aggregates",
"lemmy_db_queries",
"lemmy_db_schema",
"serde 1.0.118",
]
[[package]]
-name = "lemmy_rate_limit"
+name = "lemmy_db_views_actor"
version = "0.1.0"
dependencies = [
- "actix-web",
- "futures",
- "lemmy_utils",
- "log",
- "strum",
- "strum_macros",
- "tokio 0.3.6",
+ "diesel",
+ "lemmy_db_queries",
+ "lemmy_db_schema",
+ "serde 1.0.118",
+]
+
+[[package]]
+name = "lemmy_db_views_moderator"
+version = "0.1.0"
+dependencies = [
+ "diesel",
+ "lemmy_db_queries",
+ "lemmy_db_schema",
+ "serde 1.0.118",
]
[[package]]
"lazy_static",
"lemmy_api",
"lemmy_apub",
- "lemmy_db_aggregates",
"lemmy_db_queries",
"lemmy_db_schema",
"lemmy_db_views",
- "lemmy_rate_limit",
+ "lemmy_db_views_actor",
+ "lemmy_db_views_moderator",
"lemmy_structs",
"lemmy_utils",
"lemmy_websocket",
"lemmy_db_queries",
"lemmy_db_schema",
"lemmy_db_views",
+ "lemmy_db_views_actor",
+ "lemmy_db_views_moderator",
"lemmy_utils",
"log",
"serde 1.0.118",
"chrono",
"comrak",
"config",
+ "futures",
"itertools",
"lazy_static",
"lettre",
"reqwest",
"serde 1.0.118",
"serde_json",
+ "strum",
+ "strum_macros",
"thiserror",
+ "tokio 0.3.6",
"url",
]
"diesel",
"lemmy_db_queries",
"lemmy_db_schema",
- "lemmy_rate_limit",
"lemmy_structs",
"lemmy_utils",
"log",
"lemmy_utils",
"lemmy_db_queries",
"lemmy_db_schema",
+ "lemmy_db_views",
+ "lemmy_db_views_actor",
+ "lemmy_db_views_actor",
"lemmy_structs",
- "lemmy_rate_limit",
"lemmy_websocket",
]
lemmy_db_schema = { path = "./lemmy_db_schema" }
lemmy_db_queries = { path = "lemmy_db_queries" }
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_rate_limit = { path = "./lemmy_rate_limit" }
lemmy_websocket = { path = "./lemmy_websocket" }
diesel = "1.4.5"
diesel_migrations = "1.4.0"
lemmy_db_queries = { path = "../lemmy_db_queries" }
lemmy_db_schema = { path = "../lemmy_db_schema" }
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_rate_limit = { path = "../lemmy_rate_limit" }
lemmy_websocket = { path = "../lemmy_websocket" }
diesel = "1.4.5"
bcrypt = "0.9.0"
};
use actix_web::web::Data;
use lemmy_apub::{ApubLikeableType, ApubObjectType};
-use lemmy_db::{
+use lemmy_db_queries::{
source::comment::Comment_,
Crud,
Likeable,
use actix_web::web::Data;
use anyhow::Context;
use lemmy_apub::ActorType;
-use lemmy_db::{
+use lemmy_db_queries::{
diesel_option_overwrite,
source::{
comment::Comment_,
naive_now,
source::{comment::Comment, community::*, moderator::*, post::Post, site::*},
};
-use lemmy_db_views::{
- comment_view::CommentQueryBuilder,
- community::{
- community_follower_view::CommunityFollowerView,
- community_moderator_view::CommunityModeratorView,
- community_view::{CommunityQueryBuilder, CommunityView},
- },
+use lemmy_db_views::comment_view::CommentQueryBuilder;
+use lemmy_db_views_actor::{
+ community_follower_view::CommunityFollowerView,
+ community_moderator_view::CommunityModeratorView,
+ community_view::{CommunityQueryBuilder, CommunityView},
user_view::UserViewSafe,
};
use lemmy_structs::{blocking, community::*};
use crate::claims::Claims;
use actix_web::{web, web::Data};
-use lemmy_db::{
+use lemmy_db_queries::{
source::{
community::{CommunityModerator_, Community_},
site::Site_,
site::Site,
user::User_,
};
-use lemmy_db_views::community::{
+use lemmy_db_views_actor::{
community_user_ban_view::CommunityUserBanView,
community_view::CommunityView,
};
};
use actix_web::web::Data;
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::{
naive_now,
source::{
};
use lemmy_db_views::{
comment_view::CommentQueryBuilder,
- community::community_moderator_view::CommunityModeratorView,
post_report_view::{PostReportQueryBuilder, PostReportView},
post_view::{PostQueryBuilder, PostView},
};
+use lemmy_db_views_actor::community_moderator_view::CommunityModeratorView;
use lemmy_structs::{blocking, post::*};
use lemmy_utils::{
apub::{make_apub_endpoint, EndpointType},
use actix_web::web::Data;
use anyhow::Context;
use lemmy_apub::fetcher::search_by_apub_id;
-use lemmy_db::{
+use lemmy_db_queries::{
diesel_option_overwrite,
source::{category::Category_, site::Site_},
Crud,
};
use lemmy_db_views::{
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,
site_view::SiteView,
+};
+use lemmy_db_views_actor::{
+ community_view::CommunityQueryBuilder,
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_utils::{
location_info,
use captcha::{gen, Difficulty};
use chrono::Duration;
use lemmy_apub::ApubObjectType;
-use lemmy_db::{
+use lemmy_db_queries::{
diesel_option_overwrite,
source::{
comment::Comment_,
use lemmy_db_views::{
comment_report_view::CommentReportView,
comment_view::CommentQueryBuilder,
- community::{
- community_follower_view::CommunityFollowerView,
- community_moderator_view::CommunityModeratorView,
- },
post_report_view::PostReportView,
post_view::PostQueryBuilder,
private_message_view::{PrivateMessageQueryBuilder, PrivateMessageView},
+};
+use lemmy_db_views_actor::{
+ community_follower_view::CommunityFollowerView,
+ community_moderator_view::CommunityModeratorView,
user_mention_view::{UserMentionQueryBuilder, UserMentionView},
user_view::{UserViewDangerous, UserViewSafe},
};
lemmy_db_queries = { path = "../lemmy_db_queries" }
lemmy_db_schema = { path = "../lemmy_db_schema" }
lemmy_db_views = { path = "../lemmy_db_views" }
+lemmy_db_views_actor = { path = "../lemmy_db_views_actor" }
lemmy_structs = { path = "../lemmy_structs" }
lemmy_websocket = { path = "../lemmy_websocket" }
diesel = "1.4.5"
base::ExtendsExt,
};
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::{
comment::{Comment, CommentLike, CommentLikeForm},
post::Post,
use crate::activities::receive::get_actor_as_user;
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_views::comment_view::CommentView;
use lemmy_structs::{blocking, comment::CommentResponse};
base::{AnyBase, ExtendsExt},
};
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_views::community::community_view::CommunityView;
+use lemmy_db_views_actor::community_view::CommunityView;
use lemmy_structs::{blocking, community::CommunityResponse};
use lemmy_utils::{location_info, LemmyError};
use lemmy_websocket::{messages::SendCommunityRoomMessage, LemmyContext, UserOperation};
prelude::*,
};
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_views::post_view::PostView;
use lemmy_structs::{blocking, post::PostResponse};
use crate::activities::receive::get_actor_as_user;
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_views::post_view::PostView;
use lemmy_structs::{blocking, post::PostResponse};
public,
};
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_views::private_message_view::PrivateMessageView;
use lemmy_structs::{blocking, user::PrivateMessageResponse};
};
use anyhow::anyhow;
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_structs::{blocking, WebFingerResponse};
use lemmy_utils::{
};
use anyhow::Context;
use itertools::Itertools;
-use lemmy_db::DbPool;
+use lemmy_db_queries::DbPool;
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_utils::{location_info, settings::Settings, LemmyError};
use lemmy_websocket::LemmyContext;
prelude::*,
public,
};
-use lemmy_db::Crud;
+use lemmy_db_queries::Crud;
use lemmy_db_schema::source::{community::Community, post::Post, user::User_};
use lemmy_structs::blocking;
use lemmy_utils::LemmyError;
},
prelude::*,
};
-use lemmy_db::Crud;
+use lemmy_db_queries::Crud;
use lemmy_db_schema::source::{private_message::PrivateMessage, user::User_};
use lemmy_structs::blocking;
use lemmy_utils::LemmyError;
base::{AnyBase, BaseExt, ExtendsExt},
object::ObjectExt,
};
-use lemmy_db::{ApubObject, DbPool, Followable};
+use lemmy_db_queries::{ApubObject, DbPool, Followable};
use lemmy_db_schema::source::{
community::{Community, CommunityFollower, CommunityFollowerForm},
user::User_,
WorkerConfig,
};
use itertools::Itertools;
-use lemmy_db::DbPool;
+use lemmy_db_queries::DbPool;
use lemmy_db_schema::source::{community::Community, user::User_};
use lemmy_utils::{location_info, settings::Settings, LemmyError};
use lemmy_websocket::LemmyContext;
use activitystreams::unparsed::UnparsedMutExt;
use activitystreams_ext::UnparsedExtension;
use diesel::PgConnection;
-use lemmy_db::Crud;
+use lemmy_db_queries::Crud;
use lemmy_db_schema::source::category::Category;
use lemmy_utils::LemmyError;
use serde::{Deserialize, Serialize};
use anyhow::{anyhow, Context};
use chrono::NaiveDateTime;
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::{
naive_now,
source::{
user::User_,
},
};
-use lemmy_db_views::{
- comment_view::CommentView,
- community::community_view::CommunityView,
- post_view::PostView,
- user_view::UserViewSafe,
-};
+use lemmy_db_views::{comment_view::CommentView, post_view::PostView};
+use lemmy_db_views_actor::{community_view::CommunityView, user_view::UserViewSafe};
use lemmy_structs::{blocking, site::SearchResponse};
use lemmy_utils::{
location_info,
};
use actix_web::{body::Body, web, web::Path, HttpResponse};
use diesel::result::Error::NotFound;
-use lemmy_db::Crud;
+use lemmy_db_queries::Crud;
use lemmy_db_schema::source::comment::Comment;
use lemmy_structs::blocking;
use lemmy_utils::LemmyError;
collection::{CollectionExt, OrderedCollection, UnorderedCollection},
};
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_views::community::community_follower_view::CommunityFollowerView;
+use lemmy_db_views_actor::community_follower_view::CommunityFollowerView;
use lemmy_structs::blocking;
use lemmy_utils::LemmyError;
use lemmy_websocket::LemmyContext;
use crate::APUB_JSON_CONTENT_TYPE;
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_structs::blocking;
use lemmy_utils::{settings::Settings, LemmyError};
};
use actix_web::{body::Body, web, HttpResponse};
use diesel::result::Error::NotFound;
-use lemmy_db::Crud;
+use lemmy_db_queries::Crud;
use lemmy_db_schema::source::post::Post;
use lemmy_structs::blocking;
use lemmy_utils::LemmyError;
collection::{CollectionExt, OrderedCollection},
};
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_structs::blocking;
use lemmy_utils::LemmyError;
};
use actix_web::{web, HttpRequest, HttpResponse};
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::{
community::{Community, CommunityFollower, CommunityFollowerForm},
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_utils::{location_info, LemmyError};
use lemmy_websocket::LemmyContext;
};
use actix_web::HttpRequest;
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_structs::blocking;
use lemmy_utils::{location_info, settings::Settings, LemmyError};
};
use anyhow::Context;
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_structs::blocking;
use lemmy_utils::{location_info, LemmyError};
use activitystreams::{activity::ActorAndObject, prelude::*};
use actix_web::{web, HttpRequest, HttpResponse};
use anyhow::Context;
-use lemmy_db::{ApubObject, DbPool};
+use lemmy_db_queries::{ApubObject, DbPool};
use lemmy_db_schema::source::community::Community;
use lemmy_structs::blocking;
use lemmy_utils::{location_info, LemmyError};
use actix_web::{web, HttpRequest, HttpResponse};
use anyhow::{anyhow, Context};
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::{
community::{Community, CommunityFollower},
private_message::PrivateMessage,
};
use activitystreams_ext::{Ext1, Ext2};
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_structs::blocking;
use lemmy_utils::{location_info, settings::Settings, LemmyError};
prelude::*,
};
use anyhow::{anyhow, Context};
-use lemmy_db::{Crud, DbPool};
+use lemmy_db_queries::{Crud, DbPool};
use lemmy_db_schema::source::{
comment::{Comment, CommentForm},
community::Community,
};
use activitystreams_ext::Ext2;
use anyhow::Context;
-use lemmy_db::DbPool;
+use lemmy_db_queries::DbPool;
use lemmy_db_schema::{
naive_now,
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_utils::{
location_info,
};
use anyhow::{anyhow, Context};
use chrono::NaiveDateTime;
-use lemmy_db::{ApubObject, Crud, DbPool};
+use lemmy_db_queries::{ApubObject, Crud, DbPool};
use lemmy_structs::blocking;
use lemmy_utils::{location_info, settings::Settings, utils::convert_datetime, LemmyError};
use lemmy_websocket::LemmyContext;
};
use activitystreams_ext::Ext1;
use anyhow::Context;
-use lemmy_db::{Crud, DbPool};
+use lemmy_db_queries::{Crud, DbPool};
use lemmy_db_schema::source::{
community::Community,
post::{Post, PostForm},
prelude::*,
};
use anyhow::Context;
-use lemmy_db::{Crud, DbPool};
+use lemmy_db_queries::{Crud, DbPool};
use lemmy_db_schema::source::{
private_message::{PrivateMessage, PrivateMessageForm},
user::User_,
};
use activitystreams_ext::Ext1;
use anyhow::Context;
-use lemmy_db::{ApubObject, DbPool};
+use lemmy_db_queries::{ApubObject, DbPool};
use lemmy_db_schema::{
naive_now,
source::user::{UserForm, User_},
edition = "2018"
[lib]
-name = "lemmy_db"
+name = "lemmy_db_queries"
path = "src/lib.rs"
[dependencies]
#[cfg(test)]
mod tests {
- use crate::comment_aggregates::CommentAggregates;
- use lemmy_db::{establish_unpooled_connection, Crud, Likeable, ListingType, SortType};
+ use crate::{
+ aggregates::comment_aggregates::CommentAggregates,
+ establish_unpooled_connection,
+ Crud,
+ Likeable,
+ ListingType,
+ SortType,
+ };
use lemmy_db_schema::source::{
comment::{Comment, CommentForm, CommentLike, CommentLikeForm},
community::{Community, CommunityForm},
#[cfg(test)]
mod tests {
- use crate::community_aggregates::CommunityAggregates;
- use lemmy_db::{establish_unpooled_connection, Crud, Followable, ListingType, SortType};
+ use crate::{
+ aggregates::community_aggregates::CommunityAggregates,
+ establish_unpooled_connection,
+ Crud,
+ Followable,
+ ListingType,
+ SortType,
+ };
use lemmy_db_schema::source::{
comment::{Comment, CommentForm},
community::{Community, CommunityFollower, CommunityFollowerForm, CommunityForm},
#[cfg(test)]
mod tests {
- use crate::post_aggregates::PostAggregates;
- use lemmy_db::{establish_unpooled_connection, Crud, Likeable, ListingType, SortType};
+ use crate::{
+ aggregates::post_aggregates::PostAggregates,
+ establish_unpooled_connection,
+ Crud,
+ Likeable,
+ ListingType,
+ SortType,
+ };
use lemmy_db_schema::source::{
comment::{Comment, CommentForm},
community::{Community, CommunityForm},
#[cfg(test)]
mod tests {
- use crate::site_aggregates::SiteAggregates;
- use lemmy_db::{establish_unpooled_connection, Crud, ListingType, SortType};
+ use crate::{
+ aggregates::site_aggregates::SiteAggregates,
+ establish_unpooled_connection,
+ Crud,
+ ListingType,
+ SortType,
+ };
use lemmy_db_schema::source::{
comment::{Comment, CommentForm},
community::{Community, CommunityForm},
#[cfg(test)]
mod tests {
- use crate::user_aggregates::UserAggregates;
- use lemmy_db::{establish_unpooled_connection, Crud, Likeable, ListingType, SortType};
+ use crate::{
+ aggregates::user_aggregates::UserAggregates,
+ establish_unpooled_connection,
+ Crud,
+ Likeable,
+ ListingType,
+ SortType,
+ };
use lemmy_db_schema::source::{
comment::{Comment, CommentForm, CommentLike, CommentLikeForm},
community::{Community, CommunityForm},
use serde::{Deserialize, Serialize};
use std::{env, env::VarError};
+pub mod aggregates;
pub mod source;
pub type DbPool = diesel::r2d2::Pool<diesel::r2d2::ConnectionManager<diesel::PgConnection>>;
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> {
env::var("LEMMY_DATABASE_URL")
}
use crate::{schema::comment_report, source::comment::Comment};
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)]
#[table_name = "comment_report"]
pub struct CommentReport {
use crate::{schema::post_report, source::post::Post};
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)]
#[table_name = "post_report"]
pub struct PostReport {
[dependencies]
lemmy_db_queries = { path = "../lemmy_db_queries" }
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"] }
serde = { version = "1.0.118", features = ["derive"] }
\ No newline at end of file
-use crate::ViewToVec;
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::{
schema::{comment, comment_report, community, post, user_, user_alias_1, user_alias_2},
source::{
-use crate::ViewToVec;
use diesel::{result::Error, *};
-use lemmy_db::{
+use lemmy_db_queries::{
+ aggregates::comment_aggregates::CommentAggregates,
functions::hot_rank,
fuzzy_search,
limit_and_offset,
MaybeOptional,
SortType,
ToSafe,
+ ViewToVec,
};
-use lemmy_db_aggregates::comment_aggregates::CommentAggregates;
use lemmy_db_schema::{
schema::{
comment,
#[cfg(test)]
mod tests {
use crate::comment_view::*;
- use lemmy_db::{establish_unpooled_connection, Crud, Likeable, ListingType, SortType};
- use lemmy_db_aggregates::comment_aggregates::CommentAggregates;
+ use lemmy_db_queries::{
+ aggregates::comment_aggregates::CommentAggregates,
+ establish_unpooled_connection,
+ Crud,
+ Likeable,
+ ListingType,
+ SortType,
+ };
use lemmy_db_schema::source::{comment::*, community::*, post::*, user::*};
#[test]
pub mod comment_report_view;
pub mod comment_view;
-pub mod community;
-pub mod moderator;
pub mod post_report_view;
pub mod post_view;
pub mod private_message_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;
-}
-use crate::ViewToVec;
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::{
schema::{community, post, post_report, user_, user_alias_1, user_alias_2},
source::{
-use crate::ViewToVec;
use diesel::{result::Error, *};
-use lemmy_db::{
+use lemmy_db_queries::{
+ aggregates::post_aggregates::PostAggregates,
functions::hot_rank,
fuzzy_search,
limit_and_offset,
MaybeOptional,
SortType,
ToSafe,
+ ViewToVec,
};
-use lemmy_db_aggregates::post_aggregates::PostAggregates;
use lemmy_db_schema::{
schema::{
community,
#[cfg(test)]
mod tests {
use crate::post_view::{PostQueryBuilder, PostView};
- use lemmy_db::{establish_unpooled_connection, Crud, Likeable, ListingType, SortType};
- use lemmy_db_aggregates::post_aggregates::PostAggregates;
+ use lemmy_db_queries::{
+ aggregates::post_aggregates::PostAggregates,
+ establish_unpooled_connection,
+ Crud,
+ Likeable,
+ ListingType,
+ SortType,
+ };
use lemmy_db_schema::source::{community::*, post::*, user::*};
#[test]
-use crate::ViewToVec;
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::{
schema::{private_message, user_, user_alias_1},
source::{
use diesel::{result::Error, *};
-use lemmy_db::ToSafe;
-use lemmy_db_aggregates::site_aggregates::SiteAggregates;
+use lemmy_db_queries::{aggregates::site_aggregates::SiteAggregates, ToSafe};
use lemmy_db_schema::{
schema::{site, site_aggregates, user_},
source::{
[package]
-name = "lemmy_db_aggregates"
+name = "lemmy_db_views_actor"
version = "0.1.0"
edition = "2018"
[dependencies]
-lemmy_db_schema = { path = "../lemmy_db_schema" }
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"] }
-chrono = { version = "0.4.19", features = ["serde"] }
-use crate::ViewToVec;
use diesel::{result::Error, *};
-use lemmy_db::ToSafe;
+use lemmy_db_queries::{ToSafe, ViewToVec};
use lemmy_db_schema::{
schema::{community, community_follower, user_},
source::{
-use crate::ViewToVec;
use diesel::{result::Error, *};
-use lemmy_db::ToSafe;
+use lemmy_db_queries::{ToSafe, ViewToVec};
use lemmy_db_schema::{
schema::{community, community_moderator, user_},
source::{
use diesel::{result::Error, *};
-use lemmy_db::ToSafe;
+use lemmy_db_queries::ToSafe;
use lemmy_db_schema::{
schema::{community, community_user_ban, user_},
source::{
-use crate::{
- community::community_moderator_view::CommunityModeratorView,
- user_view::UserViewSafe,
- ViewToVec,
-};
+use crate::{community_moderator_view::CommunityModeratorView, user_view::UserViewSafe};
use diesel::{result::Error, *};
-use lemmy_db::{
+use lemmy_db_queries::{
+ aggregates::community_aggregates::CommunityAggregates,
functions::hot_rank,
fuzzy_search,
limit_and_offset,
MaybeOptional,
SortType,
ToSafe,
+ ViewToVec,
};
-use lemmy_db_aggregates::community_aggregates::CommunityAggregates;
use lemmy_db_schema::{
schema::{category, community, community_aggregates, community_follower, user_},
source::{
pub mod community_moderator_view;
pub mod community_user_ban_view;
pub mod community_view;
+pub mod user_mention_view;
+pub mod user_view;
-use crate::ViewToVec;
use diesel::{result::Error, *};
-use lemmy_db::{functions::hot_rank, limit_and_offset, MaybeOptional, SortType, ToSafe};
-use lemmy_db_aggregates::comment_aggregates::CommentAggregates;
+use lemmy_db_queries::{
+ aggregates::comment_aggregates::CommentAggregates,
+ functions::hot_rank,
+ limit_and_offset,
+ MaybeOptional,
+ SortType,
+ ToSafe,
+ ViewToVec,
+};
use lemmy_db_schema::{
schema::{
comment,
-use crate::ViewToVec;
use diesel::{dsl::*, result::Error, *};
-use lemmy_db::{fuzzy_search, limit_and_offset, MaybeOptional, SortType, ToSafe};
-use lemmy_db_aggregates::user_aggregates::UserAggregates;
+use lemmy_db_queries::{
+ aggregates::user_aggregates::UserAggregates,
+ fuzzy_search,
+ limit_and_offset,
+ MaybeOptional,
+ SortType,
+ ToSafe,
+ ViewToVec,
+};
use lemmy_db_schema::{
schema::{user_, user_aggregates},
source::user::{UserSafe, User_},
--- /dev/null
+[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"] }
-use crate::ViewToVec;
use diesel::{result::Error, *};
-use lemmy_db::{limit_and_offset, ToSafe};
+use lemmy_db_queries::{limit_and_offset, ToSafe, ViewToVec};
use lemmy_db_schema::{
schema::{community, mod_add_community, user_, user_alias_1},
source::{
-use crate::ViewToVec;
use diesel::{result::Error, *};
-use lemmy_db::{limit_and_offset, ToSafe};
+use lemmy_db_queries::{limit_and_offset, ToSafe, ViewToVec};
use lemmy_db_schema::{
schema::{mod_add, user_, user_alias_1},
source::{
-use crate::ViewToVec;
use diesel::{result::Error, *};
-use lemmy_db::{limit_and_offset, ToSafe};
+use lemmy_db_queries::{limit_and_offset, ToSafe, ViewToVec};
use lemmy_db_schema::{
schema::{community, mod_ban_from_community, user_, user_alias_1},
source::{
-use crate::ViewToVec;
use diesel::{result::Error, *};
-use lemmy_db::{limit_and_offset, ToSafe};
+use lemmy_db_queries::{limit_and_offset, ToSafe, ViewToVec};
use lemmy_db_schema::{
schema::{mod_ban, user_, user_alias_1},
source::{
-use crate::ViewToVec;
use diesel::{result::Error, *};
-use lemmy_db::{limit_and_offset, ToSafe};
+use lemmy_db_queries::{limit_and_offset, ToSafe, ViewToVec};
use lemmy_db_schema::{
schema::{community, mod_lock_post, post, user_},
source::{
-use crate::ViewToVec;
use diesel::{result::Error, *};
-use lemmy_db::{limit_and_offset, ToSafe};
+use lemmy_db_queries::{limit_and_offset, ToSafe, ViewToVec};
use lemmy_db_schema::{
schema::{comment, community, mod_remove_comment, post, user_, user_alias_1},
source::{
-use crate::ViewToVec;
use diesel::{result::Error, *};
-use lemmy_db::{limit_and_offset, ToSafe};
+use lemmy_db_queries::{limit_and_offset, ToSafe, ViewToVec};
use lemmy_db_schema::{
schema::{community, mod_remove_community, user_},
source::{
-use crate::ViewToVec;
use diesel::{result::Error, *};
-use lemmy_db::{limit_and_offset, ToSafe};
+use lemmy_db_queries::{limit_and_offset, ToSafe, ViewToVec};
use lemmy_db_schema::{
schema::{community, mod_remove_post, post, user_},
source::{
-use crate::ViewToVec;
use diesel::{result::Error, *};
-use lemmy_db::{limit_and_offset, ToSafe};
+use lemmy_db_queries::{limit_and_offset, ToSafe, ViewToVec};
use lemmy_db_schema::{
schema::{community, mod_sticky_post, post, user_},
source::{
+++ /dev/null
-[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"
[dependencies]
lemmy_db_queries = { path = "../lemmy_db_queries" }
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_utils = { path = "../lemmy_utils" }
serde = { version = "1.0.118", features = ["derive"] }
-use lemmy_db_views::{
- community::{
- community_follower_view::CommunityFollowerView,
- community_moderator_view::CommunityModeratorView,
- community_view::CommunityView,
- },
+use lemmy_db_views_actor::{
+ community_follower_view::CommunityFollowerView,
+ community_moderator_view::CommunityModeratorView,
+ community_view::CommunityView,
user_view::UserViewSafe,
};
use serde::{Deserialize, Serialize};
pub mod user;
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::{
comment::Comment,
post::Post,
use lemmy_db_views::{
comment_view::CommentView,
- community::community_moderator_view::CommunityModeratorView,
post_report_view::PostReportView,
post_view::PostView,
};
+use lemmy_db_views_actor::community_moderator_view::CommunityModeratorView;
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Debug)]
use lemmy_db_schema::source::{category::*, user::User_};
-use lemmy_db_views::{
- comment_view::CommentView,
- community::community_view::CommunityView,
- 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::PostView,
- site_view::SiteView,
- user_view::UserViewSafe,
+use lemmy_db_views::{comment_view::CommentView, post_view::PostView, site_view::SiteView};
+use lemmy_db_views_actor::{community_view::CommunityView, user_view::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 serde::{Deserialize, Serialize};
use lemmy_db_views::{
comment_view::CommentView,
- community::{
- community_follower_view::CommunityFollowerView,
- community_moderator_view::CommunityModeratorView,
- },
post_view::PostView,
private_message_view::PrivateMessageView,
+};
+use lemmy_db_views_actor::{
+ community_follower_view::CommunityFollowerView,
+ community_moderator_view::CommunityModeratorView,
user_mention_view::UserMentionView,
user_view::{UserViewDangerous, UserViewSafe},
};
actix-rt = { version = "1.1.1", default-features = false }
anyhow = "1.0.36"
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"
#[macro_use]
extern crate lazy_static;
+#[macro_use]
+extern crate strum_macros;
pub mod apub;
pub mod email;
+pub mod rate_limit;
pub mod request;
pub mod settings;
#[cfg(test)]
-#[macro_use]
-extern crate strum_macros;
-
-use actix_web::dev::{Service, ServiceRequest, ServiceResponse, Transform};
-use futures::future::{ok, Ready};
-use lemmy_utils::{
+use crate::{
settings::{RateLimitConfig, Settings},
utils::get_ip,
LemmyError,
};
+use actix_web::dev::{Service, ServiceRequest, ServiceResponse, Transform};
+use futures::future::{ok, Ready};
use rate_limiter::{RateLimitType, RateLimiter};
use std::{
future::Future,
-use lemmy_utils::{APIError, IPAddr, LemmyError};
+use crate::{APIError, IPAddr, LemmyError};
use log::debug;
use std::{collections::HashMap, time::SystemTime};
use strum::IntoEnumIterator;
lemmy_structs = { path = "../lemmy_structs" }
lemmy_db_queries = { path = "../lemmy_db_queries" }
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"
rand = "0.8.0"
r2d2::{ConnectionManager, Pool},
PgConnection,
};
-use lemmy_rate_limit::RateLimit;
use lemmy_structs::{comment::*, post::*};
use lemmy_utils::{
location_info,
+ rate_limit::RateLimit,
APIError,
CommunityId,
ConnectionId,
use crate::chat_server::ChatServer;
use actix::Addr;
use background_jobs::QueueHandle;
-use lemmy_db::DbPool;
+use lemmy_db_queries::DbPool;
use lemmy_utils::LemmyError;
use reqwest::Client;
use serde::Serialize;
sql_types::{Nullable, Text},
*,
};
-use lemmy_db::{
+use lemmy_db_queries::{
source::{comment::Comment_, post::Post_, private_message::PrivateMessage_},
Crud,
};
};
use lemmy_api::match_websocket_operation;
use lemmy_apub::activity_queue::create_activity_queue;
-use lemmy_db::get_database_url_from_env;
-use lemmy_rate_limit::{rate_limiter::RateLimiter, RateLimit};
+use lemmy_db_queries::get_database_url_from_env;
use lemmy_server::{code_migrations::run_advanced_migrations, routes::*};
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 reqwest::Client;
use std::sync::Arc;
use actix_web::{error::ErrorBadRequest, *};
use lemmy_api::Perform;
-use lemmy_rate_limit::RateLimit;
use lemmy_structs::{comment::*, community::*, post::*, site::*, user::*};
+use lemmy_utils::rate_limit::RateLimit;
use lemmy_websocket::LemmyContext;
use serde::Deserialize;
use chrono::{DateTime, NaiveDateTime, Utc};
use diesel::PgConnection;
use lemmy_api::claims::Claims;
-use lemmy_db::{
+use lemmy_db_queries::{
source::{community::Community_, user::User},
ListingType,
SortType,
comment_view::{CommentQueryBuilder, CommentView},
post_view::{PostQueryBuilder, PostView},
site_view::SiteView,
- user_mention_view::{UserMentionQueryBuilder, UserMentionView},
};
+use lemmy_db_views_actor::user_mention_view::{UserMentionQueryBuilder, UserMentionView};
use lemmy_structs::blocking;
use lemmy_utils::{settings::Settings, utils::markdown_to_html, LemmyError};
use lemmy_websocket::LemmyContext;
use actix_web::{body::BodyStream, http::StatusCode, *};
use awc::Client;
use lemmy_api::claims::Claims;
-use lemmy_rate_limit::RateLimit;
-use lemmy_utils::settings::Settings;
+use lemmy_utils::{rate_limit::RateLimit, settings::Settings};
use serde::{Deserialize, Serialize};
pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
use actix_web::{error::ErrorBadRequest, web::Query, *};
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_structs::{blocking, WebFingerLink, WebFingerResponse};
use lemmy_utils::{
user_inbox::user_inbox,
},
};
-use lemmy_db::{Crud, ListingType, SortType};
+use lemmy_db_queries::{Crud, ListingType, SortType};
use lemmy_db_schema::source::{
community::{Community, CommunityForm},
user::{UserForm, User_},
};
-use lemmy_rate_limit::{rate_limiter::RateLimiter, RateLimit};
-use lemmy_utils::{apub::generate_actor_keypair, settings::Settings};
+use lemmy_utils::{
+ apub::generate_actor_keypair,
+ rate_limit::{rate_limiter::RateLimiter, RateLimit},
+ settings::Settings,
+};
use lemmy_websocket::{chat_server::ChatServer, LemmyContext};
use reqwest::Client;
use serde::{Deserialize, Serialize};