diff --git a/Cargo.lock b/Cargo.lock index 615178729..9b1d6efc3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2504,8 +2504,6 @@ dependencies = [ "lemmy_api_crud", "lemmy_db_schema", "lemmy_db_views", - "lemmy_db_views_actor", - "lemmy_db_views_moderator", "lemmy_utils", "pretty_assertions", "serial_test", @@ -2531,8 +2529,6 @@ dependencies = [ "jsonwebtoken", "lemmy_db_schema", "lemmy_db_views", - "lemmy_db_views_actor", - "lemmy_db_views_moderator", "lemmy_utils", "mime", "mime_guess", @@ -2568,7 +2564,6 @@ dependencies = [ "lemmy_api_common", "lemmy_db_schema", "lemmy_db_views", - "lemmy_db_views_actor", "lemmy_utils", "regex", "serde", @@ -2599,7 +2594,6 @@ dependencies = [ "lemmy_api_common", "lemmy_db_schema", "lemmy_db_views", - "lemmy_db_views_actor", "lemmy_utils", "moka", "pretty_assertions", @@ -2688,49 +2682,13 @@ dependencies = [ "serde", "serde_with", "serial_test", + "strum", "tokio", "tracing", "ts-rs", "url", ] -[[package]] -name = "lemmy_db_views_actor" -version = "0.19.6-beta.7" -dependencies = [ - "chrono", - "diesel", - "diesel-async", - "i-love-jesus", - "lemmy_db_schema", - "lemmy_utils", - "pretty_assertions", - "serde", - "serde_with", - "serial_test", - "strum", - "tokio", - "ts-rs", - "url", -] - -[[package]] -name = "lemmy_db_views_moderator" -version = "0.19.6-beta.7" -dependencies = [ - "diesel", - "diesel-async", - "i-love-jesus", - "lemmy_db_schema", - "lemmy_utils", - "pretty_assertions", - "serde", - "serde_with", - "serial_test", - "tokio", - "ts-rs", -] - [[package]] name = "lemmy_federate" version = "0.19.6-beta.7" @@ -2746,7 +2704,7 @@ dependencies = [ "lemmy_api_common", "lemmy_apub", "lemmy_db_schema", - "lemmy_db_views_actor", + "lemmy_db_views", "lemmy_utils", "mockall", "moka", @@ -2775,7 +2733,6 @@ dependencies = [ "lemmy_api_common", "lemmy_db_schema", "lemmy_db_views", - "lemmy_db_views_actor", "lemmy_utils", "reqwest 0.12.8", "reqwest-middleware", diff --git a/Cargo.toml b/Cargo.toml index b1553be5c..2a8fde862 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,8 +50,6 @@ members = [ "crates/db_perf", "crates/db_schema", "crates/db_views", - "crates/db_views_actor", - "crates/db_views_actor", "crates/routes", "crates/federate", ] @@ -91,8 +89,6 @@ lemmy_db_schema = { version = "=0.19.6-beta.7", path = "./crates/db_schema" } lemmy_api_common = { version = "=0.19.6-beta.7", path = "./crates/api_common" } lemmy_routes = { version = "=0.19.6-beta.7", path = "./crates/routes" } lemmy_db_views = { version = "=0.19.6-beta.7", path = "./crates/db_views" } -lemmy_db_views_actor = { version = "=0.19.6-beta.7", path = "./crates/db_views_actor" } -lemmy_db_views_moderator = { version = "=0.19.6-beta.7", path = "./crates/db_views_moderator" } lemmy_federate = { version = "=0.19.6-beta.7", path = "./crates/federate" } activitypub_federation = { version = "0.6.1", default-features = false, features = [ "actix-web", diff --git a/api_tests/prepare-drone-federation-test.sh b/api_tests/prepare-drone-federation-test.sh index e5a4bc604..a0d333f7b 100755 --- a/api_tests/prepare-drone-federation-test.sh +++ b/api_tests/prepare-drone-federation-test.sh @@ -9,7 +9,7 @@ then fi export RUST_BACKTRACE=1 -export RUST_LOG="warn,lemmy_server=$LEMMY_LOG_LEVEL,lemmy_federate=$LEMMY_LOG_LEVEL,lemmy_api=$LEMMY_LOG_LEVEL,lemmy_api_common=$LEMMY_LOG_LEVEL,lemmy_api_crud=$LEMMY_LOG_LEVEL,lemmy_apub=$LEMMY_LOG_LEVEL,lemmy_db_schema=$LEMMY_LOG_LEVEL,lemmy_db_views=$LEMMY_LOG_LEVEL,lemmy_db_views_actor=$LEMMY_LOG_LEVEL,lemmy_db_views_moderator=$LEMMY_LOG_LEVEL,lemmy_routes=$LEMMY_LOG_LEVEL,lemmy_utils=$LEMMY_LOG_LEVEL,lemmy_websocket=$LEMMY_LOG_LEVEL" +export RUST_LOG="warn,lemmy_server=$LEMMY_LOG_LEVEL,lemmy_federate=$LEMMY_LOG_LEVEL,lemmy_api=$LEMMY_LOG_LEVEL,lemmy_api_common=$LEMMY_LOG_LEVEL,lemmy_api_crud=$LEMMY_LOG_LEVEL,lemmy_apub=$LEMMY_LOG_LEVEL,lemmy_db_schema=$LEMMY_LOG_LEVEL,lemmy_db_views=$LEMMY_LOG_LEVEL,lemmy_routes=$LEMMY_LOG_LEVEL,lemmy_utils=$LEMMY_LOG_LEVEL,lemmy_websocket=$LEMMY_LOG_LEVEL" export LEMMY_TEST_FAST_FEDERATION=1 # by default, the persistent federation queue has delays in the scale of 30s-5min diff --git a/crates/api/Cargo.toml b/crates/api/Cargo.toml index 077426d32..eddd57b1f 100644 --- a/crates/api/Cargo.toml +++ b/crates/api/Cargo.toml @@ -21,8 +21,6 @@ workspace = true lemmy_utils = { workspace = true } lemmy_db_schema = { workspace = true, features = ["full"] } lemmy_db_views = { workspace = true, features = ["full"] } -lemmy_db_views_moderator = { workspace = true, features = ["full"] } -lemmy_db_views_actor = { workspace = true, features = ["full"] } lemmy_api_common = { workspace = true, features = ["full"] } activitypub_federation = { workspace = true } bcrypt = { workspace = true } diff --git a/crates/api/src/community/add_mod.rs b/crates/api/src/community/add_mod.rs index 4c5b4eae5..3417bc20a 100644 --- a/crates/api/src/community/add_mod.rs +++ b/crates/api/src/community/add_mod.rs @@ -14,8 +14,7 @@ use lemmy_db_schema::{ }, traits::{Crud, Joinable}, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::CommunityModeratorView; +use lemmy_db_views::structs::{CommunityModeratorView, LocalUserView}; use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult}; #[tracing::instrument(skip(context))] diff --git a/crates/api/src/community/ban.rs b/crates/api/src/community/ban.rs index 547838fa7..7ba0fb79e 100644 --- a/crates/api/src/community/ban.rs +++ b/crates/api/src/community/ban.rs @@ -24,8 +24,7 @@ use lemmy_db_schema::{ }, traits::{Bannable, Crud, Followable}, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::PersonView; +use lemmy_db_views::structs::{LocalUserView, PersonView}; use lemmy_utils::{ error::{LemmyErrorExt, LemmyErrorType, LemmyResult}, utils::validation::is_valid_body_field, diff --git a/crates/api/src/community/block.rs b/crates/api/src/community/block.rs index d49872493..e0ac782e8 100644 --- a/crates/api/src/community/block.rs +++ b/crates/api/src/community/block.rs @@ -12,8 +12,7 @@ use lemmy_db_schema::{ }, traits::{Blockable, Followable}, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::CommunityView; +use lemmy_db_views::structs::{CommunityView, LocalUserView}; use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult}; #[tracing::instrument(skip(context))] diff --git a/crates/api/src/community/follow.rs b/crates/api/src/community/follow.rs index d5cd3e5b1..e2ab7ee87 100644 --- a/crates/api/src/community/follow.rs +++ b/crates/api/src/community/follow.rs @@ -14,8 +14,7 @@ use lemmy_db_schema::{ traits::{Crud, Followable}, CommunityVisibility, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::{CommunityPersonBanView, CommunityView}; +use lemmy_db_views::structs::{CommunityPersonBanView, CommunityView, LocalUserView}; use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult}; #[tracing::instrument(skip(context))] diff --git a/crates/api/src/community/pending_follows/count.rs b/crates/api/src/community/pending_follows/count.rs index e8e333c84..885ce0585 100644 --- a/crates/api/src/community/pending_follows/count.rs +++ b/crates/api/src/community/pending_follows/count.rs @@ -4,8 +4,7 @@ use lemmy_api_common::{ context::LemmyContext, utils::is_mod_or_admin, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::CommunityFollowerView; +use lemmy_db_views::structs::{CommunityFollowerView, LocalUserView}; use lemmy_utils::error::LemmyResult; pub async fn get_pending_follows_count( diff --git a/crates/api/src/community/pending_follows/list.rs b/crates/api/src/community/pending_follows/list.rs index 9f300a74f..bf56478f0 100644 --- a/crates/api/src/community/pending_follows/list.rs +++ b/crates/api/src/community/pending_follows/list.rs @@ -4,8 +4,7 @@ use lemmy_api_common::{ context::LemmyContext, utils::check_community_mod_of_any_or_admin_action, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::CommunityFollowerView; +use lemmy_db_views::structs::{CommunityFollowerView, LocalUserView}; use lemmy_utils::error::LemmyResult; pub async fn get_pending_follows_list( diff --git a/crates/api/src/community/random.rs b/crates/api/src/community/random.rs index 3cc04e126..3798e29df 100644 --- a/crates/api/src/community/random.rs +++ b/crates/api/src/community/random.rs @@ -10,8 +10,7 @@ use lemmy_db_schema::source::{ community::Community, local_site::LocalSite, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::CommunityView; +use lemmy_db_views::structs::{CommunityView, LocalUserView}; use lemmy_utils::error::LemmyResult; #[tracing::instrument(skip(context))] diff --git a/crates/api/src/community/transfer.rs b/crates/api/src/community/transfer.rs index e60b50aa2..d2e0481d0 100644 --- a/crates/api/src/community/transfer.rs +++ b/crates/api/src/community/transfer.rs @@ -12,8 +12,7 @@ use lemmy_db_schema::{ }, traits::{Crud, Joinable}, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView}; +use lemmy_db_views::structs::{CommunityModeratorView, CommunityView, LocalUserView}; use lemmy_utils::{ error::{LemmyErrorExt, LemmyErrorType, LemmyResult}, location_info, diff --git a/crates/api/src/local_user/add_admin.rs b/crates/api/src/local_user/add_admin.rs index 1e821bf3e..34d357417 100644 --- a/crates/api/src/local_user/add_admin.rs +++ b/crates/api/src/local_user/add_admin.rs @@ -11,8 +11,7 @@ use lemmy_db_schema::{ }, traits::Crud, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::PersonView; +use lemmy_db_views::structs::{LocalUserView, PersonView}; use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult}; #[tracing::instrument(skip(context))] diff --git a/crates/api/src/local_user/ban_person.rs b/crates/api/src/local_user/ban_person.rs index 715bd206d..a6ec52db9 100644 --- a/crates/api/src/local_user/ban_person.rs +++ b/crates/api/src/local_user/ban_person.rs @@ -16,8 +16,7 @@ use lemmy_db_schema::{ }, traits::Crud, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::PersonView; +use lemmy_db_views::structs::{LocalUserView, PersonView}; use lemmy_utils::{ error::{LemmyErrorExt, LemmyErrorType, LemmyResult}, utils::validation::is_valid_body_field, diff --git a/crates/api/src/local_user/block.rs b/crates/api/src/local_user/block.rs index 3aee554d4..5c69835ba 100644 --- a/crates/api/src/local_user/block.rs +++ b/crates/api/src/local_user/block.rs @@ -7,8 +7,7 @@ use lemmy_db_schema::{ source::person_block::{PersonBlock, PersonBlockForm}, traits::Blockable, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::PersonView; +use lemmy_db_views::structs::{LocalUserView, PersonView}; use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult}; #[tracing::instrument(skip(context))] diff --git a/crates/api/src/local_user/list_banned.rs b/crates/api/src/local_user/list_banned.rs index ba2c0d403..d4227ca37 100644 --- a/crates/api/src/local_user/list_banned.rs +++ b/crates/api/src/local_user/list_banned.rs @@ -1,7 +1,6 @@ use actix_web::web::{Data, Json}; use lemmy_api_common::{context::LemmyContext, person::BannedPersonsResponse, utils::is_admin}; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::PersonView; +use lemmy_db_views::structs::{LocalUserView, PersonView}; use lemmy_utils::error::LemmyResult; pub async fn list_banned_users( diff --git a/crates/api/src/local_user/list_saved.rs b/crates/api/src/local_user/list_saved.rs index 5f0deff39..a316b03b7 100644 --- a/crates/api/src/local_user/list_saved.rs +++ b/crates/api/src/local_user/list_saved.rs @@ -6,7 +6,7 @@ use lemmy_api_common::{ utils::check_private_instance, }; use lemmy_db_views::{ - person_saved_combined_view::PersonSavedCombinedQuery, + combined::person_saved_combined_view::PersonSavedCombinedQuery, structs::{LocalUserView, SiteView}, }; use lemmy_utils::error::LemmyResult; diff --git a/crates/api/src/local_user/notifications/list_inbox.rs b/crates/api/src/local_user/notifications/list_inbox.rs index 7d6e88468..2145619d7 100644 --- a/crates/api/src/local_user/notifications/list_inbox.rs +++ b/crates/api/src/local_user/notifications/list_inbox.rs @@ -3,8 +3,7 @@ use lemmy_api_common::{ context::LemmyContext, person::{ListInbox, ListInboxResponse}, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::inbox_combined_view::InboxCombinedQuery; +use lemmy_db_views::{combined::inbox_combined_view::InboxCombinedQuery, structs::LocalUserView}; use lemmy_utils::error::LemmyResult; #[tracing::instrument(skip(context))] diff --git a/crates/api/src/local_user/notifications/mark_comment_mention_read.rs b/crates/api/src/local_user/notifications/mark_comment_mention_read.rs index 4a9c40092..b83e823f8 100644 --- a/crates/api/src/local_user/notifications/mark_comment_mention_read.rs +++ b/crates/api/src/local_user/notifications/mark_comment_mention_read.rs @@ -7,8 +7,7 @@ use lemmy_db_schema::{ source::person_comment_mention::{PersonCommentMention, PersonCommentMentionUpdateForm}, traits::Crud, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::PersonCommentMentionView; +use lemmy_db_views::structs::{LocalUserView, PersonCommentMentionView}; use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult}; #[tracing::instrument(skip(context))] diff --git a/crates/api/src/local_user/notifications/mark_post_mention_read.rs b/crates/api/src/local_user/notifications/mark_post_mention_read.rs index 35a12c65c..2f7bb7e85 100644 --- a/crates/api/src/local_user/notifications/mark_post_mention_read.rs +++ b/crates/api/src/local_user/notifications/mark_post_mention_read.rs @@ -7,8 +7,7 @@ use lemmy_db_schema::{ source::person_post_mention::{PersonPostMention, PersonPostMentionUpdateForm}, traits::Crud, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::PersonPostMentionView; +use lemmy_db_views::structs::{LocalUserView, PersonPostMentionView}; use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult}; #[tracing::instrument(skip(context))] diff --git a/crates/api/src/local_user/notifications/mark_reply_read.rs b/crates/api/src/local_user/notifications/mark_reply_read.rs index 5b263145f..04a8342bb 100644 --- a/crates/api/src/local_user/notifications/mark_reply_read.rs +++ b/crates/api/src/local_user/notifications/mark_reply_read.rs @@ -7,8 +7,7 @@ use lemmy_db_schema::{ source::comment_reply::{CommentReply, CommentReplyUpdateForm}, traits::Crud, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::CommentReplyView; +use lemmy_db_views::structs::{CommentReplyView, LocalUserView}; use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult}; #[tracing::instrument(skip(context))] diff --git a/crates/api/src/local_user/notifications/unread_count.rs b/crates/api/src/local_user/notifications/unread_count.rs index 4fa959329..2a4738ea9 100644 --- a/crates/api/src/local_user/notifications/unread_count.rs +++ b/crates/api/src/local_user/notifications/unread_count.rs @@ -1,7 +1,6 @@ use actix_web::web::{Data, Json}; use lemmy_api_common::{context::LemmyContext, person::GetUnreadCountResponse}; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::InboxCombinedViewInternal; +use lemmy_db_views::structs::{InboxCombinedViewInternal, LocalUserView}; use lemmy_utils::error::LemmyResult; #[tracing::instrument(skip(context))] diff --git a/crates/api/src/private_message/mark_read.rs b/crates/api/src/private_message/mark_read.rs index 26655caef..7c213464b 100644 --- a/crates/api/src/private_message/mark_read.rs +++ b/crates/api/src/private_message/mark_read.rs @@ -7,8 +7,7 @@ use lemmy_db_schema::{ source::private_message::{PrivateMessage, PrivateMessageUpdateForm}, traits::Crud, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::PrivateMessageView; +use lemmy_db_views::structs::{LocalUserView, PrivateMessageView}; use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult}; #[tracing::instrument(skip(context))] diff --git a/crates/api/src/reports/report_combined/list.rs b/crates/api/src/reports/report_combined/list.rs index 12548d189..16b48c619 100644 --- a/crates/api/src/reports/report_combined/list.rs +++ b/crates/api/src/reports/report_combined/list.rs @@ -4,7 +4,7 @@ use lemmy_api_common::{ reports::combined::{ListReports, ListReportsResponse}, utils::check_community_mod_of_any_or_admin_action, }; -use lemmy_db_views::{report_combined_view::ReportCombinedQuery, structs::LocalUserView}; +use lemmy_db_views::{combined::report_combined_view::ReportCombinedQuery, structs::LocalUserView}; use lemmy_utils::error::LemmyResult; /// Lists reports for a community if an id is supplied diff --git a/crates/api/src/site/leave_admin.rs b/crates/api/src/site/leave_admin.rs index fde258dd2..c3a2cbee0 100644 --- a/crates/api/src/site/leave_admin.rs +++ b/crates/api/src/site/leave_admin.rs @@ -12,8 +12,7 @@ use lemmy_db_schema::{ }, traits::Crud, }; -use lemmy_db_views::structs::{LocalUserView, SiteView}; -use lemmy_db_views_actor::structs::PersonView; +use lemmy_db_views::structs::{LocalUserView, PersonView, SiteView}; use lemmy_utils::{ error::{LemmyErrorType, LemmyResult}, VERSION, diff --git a/crates/api/src/site/mod_log.rs b/crates/api/src/site/mod_log.rs index 42fa770a6..14c18d3bc 100644 --- a/crates/api/src/site/mod_log.rs +++ b/crates/api/src/site/mod_log.rs @@ -5,8 +5,7 @@ use lemmy_api_common::{ utils::{check_community_mod_of_any_or_admin_action, check_private_instance}, }; use lemmy_db_schema::source::local_site::LocalSite; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_moderator::{self, modlog_combined_view::ModlogCombinedQuery}; +use lemmy_db_views::{combined::modlog_combined_view::ModlogCombinedQuery, structs::LocalUserView}; use lemmy_utils::error::LemmyResult; #[tracing::instrument(skip(context))] diff --git a/crates/api/src/site/purge/community.rs b/crates/api/src/site/purge/community.rs index c55f753dc..4869831e9 100644 --- a/crates/api/src/site/purge/community.rs +++ b/crates/api/src/site/purge/community.rs @@ -17,8 +17,7 @@ use lemmy_db_schema::{ }, traits::Crud, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::CommunityModeratorView; +use lemmy_db_views::structs::{CommunityModeratorView, LocalUserView}; use lemmy_utils::error::LemmyResult; #[tracing::instrument(skip(context))] diff --git a/crates/api/src/site/registration_applications/list.rs b/crates/api/src/site/registration_applications/list.rs index 877e83796..cae0acd43 100644 --- a/crates/api/src/site/registration_applications/list.rs +++ b/crates/api/src/site/registration_applications/list.rs @@ -7,7 +7,7 @@ use lemmy_api_common::{ }; use lemmy_db_schema::source::local_site::LocalSite; use lemmy_db_views::{ - registration_application_view::RegistrationApplicationQuery, + registration_applications::registration_application_view::RegistrationApplicationQuery, structs::LocalUserView, }; use lemmy_utils::error::LemmyResult; diff --git a/crates/api_common/Cargo.toml b/crates/api_common/Cargo.toml index 74a0390ca..30247a257 100644 --- a/crates/api_common/Cargo.toml +++ b/crates/api_common/Cargo.toml @@ -21,8 +21,6 @@ full = [ "tracing", "rosetta-i18n", "lemmy_db_views/full", - "lemmy_db_views_actor/full", - "lemmy_db_views_moderator/full", "lemmy_utils/full", "activitypub_federation", "encoding_rs", @@ -41,8 +39,6 @@ full = [ [dependencies] lemmy_db_views = { workspace = true } -lemmy_db_views_moderator = { workspace = true } -lemmy_db_views_actor = { workspace = true } lemmy_db_schema = { workspace = true } lemmy_utils = { workspace = true } activitypub_federation = { workspace = true, optional = true } diff --git a/crates/api_common/src/build_response.rs b/crates/api_common/src/build_response.rs index 0245a0459..d7ac888a9 100644 --- a/crates/api_common/src/build_response.rs +++ b/crates/api_common/src/build_response.rs @@ -25,8 +25,7 @@ use lemmy_db_schema::{ }, traits::Crud, }; -use lemmy_db_views::structs::{CommentView, LocalUserView, PostView}; -use lemmy_db_views_actor::structs::CommunityView; +use lemmy_db_views::structs::{CommentView, CommunityView, LocalUserView, PostView}; use lemmy_utils::{ error::LemmyResult, utils::{markdown::markdown_to_html, mention::MentionData}, diff --git a/crates/api_common/src/community.rs b/crates/api_common/src/community.rs index 898767b34..4182e2fd8 100644 --- a/crates/api_common/src/community.rs +++ b/crates/api_common/src/community.rs @@ -4,7 +4,7 @@ use lemmy_db_schema::{ CommunityVisibility, ListingType, }; -use lemmy_db_views_actor::structs::{ +use lemmy_db_views::structs::{ CommunityModeratorView, CommunitySortType, CommunityView, diff --git a/crates/api_common/src/lib.rs b/crates/api_common/src/lib.rs index 8af1dec25..9a5bb617e 100644 --- a/crates/api_common/src/lib.rs +++ b/crates/api_common/src/lib.rs @@ -23,8 +23,6 @@ pub mod utils; pub extern crate lemmy_db_schema; pub extern crate lemmy_db_views; -pub extern crate lemmy_db_views_actor; -pub extern crate lemmy_db_views_moderator; pub extern crate lemmy_utils; pub use lemmy_utils::error::LemmyErrorType; diff --git a/crates/api_common/src/person.rs b/crates/api_common/src/person.rs index a52fc2616..07ed32f20 100644 --- a/crates/api_common/src/person.rs +++ b/crates/api_common/src/person.rs @@ -16,18 +16,16 @@ use lemmy_db_schema::{ PostSortType, }; use lemmy_db_views::structs::{ - LocalImageView, - PersonContentCombinedPaginationCursor, - PersonContentCombinedView, - PersonSavedCombinedPaginationCursor, -}; -use lemmy_db_views_actor::structs::{ CommentReplyView, CommunityModeratorView, InboxCombinedPaginationCursor, InboxCombinedView, + LocalImageView, PersonCommentMentionView, + PersonContentCombinedPaginationCursor, + PersonContentCombinedView, PersonPostMentionView, + PersonSavedCombinedPaginationCursor, PersonView, }; use serde::{Deserialize, Serialize}; diff --git a/crates/api_common/src/post.rs b/crates/api_common/src/post.rs index 81cd7363b..2357342c1 100644 --- a/crates/api_common/src/post.rs +++ b/crates/api_common/src/post.rs @@ -4,8 +4,13 @@ use lemmy_db_schema::{ PostFeatureType, PostSortType, }; -use lemmy_db_views::structs::{PaginationCursor, PostView, VoteView}; -use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView}; +use lemmy_db_views::structs::{ + CommunityModeratorView, + CommunityView, + PaginationCursor, + PostView, + VoteView, +}; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; #[cfg(feature = "full")] diff --git a/crates/api_common/src/private_message.rs b/crates/api_common/src/private_message.rs index f8134ea27..aac27499a 100644 --- a/crates/api_common/src/private_message.rs +++ b/crates/api_common/src/private_message.rs @@ -1,5 +1,5 @@ use lemmy_db_schema::newtypes::{PersonId, PrivateMessageId}; -use lemmy_db_views_actor::structs::PrivateMessageView; +use lemmy_db_views::structs::PrivateMessageView; use serde::{Deserialize, Serialize}; #[cfg(feature = "full")] use ts_rs::TS; diff --git a/crates/api_common/src/send_activity.rs b/crates/api_common/src/send_activity.rs index 07203ffe4..b606c9a90 100644 --- a/crates/api_common/src/send_activity.rs +++ b/crates/api_common/src/send_activity.rs @@ -11,7 +11,7 @@ use lemmy_db_schema::{ private_message::PrivateMessage, }, }; -use lemmy_db_views_actor::structs::PrivateMessageView; +use lemmy_db_views::structs::PrivateMessageView; use lemmy_utils::error::LemmyResult; use std::sync::{LazyLock, OnceLock}; use tokio::{ diff --git a/crates/api_common/src/site.rs b/crates/api_common/src/site.rs index 5f86ae3b6..f3b327cb1 100644 --- a/crates/api_common/src/site.rs +++ b/crates/api_common/src/site.rs @@ -31,18 +31,17 @@ use lemmy_db_schema::{ }; use lemmy_db_views::structs::{ CommentView, + CommunityFollowerView, + CommunityModeratorView, + CommunityView, LocalUserView, + ModlogCombinedPaginationCursor, + ModlogCombinedView, + PersonView, PostView, RegistrationApplicationView, SiteView, }; -use lemmy_db_views_actor::structs::{ - CommunityFollowerView, - CommunityModeratorView, - CommunityView, - PersonView, -}; -use lemmy_db_views_moderator::structs::{ModlogCombinedPaginationCursor, ModlogCombinedView}; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; #[cfg(feature = "full")] diff --git a/crates/api_common/src/utils.rs b/crates/api_common/src/utils.rs index 99bf7aecc..13aa57a09 100644 --- a/crates/api_common/src/utils.rs +++ b/crates/api_common/src/utils.rs @@ -43,14 +43,16 @@ use lemmy_db_schema::{ RegistrationMode, }; use lemmy_db_views::{ - comment_view::CommentQuery, - structs::{LocalImageView, LocalUserView, SiteView}, -}; -use lemmy_db_views_actor::structs::{ - CommunityFollowerView, - CommunityModeratorView, - CommunityPersonBanView, - CommunityView, + comment::comment_view::CommentQuery, + structs::{ + CommunityFollowerView, + CommunityModeratorView, + CommunityPersonBanView, + CommunityView, + LocalImageView, + LocalUserView, + SiteView, + }, }; use lemmy_utils::{ email::{send_email, translations::Lang}, @@ -1190,8 +1192,8 @@ mod tests { }, ModlogActionType, }; - use lemmy_db_views_moderator::{ - modlog_combined_view::ModlogCombinedQuery, + use lemmy_db_views::{ + combined::modlog_combined_view::ModlogCombinedQuery, structs::ModlogCombinedView, }; use pretty_assertions::assert_eq; diff --git a/crates/api_crud/Cargo.toml b/crates/api_crud/Cargo.toml index a05a4deed..1b315fd3b 100644 --- a/crates/api_crud/Cargo.toml +++ b/crates/api_crud/Cargo.toml @@ -16,7 +16,6 @@ workspace = true lemmy_utils = { workspace = true, features = ["full"] } lemmy_db_schema = { workspace = true, features = ["full"] } lemmy_db_views = { workspace = true, features = ["full"] } -lemmy_db_views_actor = { workspace = true, features = ["full"] } lemmy_api_common = { workspace = true, features = ["full"] } activitypub_federation = { workspace = true } bcrypt = { workspace = true } diff --git a/crates/api_crud/src/community/delete.rs b/crates/api_crud/src/community/delete.rs index 7f9d04933..1482206e8 100644 --- a/crates/api_crud/src/community/delete.rs +++ b/crates/api_crud/src/community/delete.rs @@ -11,8 +11,7 @@ use lemmy_db_schema::{ source::community::{Community, CommunityUpdateForm}, traits::Crud, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::CommunityModeratorView; +use lemmy_db_views::structs::{CommunityModeratorView, LocalUserView}; use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult}; #[tracing::instrument(skip(context))] diff --git a/crates/api_crud/src/community/list.rs b/crates/api_crud/src/community/list.rs index 9c13ae89f..6886cf3fc 100644 --- a/crates/api_crud/src/community/list.rs +++ b/crates/api_crud/src/community/list.rs @@ -4,8 +4,10 @@ use lemmy_api_common::{ context::LemmyContext, utils::{check_private_instance, is_admin}, }; -use lemmy_db_views::structs::{LocalUserView, SiteView}; -use lemmy_db_views_actor::community_view::CommunityQuery; +use lemmy_db_views::{ + community::community_view::CommunityQuery, + structs::{LocalUserView, SiteView}, +}; use lemmy_utils::error::LemmyResult; #[tracing::instrument(skip(context))] diff --git a/crates/api_crud/src/post/create.rs b/crates/api_crud/src/post/create.rs index 860e82f44..7086a7068 100644 --- a/crates/api_crud/src/post/create.rs +++ b/crates/api_crud/src/post/create.rs @@ -27,8 +27,7 @@ use lemmy_db_schema::{ utils::diesel_url_create, CommunityVisibility, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::CommunityModeratorView; +use lemmy_db_views::structs::{CommunityModeratorView, LocalUserView}; use lemmy_utils::{ error::{LemmyErrorExt, LemmyErrorType, LemmyResult}, spawn_try_task, diff --git a/crates/api_crud/src/post/read.rs b/crates/api_crud/src/post/read.rs index 3b6ef9414..10986a119 100644 --- a/crates/api_crud/src/post/read.rs +++ b/crates/api_crud/src/post/read.rs @@ -12,10 +12,9 @@ use lemmy_db_schema::{ traits::Crud, }; use lemmy_db_views::{ - post_view::PostQuery, - structs::{LocalUserView, PostView, SiteView}, + post::post_view::PostQuery, + structs::{CommunityModeratorView, CommunityView, LocalUserView, PostView, SiteView}, }; -use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView}; use lemmy_utils::error::{LemmyErrorType, LemmyResult}; #[tracing::instrument(skip(context))] diff --git a/crates/api_crud/src/private_message/create.rs b/crates/api_crud/src/private_message/create.rs index fd95a2b9e..1a6a78d00 100644 --- a/crates/api_crud/src/private_message/create.rs +++ b/crates/api_crud/src/private_message/create.rs @@ -21,8 +21,7 @@ use lemmy_db_schema::{ }, traits::Crud, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::PrivateMessageView; +use lemmy_db_views::structs::{LocalUserView, PrivateMessageView}; use lemmy_utils::{ error::{LemmyErrorExt, LemmyErrorType, LemmyResult}, utils::{markdown::markdown_to_html, validation::is_valid_body_field}, diff --git a/crates/api_crud/src/private_message/delete.rs b/crates/api_crud/src/private_message/delete.rs index d06c8bc04..30efc020c 100644 --- a/crates/api_crud/src/private_message/delete.rs +++ b/crates/api_crud/src/private_message/delete.rs @@ -9,8 +9,7 @@ use lemmy_db_schema::{ source::private_message::{PrivateMessage, PrivateMessageUpdateForm}, traits::Crud, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::PrivateMessageView; +use lemmy_db_views::structs::{LocalUserView, PrivateMessageView}; use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult}; #[tracing::instrument(skip(context))] diff --git a/crates/api_crud/src/private_message/update.rs b/crates/api_crud/src/private_message/update.rs index 22c1da4a2..b9e4785ef 100644 --- a/crates/api_crud/src/private_message/update.rs +++ b/crates/api_crud/src/private_message/update.rs @@ -14,8 +14,7 @@ use lemmy_db_schema::{ }, traits::Crud, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::PrivateMessageView; +use lemmy_db_views::structs::{LocalUserView, PrivateMessageView}; use lemmy_utils::{ error::{LemmyErrorExt, LemmyErrorType, LemmyResult}, utils::validation::is_valid_body_field, diff --git a/crates/api_crud/src/site/read.rs b/crates/api_crud/src/site/read.rs index 220fe1bd5..beda1e052 100644 --- a/crates/api_crud/src/site/read.rs +++ b/crates/api_crud/src/site/read.rs @@ -8,8 +8,7 @@ use lemmy_db_schema::source::{ oauth_provider::OAuthProvider, tagline::Tagline, }; -use lemmy_db_views::structs::{LocalUserView, SiteView}; -use lemmy_db_views_actor::structs::PersonView; +use lemmy_db_views::structs::{LocalUserView, PersonView, SiteView}; use lemmy_utils::{build_cache, error::LemmyResult, CacheLock, VERSION}; use std::sync::LazyLock; diff --git a/crates/api_crud/src/user/my_user.rs b/crates/api_crud/src/user/my_user.rs index f7a92eb99..66026d60b 100644 --- a/crates/api_crud/src/user/my_user.rs +++ b/crates/api_crud/src/user/my_user.rs @@ -6,8 +6,7 @@ use lemmy_db_schema::source::{ instance_block::InstanceBlock, person_block::PersonBlock, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::{CommunityFollowerView, CommunityModeratorView}; +use lemmy_db_views::structs::{CommunityFollowerView, CommunityModeratorView, LocalUserView}; use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult}; #[tracing::instrument(skip(context))] diff --git a/crates/apub/Cargo.toml b/crates/apub/Cargo.toml index 8124fda01..76a901ca4 100644 --- a/crates/apub/Cargo.toml +++ b/crates/apub/Cargo.toml @@ -21,7 +21,6 @@ workspace = true lemmy_utils = { workspace = true, features = ["full"] } lemmy_db_schema = { workspace = true, features = ["full"] } lemmy_db_views = { workspace = true, features = ["full"] } -lemmy_db_views_actor = { workspace = true, features = ["full"] } lemmy_api_common = { workspace = true, features = ["full"] } activitypub_federation = { workspace = true } diesel = { workspace = true } diff --git a/crates/apub/src/activities/create_or_update/private_message.rs b/crates/apub/src/activities/create_or_update/private_message.rs index ce04a9330..b6e7478ef 100644 --- a/crates/apub/src/activities/create_or_update/private_message.rs +++ b/crates/apub/src/activities/create_or_update/private_message.rs @@ -14,7 +14,7 @@ use activitypub_federation::{ }; use lemmy_api_common::context::LemmyContext; use lemmy_db_schema::source::activity::ActivitySendTargets; -use lemmy_db_views_actor::structs::PrivateMessageView; +use lemmy_db_views::structs::PrivateMessageView; use lemmy_utils::error::{LemmyError, LemmyResult}; use url::Url; diff --git a/crates/apub/src/activities/mod.rs b/crates/apub/src/activities/mod.rs index ffb6a662e..7e8de206d 100644 --- a/crates/apub/src/activities/mod.rs +++ b/crates/apub/src/activities/mod.rs @@ -43,7 +43,7 @@ use lemmy_db_schema::{ traits::Crud, CommunityVisibility, }; -use lemmy_db_views_actor::structs::{CommunityPersonBanView, CommunityView}; +use lemmy_db_views::structs::{CommunityPersonBanView, CommunityView}; use lemmy_utils::error::{FederationError, LemmyError, LemmyErrorExt, LemmyErrorType, LemmyResult}; use serde::Serialize; use tracing::info; diff --git a/crates/apub/src/api/list_comments.rs b/crates/apub/src/api/list_comments.rs index 2411b874a..ddd50e3ef 100644 --- a/crates/apub/src/api/list_comments.rs +++ b/crates/apub/src/api/list_comments.rs @@ -16,7 +16,7 @@ use lemmy_db_schema::{ traits::Crud, }; use lemmy_db_views::{ - comment_view::CommentQuery, + comment::comment_view::CommentQuery, structs::{LocalUserView, SiteView}, }; use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType, LemmyResult}; diff --git a/crates/apub/src/api/list_person_content.rs b/crates/apub/src/api/list_person_content.rs index 477e62e85..3ac13ac04 100644 --- a/crates/apub/src/api/list_person_content.rs +++ b/crates/apub/src/api/list_person_content.rs @@ -7,7 +7,7 @@ use lemmy_api_common::{ utils::check_private_instance, }; use lemmy_db_views::{ - person_content_combined_view::PersonContentCombinedQuery, + combined::person_content_combined_view::PersonContentCombinedQuery, structs::{LocalUserView, SiteView}, }; use lemmy_utils::error::LemmyResult; diff --git a/crates/apub/src/api/list_posts.rs b/crates/apub/src/api/list_posts.rs index 6d043ae4f..b7e435bf5 100644 --- a/crates/apub/src/api/list_posts.rs +++ b/crates/apub/src/api/list_posts.rs @@ -15,7 +15,7 @@ use lemmy_db_schema::{ source::{community::Community, post::PostRead}, }; use lemmy_db_views::{ - post_view::PostQuery, + post::post_view::PostQuery, structs::{LocalUserView, PaginationCursor, SiteView}, }; use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult}; diff --git a/crates/apub/src/api/read_community.rs b/crates/apub/src/api/read_community.rs index f94769158..46195a545 100644 --- a/crates/apub/src/api/read_community.rs +++ b/crates/apub/src/api/read_community.rs @@ -11,8 +11,7 @@ use lemmy_db_schema::source::{ community::Community, local_site::LocalSite, }; -use lemmy_db_views::structs::LocalUserView; -use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView}; +use lemmy_db_views::structs::{CommunityModeratorView, CommunityView, LocalUserView}; use lemmy_utils::error::{LemmyErrorType, LemmyResult}; #[tracing::instrument(skip(context))] diff --git a/crates/apub/src/api/read_person.rs b/crates/apub/src/api/read_person.rs index 7f719fe71..52f217fb5 100644 --- a/crates/apub/src/api/read_person.rs +++ b/crates/apub/src/api/read_person.rs @@ -6,8 +6,7 @@ use lemmy_api_common::{ person::{GetPersonDetails, GetPersonDetailsResponse}, utils::{check_private_instance, is_admin, read_site_for_actor}, }; -use lemmy_db_views::structs::{LocalUserView, SiteView}; -use lemmy_db_views_actor::structs::{CommunityModeratorView, PersonView}; +use lemmy_db_views::structs::{CommunityModeratorView, LocalUserView, PersonView, SiteView}; use lemmy_utils::error::LemmyResult; #[tracing::instrument(skip(context))] diff --git a/crates/apub/src/api/resolve_object.rs b/crates/apub/src/api/resolve_object.rs index 8d2cd384f..9b4d4551c 100644 --- a/crates/apub/src/api/resolve_object.rs +++ b/crates/apub/src/api/resolve_object.rs @@ -11,8 +11,7 @@ use lemmy_api_common::{ utils::check_private_instance, }; use lemmy_db_schema::{source::local_site::LocalSite, utils::DbPool}; -use lemmy_db_views::structs::{CommentView, LocalUserView, PostView}; -use lemmy_db_views_actor::structs::{CommunityView, PersonView}; +use lemmy_db_views::structs::{CommentView, CommunityView, LocalUserView, PersonView, PostView}; use lemmy_utils::error::{LemmyErrorExt2, LemmyErrorType, LemmyResult}; #[tracing::instrument(skip(context))] diff --git a/crates/apub/src/api/search.rs b/crates/apub/src/api/search.rs index 0ae7053d3..be8737dff 100644 --- a/crates/apub/src/api/search.rs +++ b/crates/apub/src/api/search.rs @@ -8,14 +8,11 @@ use lemmy_api_common::{ }; use lemmy_db_schema::{source::community::Community, utils::post_to_comment_sort_type, SearchType}; use lemmy_db_views::{ - comment_view::CommentQuery, - post_view::PostQuery, - structs::{LocalUserView, SiteView}, -}; -use lemmy_db_views_actor::{ - community_view::CommunityQuery, - person_view::PersonQuery, - structs::CommunitySortType, + comment::comment_view::CommentQuery, + community::community_view::CommunityQuery, + person::person_view::PersonQuery, + post::post_view::PostQuery, + structs::{CommunitySortType, LocalUserView, SiteView}, }; use lemmy_utils::error::LemmyResult; diff --git a/crates/apub/src/api/user_settings_backup.rs b/crates/apub/src/api/user_settings_backup.rs index d98df25ad..3180223c5 100644 --- a/crates/apub/src/api/user_settings_backup.rs +++ b/crates/apub/src/api/user_settings_backup.rs @@ -323,8 +323,7 @@ pub(crate) mod tests { }, traits::{Crud, Followable}, }; - use lemmy_db_views::structs::LocalUserView; - use lemmy_db_views_actor::structs::CommunityFollowerView; + use lemmy_db_views::structs::{CommunityFollowerView, LocalUserView}; use lemmy_utils::error::{LemmyErrorType, LemmyResult}; use serial_test::serial; use std::time::Duration; diff --git a/crates/apub/src/collections/community_follower.rs b/crates/apub/src/collections/community_follower.rs index a4f5debbc..7293b2297 100644 --- a/crates/apub/src/collections/community_follower.rs +++ b/crates/apub/src/collections/community_follower.rs @@ -10,7 +10,7 @@ use activitypub_federation::{ }; use lemmy_api_common::{context::LemmyContext, utils::generate_followers_url}; use lemmy_db_schema::aggregates::structs::CommunityAggregates; -use lemmy_db_views_actor::structs::CommunityFollowerView; +use lemmy_db_views::structs::CommunityFollowerView; use lemmy_utils::error::LemmyError; use url::Url; diff --git a/crates/apub/src/collections/community_moderators.rs b/crates/apub/src/collections/community_moderators.rs index c7b925f97..51913724c 100644 --- a/crates/apub/src/collections/community_moderators.rs +++ b/crates/apub/src/collections/community_moderators.rs @@ -14,7 +14,7 @@ use lemmy_db_schema::{ source::community::{CommunityModerator, CommunityModeratorForm}, traits::Joinable, }; -use lemmy_db_views_actor::structs::CommunityModeratorView; +use lemmy_db_views::structs::CommunityModeratorView; use lemmy_utils::error::{LemmyError, LemmyResult}; use url::Url; diff --git a/crates/apub/src/collections/community_outbox.rs b/crates/apub/src/collections/community_outbox.rs index 01199bc2b..5e89f07f9 100644 --- a/crates/apub/src/collections/community_outbox.rs +++ b/crates/apub/src/collections/community_outbox.rs @@ -19,7 +19,7 @@ use activitypub_federation::{ use futures::future::join_all; use lemmy_api_common::{context::LemmyContext, utils::generate_outbox_url}; use lemmy_db_schema::{source::site::Site, utils::FETCH_LIMIT_MAX, PostSortType}; -use lemmy_db_views::post_view::PostQuery; +use lemmy_db_views::post::post_view::PostQuery; use lemmy_utils::error::{LemmyError, LemmyResult}; use url::Url; diff --git a/crates/apub/src/http/community.rs b/crates/apub/src/http/community.rs index dbcc51258..f4dd23d5b 100644 --- a/crates/apub/src/http/community.rs +++ b/crates/apub/src/http/community.rs @@ -23,7 +23,7 @@ use actix_web::{ }; use lemmy_api_common::context::LemmyContext; use lemmy_db_schema::{source::community::Community, traits::ApubActor, CommunityVisibility}; -use lemmy_db_views_actor::structs::CommunityFollowerView; +use lemmy_db_views::structs::CommunityFollowerView; use lemmy_utils::error::{LemmyErrorType, LemmyResult}; use serde::Deserialize; diff --git a/crates/apub/src/http/mod.rs b/crates/apub/src/http/mod.rs index fc2fbf0d3..09d878f26 100644 --- a/crates/apub/src/http/mod.rs +++ b/crates/apub/src/http/mod.rs @@ -18,7 +18,7 @@ use lemmy_db_schema::{ source::{activity::SentActivity, community::Community}, CommunityVisibility, }; -use lemmy_db_views_actor::structs::CommunityFollowerView; +use lemmy_db_views::structs::CommunityFollowerView; use lemmy_utils::error::{FederationError, LemmyErrorExt, LemmyErrorType, LemmyResult}; use serde::{Deserialize, Serialize}; use std::{ops::Deref, time::Duration}; diff --git a/crates/apub/src/objects/community.rs b/crates/apub/src/objects/community.rs index 689641910..d51dff3e8 100644 --- a/crates/apub/src/objects/community.rs +++ b/crates/apub/src/objects/community.rs @@ -40,7 +40,7 @@ use lemmy_db_schema::{ traits::{ApubActor, Crud}, CommunityVisibility, }; -use lemmy_db_views_actor::structs::CommunityFollowerView; +use lemmy_db_views::structs::CommunityFollowerView; use lemmy_utils::{ error::{LemmyError, LemmyResult}, spawn_try_task, diff --git a/crates/apub/src/objects/post.rs b/crates/apub/src/objects/post.rs index bcd1dbf8e..a4ba1330a 100644 --- a/crates/apub/src/objects/post.rs +++ b/crates/apub/src/objects/post.rs @@ -36,7 +36,7 @@ use lemmy_db_schema::{ }, traits::Crud, }; -use lemmy_db_views_actor::structs::CommunityModeratorView; +use lemmy_db_views::structs::CommunityModeratorView; use lemmy_utils::{ error::{LemmyError, LemmyResult}, spawn_try_task, diff --git a/crates/db_perf/src/main.rs b/crates/db_perf/src/main.rs index 02796a906..2d4fa0381 100644 --- a/crates/db_perf/src/main.rs +++ b/crates/db_perf/src/main.rs @@ -22,7 +22,7 @@ use lemmy_db_schema::{ utils::{build_db_pool, get_conn, now}, PostSortType, }; -use lemmy_db_views::{post_view::PostQuery, structs::PaginationCursor}; +use lemmy_db_views::{post::post_view::PostQuery, structs::PaginationCursor}; use lemmy_utils::error::{LemmyErrorExt2, LemmyResult}; use std::num::NonZeroU32; use url::Url; diff --git a/crates/db_views/Cargo.toml b/crates/db_views/Cargo.toml index 20dca5139..a17ace92e 100644 --- a/crates/db_views/Cargo.toml +++ b/crates/db_views/Cargo.toml @@ -41,6 +41,7 @@ actix-web = { workspace = true, optional = true } i-love-jesus = { workspace = true, optional = true } chrono = { workspace = true } derive-new.workspace = true +strum = { workspace = true } [dev-dependencies] serial_test = { workspace = true } diff --git a/crates/db_views_actor/src/inbox_combined_view.rs b/crates/db_views/src/combined/inbox_combined_view.rs similarity index 99% rename from crates/db_views_actor/src/inbox_combined_view.rs rename to crates/db_views/src/combined/inbox_combined_view.rs index 7b28daf2c..3e9e05383 100644 --- a/crates/db_views_actor/src/inbox_combined_view.rs +++ b/crates/db_views/src/combined/inbox_combined_view.rs @@ -536,7 +536,7 @@ impl InternalToCombinedView for InboxCombinedViewInternal { #[expect(clippy::indexing_slicing)] mod tests { use crate::{ - inbox_combined_view::InboxCombinedQuery, + combined::inbox_combined_view::InboxCombinedQuery, structs::{InboxCombinedView, InboxCombinedViewInternal, PrivateMessageView}, }; use lemmy_db_schema::{ diff --git a/crates/db_views/src/combined/mod.rs b/crates/db_views/src/combined/mod.rs new file mode 100644 index 000000000..d6f4576ee --- /dev/null +++ b/crates/db_views/src/combined/mod.rs @@ -0,0 +1,12 @@ +#[cfg(feature = "full")] +pub mod inbox_combined_view; +#[cfg(feature = "full")] +pub mod modlog_combined_view; +#[cfg(feature = "full")] +pub mod person_content_combined_view; +#[cfg(feature = "full")] +pub mod person_saved_combined_view; +#[cfg(feature = "full")] +pub mod report_combined_view; +#[cfg(feature = "full")] +pub mod search_combined_view; diff --git a/crates/db_views_moderator/src/modlog_combined_view.rs b/crates/db_views/src/combined/modlog_combined_view.rs similarity index 99% rename from crates/db_views_moderator/src/modlog_combined_view.rs rename to crates/db_views/src/combined/modlog_combined_view.rs index 3af4c87fe..42a4ac501 100644 --- a/crates/db_views_moderator/src/modlog_combined_view.rs +++ b/crates/db_views/src/combined/modlog_combined_view.rs @@ -609,7 +609,7 @@ impl InternalToCombinedView for ModlogCombinedViewInternal { #[expect(clippy::indexing_slicing)] mod tests { - use crate::{modlog_combined_view::ModlogCombinedQuery, structs::ModlogCombinedView}; + use crate::{combined::modlog_combined_view::ModlogCombinedQuery, structs::ModlogCombinedView}; use lemmy_db_schema::{ newtypes::PersonId, source::{ diff --git a/crates/db_views/src/person_content_combined_view.rs b/crates/db_views/src/combined/person_content_combined_view.rs similarity index 99% rename from crates/db_views/src/person_content_combined_view.rs rename to crates/db_views/src/combined/person_content_combined_view.rs index 0dca66885..84dcb6d25 100644 --- a/crates/db_views/src/person_content_combined_view.rs +++ b/crates/db_views/src/combined/person_content_combined_view.rs @@ -270,7 +270,7 @@ impl InternalToCombinedView for PersonContentViewInternal { mod tests { use crate::{ - person_content_combined_view::PersonContentCombinedQuery, + combined::person_content_combined_view::PersonContentCombinedQuery, structs::PersonContentCombinedView, }; use lemmy_db_schema::{ diff --git a/crates/db_views/src/person_saved_combined_view.rs b/crates/db_views/src/combined/person_saved_combined_view.rs similarity index 99% rename from crates/db_views/src/person_saved_combined_view.rs rename to crates/db_views/src/combined/person_saved_combined_view.rs index 9c800c016..8a48470be 100644 --- a/crates/db_views/src/person_saved_combined_view.rs +++ b/crates/db_views/src/combined/person_saved_combined_view.rs @@ -226,7 +226,7 @@ impl PersonSavedCombinedQuery { mod tests { use crate::{ - person_saved_combined_view::PersonSavedCombinedQuery, + combined::person_saved_combined_view::PersonSavedCombinedQuery, structs::{LocalUserView, PersonContentCombinedView}, }; use lemmy_db_schema::{ diff --git a/crates/db_views/src/report_combined_view.rs b/crates/db_views/src/combined/report_combined_view.rs similarity index 99% rename from crates/db_views/src/report_combined_view.rs rename to crates/db_views/src/combined/report_combined_view.rs index 0a103cfc2..d804a2328 100644 --- a/crates/db_views/src/report_combined_view.rs +++ b/crates/db_views/src/combined/report_combined_view.rs @@ -415,7 +415,7 @@ impl InternalToCombinedView for ReportCombinedViewInternal { mod tests { use crate::{ - report_combined_view::ReportCombinedQuery, + combined::report_combined_view::ReportCombinedQuery, structs::{ CommentReportView, LocalUserView, diff --git a/crates/db_views/src/combined/search_combined_view.rs b/crates/db_views/src/combined/search_combined_view.rs new file mode 100644 index 000000000..e69de29bb diff --git a/crates/db_views_actor/src/comment_reply_view.rs b/crates/db_views/src/comment/comment_reply_view.rs similarity index 100% rename from crates/db_views_actor/src/comment_reply_view.rs rename to crates/db_views/src/comment/comment_reply_view.rs diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment/comment_view.rs similarity index 99% rename from crates/db_views/src/comment_view.rs rename to crates/db_views/src/comment/comment_view.rs index 0067d0807..7d2f42a29 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment/comment_view.rs @@ -363,7 +363,7 @@ fn handle_deleted(mut c: CommentView, is_admin: bool) -> CommentView { mod tests { use crate::{ - comment_view::{CommentQuery, CommentSortType, CommentView, DbPool}, + comment::comment_view::{CommentQuery, CommentSortType, CommentView, DbPool}, structs::LocalUserView, }; use lemmy_db_schema::{ diff --git a/crates/db_views/src/comment/mod.rs b/crates/db_views/src/comment/mod.rs new file mode 100644 index 000000000..27d33a881 --- /dev/null +++ b/crates/db_views/src/comment/mod.rs @@ -0,0 +1,4 @@ +#[cfg(feature = "full")] +pub mod comment_reply_view; +#[cfg(feature = "full")] +pub mod comment_view; diff --git a/crates/db_views_actor/src/community_follower_view.rs b/crates/db_views/src/community/community_follower_view.rs similarity index 100% rename from crates/db_views_actor/src/community_follower_view.rs rename to crates/db_views/src/community/community_follower_view.rs diff --git a/crates/db_views_actor/src/community_moderator_view.rs b/crates/db_views/src/community/community_moderator_view.rs similarity index 100% rename from crates/db_views_actor/src/community_moderator_view.rs rename to crates/db_views/src/community/community_moderator_view.rs diff --git a/crates/db_views_actor/src/community_person_ban_view.rs b/crates/db_views/src/community/community_person_ban_view.rs similarity index 100% rename from crates/db_views_actor/src/community_person_ban_view.rs rename to crates/db_views/src/community/community_person_ban_view.rs diff --git a/crates/db_views_actor/src/community_view.rs b/crates/db_views/src/community/community_view.rs similarity index 99% rename from crates/db_views_actor/src/community_view.rs rename to crates/db_views/src/community/community_view.rs index 8bcf50ba3..d75c473f9 100644 --- a/crates/db_views_actor/src/community_view.rs +++ b/crates/db_views/src/community/community_view.rs @@ -266,7 +266,7 @@ impl CommunityQuery<'_> { mod tests { use crate::{ - community_view::CommunityQuery, + community::community_view::CommunityQuery, structs::{CommunitySortType, CommunityView}, }; use lemmy_db_schema::{ diff --git a/crates/db_views/src/community/mod.rs b/crates/db_views/src/community/mod.rs new file mode 100644 index 000000000..53d55c3cf --- /dev/null +++ b/crates/db_views/src/community/mod.rs @@ -0,0 +1,8 @@ +#[cfg(feature = "full")] +pub mod community_follower_view; +#[cfg(feature = "full")] +pub mod community_moderator_view; +#[cfg(feature = "full")] +pub mod community_person_ban_view; +#[cfg(feature = "full")] +pub mod community_view; diff --git a/crates/db_views/src/lib.rs b/crates/db_views/src/lib.rs index 06411a0cb..594303fda 100644 --- a/crates/db_views/src/lib.rs +++ b/crates/db_views/src/lib.rs @@ -2,31 +2,23 @@ extern crate serial_test; #[cfg(feature = "full")] -pub mod comment_report_view; +pub mod combined; #[cfg(feature = "full")] -pub mod comment_view; +pub mod comment; #[cfg(feature = "full")] -pub mod custom_emoji_view; +pub mod community; #[cfg(feature = "full")] -pub mod local_image_view; +pub mod local_user; #[cfg(feature = "full")] -pub mod local_user_view; +pub mod person; #[cfg(feature = "full")] -pub mod person_content_combined_view; +pub mod post; #[cfg(feature = "full")] -pub mod person_saved_combined_view; +pub mod private_message; #[cfg(feature = "full")] -pub mod post_report_view; +pub mod registration_applications; #[cfg(feature = "full")] -pub mod post_view; +pub mod reports; #[cfg(feature = "full")] -pub mod private_message_report_view; -#[cfg(feature = "full")] -pub mod registration_application_view; -#[cfg(feature = "full")] -pub mod report_combined_view; -#[cfg(feature = "full")] -pub mod site_view; +pub mod site; pub mod structs; -#[cfg(feature = "full")] -pub mod vote_view; diff --git a/crates/db_views/src/local_user_view.rs b/crates/db_views/src/local_user/local_user_view.rs similarity index 100% rename from crates/db_views/src/local_user_view.rs rename to crates/db_views/src/local_user/local_user_view.rs diff --git a/crates/db_views/src/local_user/mod.rs b/crates/db_views/src/local_user/mod.rs new file mode 100644 index 000000000..ffe33f138 --- /dev/null +++ b/crates/db_views/src/local_user/mod.rs @@ -0,0 +1,2 @@ +#[cfg(feature = "full")] +pub mod local_user_view; diff --git a/crates/db_views/src/person/mod.rs b/crates/db_views/src/person/mod.rs new file mode 100644 index 000000000..6c8d18238 --- /dev/null +++ b/crates/db_views/src/person/mod.rs @@ -0,0 +1,6 @@ +#[cfg(feature = "full")] +pub mod person_comment_mention_view; +#[cfg(feature = "full")] +pub mod person_post_mention_view; +#[cfg(feature = "full")] +pub mod person_view; diff --git a/crates/db_views_actor/src/person_comment_mention_view.rs b/crates/db_views/src/person/person_comment_mention_view.rs similarity index 100% rename from crates/db_views_actor/src/person_comment_mention_view.rs rename to crates/db_views/src/person/person_comment_mention_view.rs diff --git a/crates/db_views_actor/src/person_post_mention_view.rs b/crates/db_views/src/person/person_post_mention_view.rs similarity index 100% rename from crates/db_views_actor/src/person_post_mention_view.rs rename to crates/db_views/src/person/person_post_mention_view.rs diff --git a/crates/db_views_actor/src/person_view.rs b/crates/db_views/src/person/person_view.rs similarity index 100% rename from crates/db_views_actor/src/person_view.rs rename to crates/db_views/src/person/person_view.rs diff --git a/crates/db_views/src/post/mod.rs b/crates/db_views/src/post/mod.rs new file mode 100644 index 000000000..a44b4da5f --- /dev/null +++ b/crates/db_views/src/post/mod.rs @@ -0,0 +1,2 @@ +#[cfg(feature = "full")] +pub mod post_view; diff --git a/crates/db_views/src/post_view.rs b/crates/db_views/src/post/post_view.rs similarity index 99% rename from crates/db_views/src/post_view.rs rename to crates/db_views/src/post/post_view.rs index e4a65721e..f52867a5f 100644 --- a/crates/db_views/src/post_view.rs +++ b/crates/db_views/src/post/post_view.rs @@ -597,7 +597,7 @@ impl<'a> PostQuery<'a> { #[cfg(test)] mod tests { use crate::{ - post_view::{PaginationCursorData, PostQuery, PostView}, + post::post_view::{PaginationCursorData, PostQuery, PostView}, structs::LocalUserView, }; use chrono::Utc; diff --git a/crates/db_views/src/private_message/mod.rs b/crates/db_views/src/private_message/mod.rs new file mode 100644 index 000000000..71bde5dd1 --- /dev/null +++ b/crates/db_views/src/private_message/mod.rs @@ -0,0 +1,2 @@ +#[cfg(feature = "full")] +pub mod private_message_view; diff --git a/crates/db_views_actor/src/private_message_view.rs b/crates/db_views/src/private_message/private_message_view.rs similarity index 100% rename from crates/db_views_actor/src/private_message_view.rs rename to crates/db_views/src/private_message/private_message_view.rs diff --git a/crates/db_views/src/registration_applications/mod.rs b/crates/db_views/src/registration_applications/mod.rs new file mode 100644 index 000000000..b71cca970 --- /dev/null +++ b/crates/db_views/src/registration_applications/mod.rs @@ -0,0 +1,2 @@ +#[cfg(feature = "full")] +pub mod registration_application_view; diff --git a/crates/db_views/src/registration_application_view.rs b/crates/db_views/src/registration_applications/registration_application_view.rs similarity index 99% rename from crates/db_views/src/registration_application_view.rs rename to crates/db_views/src/registration_applications/registration_application_view.rs index 0fa0a5d7e..2fb4f5d7c 100644 --- a/crates/db_views/src/registration_application_view.rs +++ b/crates/db_views/src/registration_applications/registration_application_view.rs @@ -137,7 +137,7 @@ impl RegistrationApplicationQuery { #[cfg(test)] mod tests { - use crate::registration_application_view::{ + use crate::registration_applications::registration_application_view::{ RegistrationApplicationQuery, RegistrationApplicationView, }; diff --git a/crates/db_views/src/comment_report_view.rs b/crates/db_views/src/reports/comment_report_view.rs similarity index 100% rename from crates/db_views/src/comment_report_view.rs rename to crates/db_views/src/reports/comment_report_view.rs diff --git a/crates/db_views/src/reports/mod.rs b/crates/db_views/src/reports/mod.rs new file mode 100644 index 000000000..aa42ff6e9 --- /dev/null +++ b/crates/db_views/src/reports/mod.rs @@ -0,0 +1,6 @@ +#[cfg(feature = "full")] +pub mod comment_report_view; +#[cfg(feature = "full")] +pub mod post_report_view; +#[cfg(feature = "full")] +pub mod private_message_report_view; diff --git a/crates/db_views/src/post_report_view.rs b/crates/db_views/src/reports/post_report_view.rs similarity index 100% rename from crates/db_views/src/post_report_view.rs rename to crates/db_views/src/reports/post_report_view.rs diff --git a/crates/db_views/src/private_message_report_view.rs b/crates/db_views/src/reports/private_message_report_view.rs similarity index 100% rename from crates/db_views/src/private_message_report_view.rs rename to crates/db_views/src/reports/private_message_report_view.rs diff --git a/crates/db_views/src/custom_emoji_view.rs b/crates/db_views/src/site/custom_emoji_view.rs similarity index 100% rename from crates/db_views/src/custom_emoji_view.rs rename to crates/db_views/src/site/custom_emoji_view.rs diff --git a/crates/db_views/src/local_image_view.rs b/crates/db_views/src/site/local_image_view.rs similarity index 100% rename from crates/db_views/src/local_image_view.rs rename to crates/db_views/src/site/local_image_view.rs diff --git a/crates/db_views/src/site/mod.rs b/crates/db_views/src/site/mod.rs new file mode 100644 index 000000000..f2c318409 --- /dev/null +++ b/crates/db_views/src/site/mod.rs @@ -0,0 +1,8 @@ +#[cfg(feature = "full")] +pub mod custom_emoji_view; +#[cfg(feature = "full")] +pub mod local_image_view; +#[cfg(feature = "full")] +pub mod site_view; +#[cfg(feature = "full")] +pub mod vote_view; diff --git a/crates/db_views/src/site_view.rs b/crates/db_views/src/site/site_view.rs similarity index 100% rename from crates/db_views/src/site_view.rs rename to crates/db_views/src/site/site_view.rs diff --git a/crates/db_views/src/vote_view.rs b/crates/db_views/src/site/vote_view.rs similarity index 100% rename from crates/db_views/src/vote_view.rs rename to crates/db_views/src/site/vote_view.rs diff --git a/crates/db_views/src/structs.rs b/crates/db_views/src/structs.rs index 6aad4af21..e9a8bccb6 100644 --- a/crates/db_views/src/structs.rs +++ b/crates/db_views/src/structs.rs @@ -1,19 +1,52 @@ #[cfg(feature = "full")] use diesel::Queryable; use lemmy_db_schema::{ - aggregates::structs::{CommentAggregates, PersonAggregates, PostAggregates, SiteAggregates}, + aggregates::structs::{ + CommentAggregates, + CommunityAggregates, + PersonAggregates, + PostAggregates, + SiteAggregates, + }, source::{ comment::Comment, + comment_reply::CommentReply, comment_report::CommentReport, community::Community, custom_emoji::CustomEmoji, custom_emoji_keyword::CustomEmojiKeyword, images::{ImageDetails, LocalImage}, + instance::Instance, local_site::LocalSite, local_site_rate_limit::LocalSiteRateLimit, local_user::LocalUser, local_user_vote_display_mode::LocalUserVoteDisplayMode, + mod_log::{ + admin::{ + AdminAllowInstance, + AdminBlockInstance, + AdminPurgeComment, + AdminPurgeCommunity, + AdminPurgePerson, + AdminPurgePost, + }, + moderator::{ + ModAdd, + ModAddCommunity, + ModBan, + ModBanFromCommunity, + ModFeaturePost, + ModHideCommunity, + ModLockPost, + ModRemoveComment, + ModRemoveCommunity, + ModRemovePost, + ModTransferCommunity, + }, + }, person::Person, + person_comment_mention::PersonCommentMention, + person_post_mention::PersonPostMention, post::Post, post_report::PostReport, private_message::PrivateMessage, @@ -330,3 +363,536 @@ pub enum PersonContentCombinedView { Post(PostView), Comment(CommentView), } + +#[derive(Debug, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// A community follower. +pub struct CommunityFollowerView { + pub community: Community, + pub follower: Person, +} + +#[derive(Debug, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// A community moderator. +pub struct CommunityModeratorView { + pub community: Community, + pub moderator: Person, +} + +#[derive(Debug, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +/// A community person ban. +pub struct CommunityPersonBanView { + pub community: Community, + pub person: Person, +} + +#[derive(Debug, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// A community view. +pub struct CommunityView { + pub community: Community, + pub subscribed: SubscribedType, + pub blocked: bool, + pub counts: CommunityAggregates, + pub banned_from_community: bool, +} + +/// The community sort types. See here for descriptions: https://join-lemmy.org/docs/en/users/03-votes-and-ranking.html +#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "full", derive(TS))] +#[cfg_attr(feature = "full", ts(export))] +pub enum CommunitySortType { + #[default] + Active, + Hot, + New, + Old, + TopDay, + TopWeek, + TopMonth, + TopYear, + TopAll, + MostComments, + NewComments, + TopHour, + TopSixHour, + TopTwelveHour, + TopThreeMonths, + TopSixMonths, + TopNineMonths, + Controversial, + Scaled, + NameAsc, + NameDesc, +} + +#[skip_serializing_none] +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// A person comment mention view. +pub struct PersonCommentMentionView { + pub person_comment_mention: PersonCommentMention, + pub comment: Comment, + pub creator: Person, + pub post: Post, + pub community: Community, + pub recipient: Person, + pub counts: CommentAggregates, + pub creator_banned_from_community: bool, + pub banned_from_community: bool, + pub creator_is_moderator: bool, + pub creator_is_admin: bool, + pub subscribed: SubscribedType, + pub saved: bool, + pub creator_blocked: bool, + #[cfg_attr(feature = "full", ts(optional))] + pub my_vote: Option, +} + +#[skip_serializing_none] +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// A person post mention view. +pub struct PersonPostMentionView { + pub person_post_mention: PersonPostMention, + pub post: Post, + pub creator: Person, + pub community: Community, + #[cfg_attr(feature = "full", ts(optional))] + pub image_details: Option, + pub recipient: Person, + pub counts: PostAggregates, + pub creator_banned_from_community: bool, + pub banned_from_community: bool, + pub creator_is_moderator: bool, + pub creator_is_admin: bool, + pub subscribed: SubscribedType, + pub saved: bool, + pub read: bool, + pub hidden: bool, + pub creator_blocked: bool, + #[cfg_attr(feature = "full", ts(optional))] + pub my_vote: Option, + pub unread_comments: i64, +} + +#[skip_serializing_none] +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// A comment reply view. +pub struct CommentReplyView { + pub comment_reply: CommentReply, + pub comment: Comment, + pub creator: Person, + pub post: Post, + pub community: Community, + pub recipient: Person, + pub counts: CommentAggregates, + pub creator_banned_from_community: bool, + pub banned_from_community: bool, + pub creator_is_moderator: bool, + pub creator_is_admin: bool, + pub subscribed: SubscribedType, + pub saved: bool, + pub creator_blocked: bool, + #[cfg_attr(feature = "full", ts(optional))] + pub my_vote: Option, +} + +#[derive(Debug, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// A person view. +pub struct PersonView { + pub person: Person, + pub counts: PersonAggregates, + pub is_admin: bool, +} + +#[derive(Debug, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +pub struct PendingFollow { + pub person: Person, + pub community: Community, + pub is_new_instance: bool, + pub subscribed: SubscribedType, +} + +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// A private message view. +pub struct PrivateMessageView { + pub private_message: PrivateMessage, + pub creator: Person, + pub recipient: Person, +} + +/// like PaginationCursor but for the report_combined table +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "full", derive(TS))] +#[cfg_attr(feature = "full", ts(export))] +pub struct InboxCombinedPaginationCursor(pub String); + +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +/// A combined inbox view +pub struct InboxCombinedViewInternal { + // Comment reply + pub comment_reply: Option, + // Person comment mention + pub person_comment_mention: Option, + // Person post mention + pub person_post_mention: Option, + pub post_counts: Option, + pub post_unread_comments: Option, + pub post_saved: bool, + pub post_read: bool, + pub post_hidden: bool, + pub my_post_vote: Option, + pub image_details: Option, + // Private message + pub private_message: Option, + // Shared + pub post: Option, + pub community: Option, + pub comment: Option, + pub comment_counts: Option, + pub comment_saved: bool, + pub my_comment_vote: Option, + pub subscribed: SubscribedType, + pub item_creator: Person, + pub item_recipient: Person, + pub item_creator_is_admin: bool, + pub item_creator_is_moderator: bool, + pub item_creator_banned_from_community: bool, + pub item_creator_blocked: bool, + pub banned_from_community: bool, +} + +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS))] +#[cfg_attr(feature = "full", ts(export))] +// Use serde's internal tagging, to work easier with javascript libraries +#[serde(tag = "type_")] +pub enum InboxCombinedView { + CommentReply(CommentReplyView), + CommentMention(PersonCommentMentionView), + PostMention(PersonPostMentionView), + PrivateMessage(PrivateMessageView), +} +#[skip_serializing_none] +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// When someone is added as a community moderator. +pub struct ModAddCommunityView { + pub mod_add_community: ModAddCommunity, + #[cfg_attr(feature = "full", ts(optional))] + pub moderator: Option, + pub community: Community, + pub modded_person: Person, +} + +#[skip_serializing_none] +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// When someone is added as a site moderator. +pub struct ModAddView { + pub mod_add: ModAdd, + #[cfg_attr(feature = "full", ts(optional))] + pub moderator: Option, + pub modded_person: Person, +} + +#[skip_serializing_none] +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// When someone is banned from a community. +pub struct ModBanFromCommunityView { + pub mod_ban_from_community: ModBanFromCommunity, + #[cfg_attr(feature = "full", ts(optional))] + pub moderator: Option, + pub community: Community, + pub modded_person: Person, +} + +#[skip_serializing_none] +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// When someone is banned from the site. +pub struct ModBanView { + pub mod_ban: ModBan, + #[cfg_attr(feature = "full", ts(optional))] + pub moderator: Option, + pub modded_person: Person, +} + +#[skip_serializing_none] +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// When a community is hidden from public view. +pub struct ModHideCommunityView { + pub mod_hide_community: ModHideCommunity, + #[cfg_attr(feature = "full", ts(optional))] + pub admin: Option, + pub community: Community, +} + +#[skip_serializing_none] +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// When a moderator locks a post (prevents new comments being made). +pub struct ModLockPostView { + pub mod_lock_post: ModLockPost, + #[cfg_attr(feature = "full", ts(optional))] + pub moderator: Option, + pub modded_person: Person, + pub post: Post, + pub community: Community, +} + +#[skip_serializing_none] +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// When a moderator removes a comment. +pub struct ModRemoveCommentView { + pub mod_remove_comment: ModRemoveComment, + #[cfg_attr(feature = "full", ts(optional))] + pub moderator: Option, + pub modded_person: Person, + pub comment: Comment, + pub post: Post, + pub community: Community, +} + +#[skip_serializing_none] +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// When a moderator removes a community. +pub struct ModRemoveCommunityView { + pub mod_remove_community: ModRemoveCommunity, + #[cfg_attr(feature = "full", ts(optional))] + pub moderator: Option, + pub community: Community, +} + +#[skip_serializing_none] +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// When a moderator removes a post. +pub struct ModRemovePostView { + pub mod_remove_post: ModRemovePost, + #[cfg_attr(feature = "full", ts(optional))] + pub moderator: Option, + pub modded_person: Person, + pub post: Post, + pub community: Community, +} + +#[skip_serializing_none] +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// When a moderator features a post on a community (pins it to the top). +pub struct ModFeaturePostView { + pub mod_feature_post: ModFeaturePost, + #[cfg_attr(feature = "full", ts(optional))] + pub moderator: Option, + pub modded_person: Person, + pub post: Post, + pub community: Community, +} + +#[skip_serializing_none] +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// When a moderator transfers a community to a new owner. +pub struct ModTransferCommunityView { + pub mod_transfer_community: ModTransferCommunity, + #[cfg_attr(feature = "full", ts(optional))] + pub moderator: Option, + pub community: Community, + pub modded_person: Person, +} + +#[skip_serializing_none] +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// When an admin purges a comment. +pub struct AdminPurgeCommentView { + pub admin_purge_comment: AdminPurgeComment, + #[cfg_attr(feature = "full", ts(optional))] + pub admin: Option, + pub post: Post, +} + +#[skip_serializing_none] +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// When an admin purges a community. +pub struct AdminPurgeCommunityView { + pub admin_purge_community: AdminPurgeCommunity, + #[cfg_attr(feature = "full", ts(optional))] + pub admin: Option, +} + +#[skip_serializing_none] +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// When an admin purges a person. +pub struct AdminPurgePersonView { + pub admin_purge_person: AdminPurgePerson, + #[cfg_attr(feature = "full", ts(optional))] + pub admin: Option, +} + +#[skip_serializing_none] +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// When an admin purges a post. +pub struct AdminPurgePostView { + pub admin_purge_post: AdminPurgePost, + #[cfg_attr(feature = "full", ts(optional))] + pub admin: Option, + pub community: Community, +} + +#[skip_serializing_none] +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// When an admin purges a post. +pub struct AdminBlockInstanceView { + pub admin_block_instance: AdminBlockInstance, + pub instance: Instance, + #[cfg_attr(feature = "full", ts(optional))] + pub admin: Option, +} + +#[skip_serializing_none] +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS, Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +/// When an admin purges a post. +pub struct AdminAllowInstanceView { + pub admin_allow_instance: AdminAllowInstance, + pub instance: Instance, + #[cfg_attr(feature = "full", ts(optional))] + pub admin: Option, +} + +/// like PaginationCursor but for the modlog_combined +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "full", derive(TS))] +#[cfg_attr(feature = "full", ts(export))] +pub struct ModlogCombinedPaginationCursor(pub String); + +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(Queryable))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +/// A combined modlog view +pub struct ModlogCombinedViewInternal { + // Specific + pub admin_allow_instance: Option, + pub admin_block_instance: Option, + pub admin_purge_comment: Option, + pub admin_purge_community: Option, + pub admin_purge_person: Option, + pub admin_purge_post: Option, + pub mod_add: Option, + pub mod_add_community: Option, + pub mod_ban: Option, + pub mod_ban_from_community: Option, + pub mod_feature_post: Option, + pub mod_hide_community: Option, + pub mod_lock_post: Option, + pub mod_remove_comment: Option, + pub mod_remove_community: Option, + pub mod_remove_post: Option, + pub mod_transfer_community: Option, + // Specific fields + + // Shared + pub moderator: Option, + pub modded_person: Option, + pub instance: Option, + pub community: Option, + pub post: Option, + pub comment: Option, +} + +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS))] +#[cfg_attr(feature = "full", ts(export))] +// Use serde's internal tagging, to work easier with javascript libraries +#[serde(tag = "type_")] +pub enum ModlogCombinedView { + AdminAllowInstance(AdminAllowInstanceView), + AdminBlockInstance(AdminBlockInstanceView), + AdminPurgeComment(AdminPurgeCommentView), + AdminPurgeCommunity(AdminPurgeCommunityView), + AdminPurgePerson(AdminPurgePersonView), + AdminPurgePost(AdminPurgePostView), + ModAdd(ModAddView), + ModAddCommunity(ModAddCommunityView), + ModBan(ModBanView), + ModBanFromCommunity(ModBanFromCommunityView), + ModFeaturePost(ModFeaturePostView), + ModHideCommunity(ModHideCommunityView), + ModLockPost(ModLockPostView), + ModRemoveComment(ModRemoveCommentView), + ModRemoveCommunity(ModRemoveCommunityView), + ModRemovePost(ModRemovePostView), + ModTransferCommunity(ModTransferCommunityView), +} diff --git a/crates/db_views_actor/Cargo.toml b/crates/db_views_actor/Cargo.toml deleted file mode 100644 index 85f50d08c..000000000 --- a/crates/db_views_actor/Cargo.toml +++ /dev/null @@ -1,50 +0,0 @@ -[package] -name = "lemmy_db_views_actor" -version.workspace = true -edition.workspace = true -description.workspace = true -license.workspace = true -homepage.workspace = true -documentation.workspace = true -repository.workspace = true - -[lib] -doctest = false - -[lints] -workspace = true - -[features] -full = [ - "lemmy_db_schema/full", - "lemmy_utils/full", - "i-love-jesus", - "diesel", - "diesel-async", - "ts-rs", -] - -[dependencies] -lemmy_db_schema = { workspace = true } -diesel = { workspace = true, features = [ - "postgres", - "chrono", - "serde_json", -], optional = true } -diesel-async = { workspace = true, features = [ - "postgres", - "deadpool", -], optional = true } -serde = { workspace = true } -serde_with = { workspace = true } -ts-rs = { workspace = true, optional = true } -chrono.workspace = true -strum = { workspace = true } -lemmy_utils = { workspace = true, optional = true } -i-love-jesus = { workspace = true, optional = true } - -[dev-dependencies] -serial_test = { workspace = true } -tokio = { workspace = true } -pretty_assertions = { workspace = true } -url.workspace = true diff --git a/crates/db_views_actor/src/lib.rs b/crates/db_views_actor/src/lib.rs deleted file mode 100644 index d982c4a1f..000000000 --- a/crates/db_views_actor/src/lib.rs +++ /dev/null @@ -1,21 +0,0 @@ -#[cfg(feature = "full")] -pub mod comment_reply_view; -#[cfg(feature = "full")] -pub mod community_follower_view; -#[cfg(feature = "full")] -pub mod community_moderator_view; -#[cfg(feature = "full")] -pub mod community_person_ban_view; -#[cfg(feature = "full")] -pub mod community_view; -#[cfg(feature = "full")] -pub mod inbox_combined_view; -#[cfg(feature = "full")] -pub mod person_comment_mention_view; -#[cfg(feature = "full")] -pub mod person_post_mention_view; -#[cfg(feature = "full")] -pub mod person_view; -#[cfg(feature = "full")] -pub mod private_message_view; -pub mod structs; diff --git a/crates/db_views_actor/src/structs.rs b/crates/db_views_actor/src/structs.rs deleted file mode 100644 index b1f75c86d..000000000 --- a/crates/db_views_actor/src/structs.rs +++ /dev/null @@ -1,259 +0,0 @@ -#[cfg(feature = "full")] -use diesel::Queryable; -use lemmy_db_schema::{ - aggregates::structs::{CommentAggregates, CommunityAggregates, PersonAggregates, PostAggregates}, - source::{ - comment::Comment, - comment_reply::CommentReply, - community::Community, - images::ImageDetails, - person::Person, - person_comment_mention::PersonCommentMention, - person_post_mention::PersonPostMention, - post::Post, - private_message::PrivateMessage, - }, - SubscribedType, -}; -use serde::{Deserialize, Serialize}; -use serde_with::skip_serializing_none; -#[cfg(feature = "full")] -use ts_rs::TS; - -#[derive(Debug, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// A community follower. -pub struct CommunityFollowerView { - pub community: Community, - pub follower: Person, -} - -#[derive(Debug, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// A community moderator. -pub struct CommunityModeratorView { - pub community: Community, - pub moderator: Person, -} - -#[derive(Debug, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -/// A community person ban. -pub struct CommunityPersonBanView { - pub community: Community, - pub person: Person, -} - -#[derive(Debug, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// A community view. -pub struct CommunityView { - pub community: Community, - pub subscribed: SubscribedType, - pub blocked: bool, - pub counts: CommunityAggregates, - pub banned_from_community: bool, -} - -/// The community sort types. See here for descriptions: https://join-lemmy.org/docs/en/users/03-votes-and-ranking.html -#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "full", derive(TS))] -#[cfg_attr(feature = "full", ts(export))] -pub enum CommunitySortType { - #[default] - Active, - Hot, - New, - Old, - TopDay, - TopWeek, - TopMonth, - TopYear, - TopAll, - MostComments, - NewComments, - TopHour, - TopSixHour, - TopTwelveHour, - TopThreeMonths, - TopSixMonths, - TopNineMonths, - Controversial, - Scaled, - NameAsc, - NameDesc, -} - -#[skip_serializing_none] -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// A person comment mention view. -pub struct PersonCommentMentionView { - pub person_comment_mention: PersonCommentMention, - pub comment: Comment, - pub creator: Person, - pub post: Post, - pub community: Community, - pub recipient: Person, - pub counts: CommentAggregates, - pub creator_banned_from_community: bool, - pub banned_from_community: bool, - pub creator_is_moderator: bool, - pub creator_is_admin: bool, - pub subscribed: SubscribedType, - pub saved: bool, - pub creator_blocked: bool, - #[cfg_attr(feature = "full", ts(optional))] - pub my_vote: Option, -} - -#[skip_serializing_none] -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// A person post mention view. -pub struct PersonPostMentionView { - pub person_post_mention: PersonPostMention, - pub post: Post, - pub creator: Person, - pub community: Community, - #[cfg_attr(feature = "full", ts(optional))] - pub image_details: Option, - pub recipient: Person, - pub counts: PostAggregates, - pub creator_banned_from_community: bool, - pub banned_from_community: bool, - pub creator_is_moderator: bool, - pub creator_is_admin: bool, - pub subscribed: SubscribedType, - pub saved: bool, - pub read: bool, - pub hidden: bool, - pub creator_blocked: bool, - #[cfg_attr(feature = "full", ts(optional))] - pub my_vote: Option, - pub unread_comments: i64, -} - -#[skip_serializing_none] -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// A comment reply view. -pub struct CommentReplyView { - pub comment_reply: CommentReply, - pub comment: Comment, - pub creator: Person, - pub post: Post, - pub community: Community, - pub recipient: Person, - pub counts: CommentAggregates, - pub creator_banned_from_community: bool, - pub banned_from_community: bool, - pub creator_is_moderator: bool, - pub creator_is_admin: bool, - pub subscribed: SubscribedType, - pub saved: bool, - pub creator_blocked: bool, - #[cfg_attr(feature = "full", ts(optional))] - pub my_vote: Option, -} - -#[derive(Debug, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// A person view. -pub struct PersonView { - pub person: Person, - pub counts: PersonAggregates, - pub is_admin: bool, -} - -#[derive(Debug, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -pub struct PendingFollow { - pub person: Person, - pub community: Community, - pub is_new_instance: bool, - pub subscribed: SubscribedType, -} - -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// A private message view. -pub struct PrivateMessageView { - pub private_message: PrivateMessage, - pub creator: Person, - pub recipient: Person, -} - -/// like PaginationCursor but for the report_combined table -#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "full", derive(TS))] -#[cfg_attr(feature = "full", ts(export))] -pub struct InboxCombinedPaginationCursor(pub String); - -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -/// A combined inbox view -pub struct InboxCombinedViewInternal { - // Comment reply - pub comment_reply: Option, - // Person comment mention - pub person_comment_mention: Option, - // Person post mention - pub person_post_mention: Option, - pub post_counts: Option, - pub post_unread_comments: Option, - pub post_saved: bool, - pub post_read: bool, - pub post_hidden: bool, - pub my_post_vote: Option, - pub image_details: Option, - // Private message - pub private_message: Option, - // Shared - pub post: Option, - pub community: Option, - pub comment: Option, - pub comment_counts: Option, - pub comment_saved: bool, - pub my_comment_vote: Option, - pub subscribed: SubscribedType, - pub item_creator: Person, - pub item_recipient: Person, - pub item_creator_is_admin: bool, - pub item_creator_is_moderator: bool, - pub item_creator_banned_from_community: bool, - pub item_creator_blocked: bool, - pub banned_from_community: bool, -} - -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS))] -#[cfg_attr(feature = "full", ts(export))] -// Use serde's internal tagging, to work easier with javascript libraries -#[serde(tag = "type_")] -pub enum InboxCombinedView { - CommentReply(CommentReplyView), - CommentMention(PersonCommentMentionView), - PostMention(PersonPostMentionView), - PrivateMessage(PrivateMessageView), -} diff --git a/crates/db_views_moderator/Cargo.toml b/crates/db_views_moderator/Cargo.toml deleted file mode 100644 index 9e0185e4b..000000000 --- a/crates/db_views_moderator/Cargo.toml +++ /dev/null @@ -1,47 +0,0 @@ -[package] -name = "lemmy_db_views_moderator" -version.workspace = true -edition.workspace = true -description.workspace = true -license.workspace = true -homepage.workspace = true -documentation.workspace = true -repository.workspace = true - -[lib] -doctest = false - -[lints] -workspace = true - -[features] -full = [ - "lemmy_db_schema/full", - "lemmy_utils", - "i-love-jesus", - "diesel", - "diesel-async", - "ts-rs", -] - -[dependencies] -lemmy_db_schema = { workspace = true } -lemmy_utils = { workspace = true, optional = true } -i-love-jesus = { workspace = true, optional = true } -diesel = { workspace = true, features = [ - "postgres", - "chrono", - "serde_json", -], optional = true } -diesel-async = { workspace = true, features = [ - "postgres", - "deadpool", -], optional = true } -serde = { workspace = true } -serde_with = { workspace = true } -ts-rs = { workspace = true, optional = true } - -[dev-dependencies] -serial_test = { workspace = true } -tokio = { workspace = true } -pretty_assertions = { workspace = true } diff --git a/crates/db_views_moderator/src/lib.rs b/crates/db_views_moderator/src/lib.rs deleted file mode 100644 index 1cc21da27..000000000 --- a/crates/db_views_moderator/src/lib.rs +++ /dev/null @@ -1,3 +0,0 @@ -#[cfg(feature = "full")] -pub mod modlog_combined_view; -pub mod structs; diff --git a/crates/db_views_moderator/src/structs.rs b/crates/db_views_moderator/src/structs.rs deleted file mode 100644 index 96aa27b59..000000000 --- a/crates/db_views_moderator/src/structs.rs +++ /dev/null @@ -1,332 +0,0 @@ -#[cfg(feature = "full")] -use diesel::Queryable; -use lemmy_db_schema::source::{ - comment::Comment, - community::Community, - instance::Instance, - mod_log::{ - admin::{ - AdminAllowInstance, - AdminBlockInstance, - AdminPurgeComment, - AdminPurgeCommunity, - AdminPurgePerson, - AdminPurgePost, - }, - moderator::{ - ModAdd, - ModAddCommunity, - ModBan, - ModBanFromCommunity, - ModFeaturePost, - ModHideCommunity, - ModLockPost, - ModRemoveComment, - ModRemoveCommunity, - ModRemovePost, - ModTransferCommunity, - }, - }, - person::Person, - post::Post, -}; -use serde::{Deserialize, Serialize}; -use serde_with::skip_serializing_none; -#[cfg(feature = "full")] -use ts_rs::TS; - -#[skip_serializing_none] -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// When someone is added as a community moderator. -pub struct ModAddCommunityView { - pub mod_add_community: ModAddCommunity, - #[cfg_attr(feature = "full", ts(optional))] - pub moderator: Option, - pub community: Community, - pub modded_person: Person, -} - -#[skip_serializing_none] -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// When someone is added as a site moderator. -pub struct ModAddView { - pub mod_add: ModAdd, - #[cfg_attr(feature = "full", ts(optional))] - pub moderator: Option, - pub modded_person: Person, -} - -#[skip_serializing_none] -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// When someone is banned from a community. -pub struct ModBanFromCommunityView { - pub mod_ban_from_community: ModBanFromCommunity, - #[cfg_attr(feature = "full", ts(optional))] - pub moderator: Option, - pub community: Community, - pub modded_person: Person, -} - -#[skip_serializing_none] -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// When someone is banned from the site. -pub struct ModBanView { - pub mod_ban: ModBan, - #[cfg_attr(feature = "full", ts(optional))] - pub moderator: Option, - pub modded_person: Person, -} - -#[skip_serializing_none] -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// When a community is hidden from public view. -pub struct ModHideCommunityView { - pub mod_hide_community: ModHideCommunity, - #[cfg_attr(feature = "full", ts(optional))] - pub admin: Option, - pub community: Community, -} - -#[skip_serializing_none] -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// When a moderator locks a post (prevents new comments being made). -pub struct ModLockPostView { - pub mod_lock_post: ModLockPost, - #[cfg_attr(feature = "full", ts(optional))] - pub moderator: Option, - pub modded_person: Person, - pub post: Post, - pub community: Community, -} - -#[skip_serializing_none] -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// When a moderator removes a comment. -pub struct ModRemoveCommentView { - pub mod_remove_comment: ModRemoveComment, - #[cfg_attr(feature = "full", ts(optional))] - pub moderator: Option, - pub modded_person: Person, - pub comment: Comment, - pub post: Post, - pub community: Community, -} - -#[skip_serializing_none] -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// When a moderator removes a community. -pub struct ModRemoveCommunityView { - pub mod_remove_community: ModRemoveCommunity, - #[cfg_attr(feature = "full", ts(optional))] - pub moderator: Option, - pub community: Community, -} - -#[skip_serializing_none] -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// When a moderator removes a post. -pub struct ModRemovePostView { - pub mod_remove_post: ModRemovePost, - #[cfg_attr(feature = "full", ts(optional))] - pub moderator: Option, - pub modded_person: Person, - pub post: Post, - pub community: Community, -} - -#[skip_serializing_none] -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// When a moderator features a post on a community (pins it to the top). -pub struct ModFeaturePostView { - pub mod_feature_post: ModFeaturePost, - #[cfg_attr(feature = "full", ts(optional))] - pub moderator: Option, - pub modded_person: Person, - pub post: Post, - pub community: Community, -} - -#[skip_serializing_none] -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// When a moderator transfers a community to a new owner. -pub struct ModTransferCommunityView { - pub mod_transfer_community: ModTransferCommunity, - #[cfg_attr(feature = "full", ts(optional))] - pub moderator: Option, - pub community: Community, - pub modded_person: Person, -} - -#[skip_serializing_none] -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// When an admin purges a comment. -pub struct AdminPurgeCommentView { - pub admin_purge_comment: AdminPurgeComment, - #[cfg_attr(feature = "full", ts(optional))] - pub admin: Option, - pub post: Post, -} - -#[skip_serializing_none] -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// When an admin purges a community. -pub struct AdminPurgeCommunityView { - pub admin_purge_community: AdminPurgeCommunity, - #[cfg_attr(feature = "full", ts(optional))] - pub admin: Option, -} - -#[skip_serializing_none] -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// When an admin purges a person. -pub struct AdminPurgePersonView { - pub admin_purge_person: AdminPurgePerson, - #[cfg_attr(feature = "full", ts(optional))] - pub admin: Option, -} - -#[skip_serializing_none] -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// When an admin purges a post. -pub struct AdminPurgePostView { - pub admin_purge_post: AdminPurgePost, - #[cfg_attr(feature = "full", ts(optional))] - pub admin: Option, - pub community: Community, -} - -#[skip_serializing_none] -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// When an admin purges a post. -pub struct AdminBlockInstanceView { - pub admin_block_instance: AdminBlockInstance, - pub instance: Instance, - #[cfg_attr(feature = "full", ts(optional))] - pub admin: Option, -} - -#[skip_serializing_none] -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS, Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -#[cfg_attr(feature = "full", ts(export))] -/// When an admin purges a post. -pub struct AdminAllowInstanceView { - pub admin_allow_instance: AdminAllowInstance, - pub instance: Instance, - #[cfg_attr(feature = "full", ts(optional))] - pub admin: Option, -} - -/// like PaginationCursor but for the modlog_combined -#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "full", derive(TS))] -#[cfg_attr(feature = "full", ts(export))] -pub struct ModlogCombinedPaginationCursor(pub String); - -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(Queryable))] -#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] -/// A combined modlog view -pub struct ModlogCombinedViewInternal { - // Specific - pub admin_allow_instance: Option, - pub admin_block_instance: Option, - pub admin_purge_comment: Option, - pub admin_purge_community: Option, - pub admin_purge_person: Option, - pub admin_purge_post: Option, - pub mod_add: Option, - pub mod_add_community: Option, - pub mod_ban: Option, - pub mod_ban_from_community: Option, - pub mod_feature_post: Option, - pub mod_hide_community: Option, - pub mod_lock_post: Option, - pub mod_remove_comment: Option, - pub mod_remove_community: Option, - pub mod_remove_post: Option, - pub mod_transfer_community: Option, - // Specific fields - - // Shared - pub moderator: Option, - pub modded_person: Option, - pub instance: Option, - pub community: Option, - pub post: Option, - pub comment: Option, -} - -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "full", derive(TS))] -#[cfg_attr(feature = "full", ts(export))] -// Use serde's internal tagging, to work easier with javascript libraries -#[serde(tag = "type_")] -pub enum ModlogCombinedView { - AdminAllowInstance(AdminAllowInstanceView), - AdminBlockInstance(AdminBlockInstanceView), - AdminPurgeComment(AdminPurgeCommentView), - AdminPurgeCommunity(AdminPurgeCommunityView), - AdminPurgePerson(AdminPurgePersonView), - AdminPurgePost(AdminPurgePostView), - ModAdd(ModAddView), - ModAddCommunity(ModAddCommunityView), - ModBan(ModBanView), - ModBanFromCommunity(ModBanFromCommunityView), - ModFeaturePost(ModFeaturePostView), - ModHideCommunity(ModHideCommunityView), - ModLockPost(ModLockPostView), - ModRemoveComment(ModRemoveCommentView), - ModRemoveCommunity(ModRemoveCommunityView), - ModRemovePost(ModRemovePostView), - ModTransferCommunity(ModTransferCommunityView), -} diff --git a/crates/federate/Cargo.toml b/crates/federate/Cargo.toml index 5d7454276..775763030 100644 --- a/crates/federate/Cargo.toml +++ b/crates/federate/Cargo.toml @@ -18,7 +18,7 @@ workspace = true lemmy_api_common.workspace = true lemmy_apub.workspace = true lemmy_db_schema = { workspace = true, features = ["full"] } -lemmy_db_views_actor.workspace = true +lemmy_db_views.workspace = true lemmy_utils.workspace = true activitypub_federation.workspace = true diff --git a/crates/federate/src/inboxes.rs b/crates/federate/src/inboxes.rs index ec96b1d6c..a3997bc3b 100644 --- a/crates/federate/src/inboxes.rs +++ b/crates/federate/src/inboxes.rs @@ -6,7 +6,7 @@ use lemmy_db_schema::{ source::{activity::SentActivity, site::Site}, utils::{ActualDbPool, DbPool}, }; -use lemmy_db_views_actor::structs::CommunityFollowerView; +use lemmy_db_views::structs::CommunityFollowerView; use lemmy_utils::error::LemmyResult; use reqwest::Url; use std::{ diff --git a/crates/routes/Cargo.toml b/crates/routes/Cargo.toml index 91c3ed683..828c0f25b 100644 --- a/crates/routes/Cargo.toml +++ b/crates/routes/Cargo.toml @@ -18,7 +18,6 @@ workspace = true [dependencies] lemmy_utils = { workspace = true, features = ["full"] } lemmy_db_views = { workspace = true } -lemmy_db_views_actor = { workspace = true } lemmy_db_schema = { workspace = true } lemmy_api_common = { workspace = true, features = ["full"] } activitypub_federation = { workspace = true } diff --git a/crates/routes/src/feeds.rs b/crates/routes/src/feeds.rs index 810daf4c1..e06944b4a 100644 --- a/crates/routes/src/feeds.rs +++ b/crates/routes/src/feeds.rs @@ -11,10 +11,10 @@ use lemmy_db_schema::{ PostSortType, }; use lemmy_db_views::{ - post_view::PostQuery, - structs::{PostView, SiteView}, + combined::inbox_combined_view::InboxCombinedQuery, + post::post_view::PostQuery, + structs::{InboxCombinedView, PostView, SiteView}, }; -use lemmy_db_views_actor::{inbox_combined_view::InboxCombinedQuery, structs::InboxCombinedView}; use lemmy_utils::{ cache_header::cache_1hour, error::{LemmyError, LemmyErrorType, LemmyResult}, diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index cb438af3a..c69b3e78e 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -38,7 +38,7 @@ services: hostname: lemmy restart: unless-stopped environment: - - RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug" + - RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug" - RUST_BACKTRACE=full ports: # prometheus metrics can be enabled with the `prometheus` config option. they are available on diff --git a/docker/federation/docker-compose.yml b/docker/federation/docker-compose.yml index bc4b5ea7f..711e4eae0 100644 --- a/docker/federation/docker-compose.yml +++ b/docker/federation/docker-compose.yml @@ -16,7 +16,7 @@ x-lemmy-default: &lemmy-default dockerfile: docker/Dockerfile environment: - RUST_BACKTRACE=1 - - RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug" + - RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug" restart: always x-postgres-default: &postgres-default