From d1aed759567c06066c784482f5fc6bc9415dffd1 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> Date: Mon, 16 Jun 2025 08:34:05 +0000 Subject: [PATCH] Small `lemmy_api_common`/`db_views` fixes/tweaks (#5783) * Refactor Taglines * Include crate ts-rs dependencies when needed, move some views to account_management views * Re export NotePerson from lemmy_api_common * Remove unused "full" feature from lemmy_db_views_tagline * Replace "full" feature in lemmy_api_common with "ts-rs" * Remove newly added db_views crates and put structs in existing db_views crates --- Cargo.lock | 31 +- Cargo.toml | 2 - crates/api/api/Cargo.toml | 1 - .../src/community/pending_follows/approve.rs | 2 +- .../api/api/src/local_user/change_password.rs | 2 +- .../local_user/change_password_after_reset.rs | 2 +- .../src/local_user/donation_dialog_shown.rs | 2 +- .../src/local_user/generate_totp_secret.rs | 2 +- crates/api/api/src/local_user/get_captcha.rs | 6 +- crates/api/api/src/local_user/list_hidden.rs | 2 +- crates/api/api/src/local_user/list_logins.rs | 2 +- crates/api/api/src/local_user/list_read.rs | 2 +- crates/api/api/src/local_user/login.rs | 6 +- crates/api/api/src/local_user/logout.rs | 2 +- crates/api/api/src/local_user/note_person.rs | 3 +- .../local_user/notifications/mark_all_read.rs | 2 +- .../mark_comment_mention_read.rs | 2 +- .../notifications/mark_post_mention_read.rs | 2 +- .../notifications/mark_reply_read.rs | 2 +- .../local_user/resend_verification_email.rs | 6 +- .../api/api/src/local_user/reset_password.rs | 6 +- .../api/api/src/local_user/save_settings.rs | 6 +- crates/api/api/src/local_user/update_totp.rs | 2 +- .../api/src/local_user/user_block_instance.rs | 2 +- .../api/api/src/local_user/validate_auth.rs | 2 +- crates/api/api/src/local_user/verify_email.rs | 6 +- crates/api/api/src/post/mark_many_read.rs | 2 +- .../api/api/src/private_message/mark_read.rs | 2 +- .../api/api/src/site/admin_allow_instance.rs | 3 +- .../api/api/src/site/admin_block_instance.rs | 3 +- crates/api/api/src/site/purge/comment.rs | 2 +- crates/api/api/src/site/purge/community.rs | 2 +- crates/api/api/src/site/purge/person.rs | 2 +- crates/api/api/src/site/purge/post.rs | 2 +- crates/api/api_common/Cargo.toml | 54 ++- crates/api/api_common/src/account.rs | 22 +- crates/api/api_common/src/federation.rs | 3 +- crates/api/api_common/src/lib.rs | 2 +- crates/api/api_common/src/person.rs | 2 +- crates/api/api_common/src/plugin.rs | 2 +- crates/api/api_common/src/tagline.rs | 2 +- crates/api/api_crud/Cargo.toml | 1 - .../api/api_crud/src/custom_emoji/delete.rs | 2 +- .../api/api_crud/src/oauth_provider/delete.rs | 3 +- crates/api/api_crud/src/tagline/create.rs | 3 +- crates/api/api_crud/src/tagline/delete.rs | 3 +- crates/api/api_crud/src/user/create.rs | 6 +- crates/api/api_crud/src/user/delete.rs | 2 +- crates/api/api_crud/src/user/my_user.rs | 2 +- crates/api/api_utils/Cargo.toml | 1 - crates/api/api_utils/src/plugins.rs | 2 +- crates/apub/Cargo.toml | 1 - crates/apub/src/api/resolve_object.rs | 3 +- crates/apub/src/api/user_settings_backup.rs | 2 +- crates/db_views/api_misc/Cargo.toml | 43 -- crates/db_views/api_misc/src/lib.rs | 352 ----------------- crates/db_views/comment/Cargo.toml | 7 +- crates/db_views/community/Cargo.toml | 8 +- crates/db_views/community_follower/Cargo.toml | 2 +- .../db_views/community_moderator/Cargo.toml | 2 +- crates/db_views/custom_emoji/Cargo.toml | 2 +- crates/db_views/inbox_combined/Cargo.toml | 7 +- crates/db_views/local_image/Cargo.toml | 2 +- crates/db_views/local_user/Cargo.toml | 2 +- crates/db_views/modlog_combined/Cargo.toml | 2 +- crates/db_views/person/Cargo.toml | 6 +- crates/db_views/person/src/api.rs | 11 + .../person_content_combined/Cargo.toml | 8 +- .../db_views/person_liked_combined/Cargo.toml | 7 +- .../db_views/person_saved_combined/Cargo.toml | 7 +- crates/db_views/post/Cargo.toml | 8 +- crates/db_views/private_message/Cargo.toml | 2 +- .../readable_federation_state/Cargo.toml | 2 +- .../registration_applications/Cargo.toml | 2 +- crates/db_views/report_combined/Cargo.toml | 2 +- crates/db_views/reports/Cargo.toml | 2 +- crates/db_views/search_combined/Cargo.toml | 10 +- crates/db_views/site/Cargo.toml | 23 +- crates/db_views/site/src/api.rs | 366 +++++++++++++++++- crates/db_views/vote/Cargo.toml | 2 +- crates/routes/Cargo.toml | 1 - crates/routes/src/images/delete.rs | 2 +- crates/routes/src/images/mod.rs | 2 +- 83 files changed, 564 insertions(+), 569 deletions(-) delete mode 100644 crates/db_views/api_misc/Cargo.toml delete mode 100644 crates/db_views/api_misc/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 7dc4e5359..08c276210 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3101,7 +3101,6 @@ dependencies = [ "lemmy_api_utils", "lemmy_db_schema", "lemmy_db_schema_file", - "lemmy_db_views_api_misc", "lemmy_db_views_comment", "lemmy_db_views_community", "lemmy_db_views_community_follower", @@ -3138,7 +3137,6 @@ version = "1.0.0-alpha.5" dependencies = [ "lemmy_db_schema", "lemmy_db_schema_file", - "lemmy_db_views_api_misc", "lemmy_db_views_comment", "lemmy_db_views_community", "lemmy_db_views_community_follower", @@ -3180,7 +3178,6 @@ dependencies = [ "lemmy_api_utils", "lemmy_db_schema", "lemmy_db_schema_file", - "lemmy_db_views_api_misc", "lemmy_db_views_comment", "lemmy_db_views_community", "lemmy_db_views_community_follower", @@ -3222,7 +3219,6 @@ dependencies = [ "jsonwebtoken", "lemmy_db_schema", "lemmy_db_schema_file", - "lemmy_db_views_api_misc", "lemmy_db_views_comment", "lemmy_db_views_community", "lemmy_db_views_community_follower", @@ -3274,7 +3270,6 @@ dependencies = [ "lemmy_apub_objects", "lemmy_db_schema", "lemmy_db_schema_file", - "lemmy_db_views_api_misc", "lemmy_db_views_comment", "lemmy_db_views_community", "lemmy_db_views_community_follower", @@ -3391,24 +3386,6 @@ dependencies = [ "ts-rs", ] -[[package]] -name = "lemmy_db_views_api_misc" -version = "1.0.0-alpha.5" -dependencies = [ - "extism", - "extism-convert", - "lemmy_db_schema", - "lemmy_db_schema_file", - "lemmy_db_views_community_follower", - "lemmy_db_views_community_moderator", - "lemmy_db_views_local_user", - "lemmy_db_views_post", - "serde", - "serde_with", - "ts-rs", - "url", -] - [[package]] name = "lemmy_db_views_comment" version = "1.0.0-alpha.5" @@ -3798,10 +3775,15 @@ dependencies = [ "chrono", "diesel", "diesel-async", + "extism", + "extism-convert", "lemmy_db_schema", "lemmy_db_schema_file", - "lemmy_db_views_api_misc", + "lemmy_db_views_community_follower", + "lemmy_db_views_community_moderator", + "lemmy_db_views_local_user", "lemmy_db_views_person", + "lemmy_db_views_post", "lemmy_db_views_readable_federation_state", "lemmy_utils", "serde", @@ -3896,7 +3878,6 @@ dependencies = [ "lemmy_api_utils", "lemmy_db_schema", "lemmy_db_schema_file", - "lemmy_db_views_api_misc", "lemmy_db_views_community", "lemmy_db_views_inbox_combined", "lemmy_db_views_local_image", diff --git a/Cargo.toml b/Cargo.toml index 607c8909c..5685bdeca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,7 +51,6 @@ members = [ "crates/utils", "crates/db_schema", "crates/db_schema_file", - "crates/db_views/api_misc", "crates/db_views/private_message", "crates/db_views/local_user", "crates/db_views/local_image", @@ -118,7 +117,6 @@ lemmy_api_utils = { version = "=1.0.0-alpha.5", path = "./crates/api/api_utils" lemmy_routes = { version = "=1.0.0-alpha.5", path = "./crates/routes" } lemmy_federate = { version = "=1.0.0-alpha.5", path = "./crates/federate" } lemmy_email = { version = "=1.0.0-alpha.5", path = "./crates/email" } -lemmy_db_views_api_misc = { version = "=1.0.0-alpha.5", path = "./crates/db_views/api_misc" } lemmy_db_views_comment = { version = "=1.0.0-alpha.5", path = "./crates/db_views/comment" } lemmy_db_views_community = { version = "=1.0.0-alpha.5", path = "./crates/db_views/community" } lemmy_db_views_community_follower = { version = "=1.0.0-alpha.5", path = "./crates/db_views/community_follower" } diff --git a/crates/api/api/Cargo.toml b/crates/api/api/Cargo.toml index 1e49679f3..b36bdceee 100644 --- a/crates/api/api/Cargo.toml +++ b/crates/api/api/Cargo.toml @@ -19,7 +19,6 @@ doctest = false workspace = true [dependencies] -lemmy_db_views_api_misc = { workspace = true, features = ["full"] } lemmy_db_views_comment = { workspace = true, features = ["full"] } lemmy_db_views_community = { workspace = true, features = ["full"] } lemmy_db_views_community_moderator = { workspace = true, features = ["full"] } diff --git a/crates/api/api/src/community/pending_follows/approve.rs b/crates/api/api/src/community/pending_follows/approve.rs index 9dcb19dc4..7273d97a5 100644 --- a/crates/api/api/src/community/pending_follows/approve.rs +++ b/crates/api/api/src/community/pending_follows/approve.rs @@ -6,9 +6,9 @@ use lemmy_api_utils::{ utils::is_mod_or_admin, }; use lemmy_db_schema::{source::community::CommunityActions, traits::Followable}; -use lemmy_db_views_api_misc::SuccessResponse; use lemmy_db_views_community::api::ApproveCommunityPendingFollower; use lemmy_db_views_local_user::LocalUserView; +use lemmy_db_views_site::api::SuccessResponse; use lemmy_utils::error::LemmyResult; pub async fn post_pending_follows_approve( diff --git a/crates/api/api/src/local_user/change_password.rs b/crates/api/api/src/local_user/change_password.rs index 75dba5c45..2620b78e3 100644 --- a/crates/api/api/src/local_user/change_password.rs +++ b/crates/api/api/src/local_user/change_password.rs @@ -5,8 +5,8 @@ use actix_web::{ use bcrypt::verify; use lemmy_api_utils::{claims::Claims, context::LemmyContext, utils::password_length_check}; use lemmy_db_schema::source::{local_user::LocalUser, login_token::LoginToken}; -use lemmy_db_views_api_misc::{ChangePassword, LoginResponse}; use lemmy_db_views_local_user::LocalUserView; +use lemmy_db_views_site::api::{ChangePassword, LoginResponse}; use lemmy_utils::error::{LemmyErrorType, LemmyResult}; pub async fn change_password( diff --git a/crates/api/api/src/local_user/change_password_after_reset.rs b/crates/api/api/src/local_user/change_password_after_reset.rs index 0ab190399..4ba27b3ba 100644 --- a/crates/api/api/src/local_user/change_password_after_reset.rs +++ b/crates/api/api/src/local_user/change_password_after_reset.rs @@ -5,7 +5,7 @@ use lemmy_db_schema::source::{ login_token::LoginToken, password_reset_request::PasswordResetRequest, }; -use lemmy_db_views_api_misc::{PasswordChangeAfterReset, SuccessResponse}; +use lemmy_db_views_site::api::{PasswordChangeAfterReset, SuccessResponse}; use lemmy_utils::error::{LemmyErrorType, LemmyResult}; pub async fn change_password_after_reset( diff --git a/crates/api/api/src/local_user/donation_dialog_shown.rs b/crates/api/api/src/local_user/donation_dialog_shown.rs index 2195edcb3..4876a4798 100644 --- a/crates/api/api/src/local_user/donation_dialog_shown.rs +++ b/crates/api/api/src/local_user/donation_dialog_shown.rs @@ -2,8 +2,8 @@ use actix_web::web::{Data, Json}; use chrono::Utc; use lemmy_api_utils::context::LemmyContext; use lemmy_db_schema::source::local_user::{LocalUser, LocalUserUpdateForm}; -use lemmy_db_views_api_misc::SuccessResponse; use lemmy_db_views_local_user::LocalUserView; +use lemmy_db_views_site::api::SuccessResponse; use lemmy_utils::error::LemmyResult; pub async fn donation_dialog_shown( diff --git a/crates/api/api/src/local_user/generate_totp_secret.rs b/crates/api/api/src/local_user/generate_totp_secret.rs index 1ec381a65..dbd988e9a 100644 --- a/crates/api/api/src/local_user/generate_totp_secret.rs +++ b/crates/api/api/src/local_user/generate_totp_secret.rs @@ -6,8 +6,8 @@ use lemmy_db_schema::source::{ local_user::{LocalUser, LocalUserUpdateForm}, site::Site, }; -use lemmy_db_views_api_misc::GenerateTotpSecretResponse; use lemmy_db_views_local_user::LocalUserView; +use lemmy_db_views_site::api::GenerateTotpSecretResponse; use lemmy_utils::error::{LemmyErrorType, LemmyResult}; /// Generate a new secret for two-factor-authentication. Afterwards you need to call [toggle_totp] diff --git a/crates/api/api/src/local_user/get_captcha.rs b/crates/api/api/src/local_user/get_captcha.rs index 42e0d21a0..a58e8c464 100644 --- a/crates/api/api/src/local_user/get_captcha.rs +++ b/crates/api/api/src/local_user/get_captcha.rs @@ -11,8 +11,10 @@ use actix_web::{ use captcha::{generate, Difficulty}; use lemmy_api_utils::context::LemmyContext; use lemmy_db_schema::source::captcha_answer::{CaptchaAnswer, CaptchaAnswerForm}; -use lemmy_db_views_api_misc::{CaptchaResponse, GetCaptchaResponse}; -use lemmy_db_views_site::SiteView; +use lemmy_db_views_site::{ + api::{CaptchaResponse, GetCaptchaResponse}, + SiteView, +}; use lemmy_utils::error::{LemmyErrorType, LemmyResult}; pub async fn get_captcha(context: Data) -> LemmyResult { diff --git a/crates/api/api/src/local_user/list_hidden.rs b/crates/api/api/src/local_user/list_hidden.rs index 4e1768602..26b8f1b3c 100644 --- a/crates/api/api/src/local_user/list_hidden.rs +++ b/crates/api/api/src/local_user/list_hidden.rs @@ -2,9 +2,9 @@ use activitypub_federation::config::Data; use actix_web::web::{Json, Query}; use lemmy_api_utils::context::LemmyContext; use lemmy_db_schema::source::post::PostActions; -use lemmy_db_views_api_misc::{ListPersonHidden, ListPersonHiddenResponse}; use lemmy_db_views_local_user::LocalUserView; use lemmy_db_views_post::PostView; +use lemmy_db_views_site::api::{ListPersonHidden, ListPersonHiddenResponse}; use lemmy_utils::error::LemmyResult; pub async fn list_person_hidden( diff --git a/crates/api/api/src/local_user/list_logins.rs b/crates/api/api/src/local_user/list_logins.rs index 9ba4af653..801347a20 100644 --- a/crates/api/api/src/local_user/list_logins.rs +++ b/crates/api/api/src/local_user/list_logins.rs @@ -1,8 +1,8 @@ use actix_web::web::{Data, Json}; use lemmy_api_utils::context::LemmyContext; use lemmy_db_schema::source::login_token::LoginToken; -use lemmy_db_views_api_misc::ListLoginsResponse; use lemmy_db_views_local_user::LocalUserView; +use lemmy_db_views_site::api::ListLoginsResponse; use lemmy_utils::error::LemmyResult; pub async fn list_logins( diff --git a/crates/api/api/src/local_user/list_read.rs b/crates/api/api/src/local_user/list_read.rs index a69b930df..cb1bfbda7 100644 --- a/crates/api/api/src/local_user/list_read.rs +++ b/crates/api/api/src/local_user/list_read.rs @@ -2,9 +2,9 @@ use activitypub_federation::config::Data; use actix_web::web::{Json, Query}; use lemmy_api_utils::context::LemmyContext; use lemmy_db_schema::source::post::PostActions; -use lemmy_db_views_api_misc::{ListPersonRead, ListPersonReadResponse}; use lemmy_db_views_local_user::LocalUserView; use lemmy_db_views_post::PostView; +use lemmy_db_views_site::api::{ListPersonRead, ListPersonReadResponse}; use lemmy_utils::error::LemmyResult; pub async fn list_person_read( diff --git a/crates/api/api/src/local_user/login.rs b/crates/api/api/src/local_user/login.rs index 4a8d6218c..2dd471dcd 100644 --- a/crates/api/api/src/local_user/login.rs +++ b/crates/api/api/src/local_user/login.rs @@ -9,9 +9,11 @@ use lemmy_api_utils::{ context::LemmyContext, utils::{check_email_verified, check_local_user_deleted, check_registration_application}, }; -use lemmy_db_views_api_misc::{Login, LoginResponse}; use lemmy_db_views_local_user::LocalUserView; -use lemmy_db_views_site::SiteView; +use lemmy_db_views_site::{ + api::{Login, LoginResponse}, + SiteView, +}; use lemmy_utils::error::{LemmyErrorType, LemmyResult}; pub async fn login( diff --git a/crates/api/api/src/local_user/logout.rs b/crates/api/api/src/local_user/logout.rs index 27936f491..4db8e35ba 100644 --- a/crates/api/api/src/local_user/logout.rs +++ b/crates/api/api/src/local_user/logout.rs @@ -5,8 +5,8 @@ use lemmy_api_utils::{ utils::{read_auth_token, AUTH_COOKIE_NAME}, }; use lemmy_db_schema::source::login_token::LoginToken; -use lemmy_db_views_api_misc::SuccessResponse; use lemmy_db_views_local_user::LocalUserView; +use lemmy_db_views_site::api::SuccessResponse; use lemmy_utils::error::{LemmyErrorType, LemmyResult}; pub async fn logout( diff --git a/crates/api/api/src/local_user/note_person.rs b/crates/api/api/src/local_user/note_person.rs index fc25b2981..dd9a58f60 100644 --- a/crates/api/api/src/local_user/note_person.rs +++ b/crates/api/api/src/local_user/note_person.rs @@ -4,8 +4,9 @@ use lemmy_api_utils::{ utils::{get_url_blocklist, process_markdown, slur_regex}, }; use lemmy_db_schema::source::person::{PersonActions, PersonNoteForm}; -use lemmy_db_views_api_misc::{NotePerson, SuccessResponse}; use lemmy_db_views_local_user::LocalUserView; +use lemmy_db_views_person::api::NotePerson; +use lemmy_db_views_site::api::SuccessResponse; use lemmy_utils::{ error::{LemmyErrorType, LemmyResult}, utils::{slurs::check_slurs, validation::is_valid_body_field}, diff --git a/crates/api/api/src/local_user/notifications/mark_all_read.rs b/crates/api/api/src/local_user/notifications/mark_all_read.rs index 86de7562f..ff315fd95 100644 --- a/crates/api/api/src/local_user/notifications/mark_all_read.rs +++ b/crates/api/api/src/local_user/notifications/mark_all_read.rs @@ -6,8 +6,8 @@ use lemmy_db_schema::source::{ person_post_mention::PersonPostMention, private_message::PrivateMessage, }; -use lemmy_db_views_api_misc::SuccessResponse; use lemmy_db_views_local_user::LocalUserView; +use lemmy_db_views_site::api::SuccessResponse; use lemmy_utils::error::LemmyResult; pub async fn mark_all_notifications_read( diff --git a/crates/api/api/src/local_user/notifications/mark_comment_mention_read.rs b/crates/api/api/src/local_user/notifications/mark_comment_mention_read.rs index 1bbef99ae..6f7b71105 100644 --- a/crates/api/api/src/local_user/notifications/mark_comment_mention_read.rs +++ b/crates/api/api/src/local_user/notifications/mark_comment_mention_read.rs @@ -4,9 +4,9 @@ use lemmy_db_schema::{ source::person_comment_mention::{PersonCommentMention, PersonCommentMentionUpdateForm}, traits::Crud, }; -use lemmy_db_views_api_misc::SuccessResponse; use lemmy_db_views_inbox_combined::api::MarkPersonCommentMentionAsRead; use lemmy_db_views_local_user::LocalUserView; +use lemmy_db_views_site::api::SuccessResponse; use lemmy_utils::error::{LemmyErrorType, LemmyResult}; pub async fn mark_comment_mention_as_read( diff --git a/crates/api/api/src/local_user/notifications/mark_post_mention_read.rs b/crates/api/api/src/local_user/notifications/mark_post_mention_read.rs index 810c78868..9e0dafaf4 100644 --- a/crates/api/api/src/local_user/notifications/mark_post_mention_read.rs +++ b/crates/api/api/src/local_user/notifications/mark_post_mention_read.rs @@ -4,9 +4,9 @@ use lemmy_db_schema::{ source::person_post_mention::{PersonPostMention, PersonPostMentionUpdateForm}, traits::Crud, }; -use lemmy_db_views_api_misc::SuccessResponse; use lemmy_db_views_inbox_combined::api::MarkPersonPostMentionAsRead; use lemmy_db_views_local_user::LocalUserView; +use lemmy_db_views_site::api::SuccessResponse; use lemmy_utils::error::{LemmyErrorType, LemmyResult}; pub async fn mark_post_mention_as_read( diff --git a/crates/api/api/src/local_user/notifications/mark_reply_read.rs b/crates/api/api/src/local_user/notifications/mark_reply_read.rs index a313eb96c..d832f6f48 100644 --- a/crates/api/api/src/local_user/notifications/mark_reply_read.rs +++ b/crates/api/api/src/local_user/notifications/mark_reply_read.rs @@ -4,9 +4,9 @@ use lemmy_db_schema::{ source::comment_reply::{CommentReply, CommentReplyUpdateForm}, traits::Crud, }; -use lemmy_db_views_api_misc::SuccessResponse; use lemmy_db_views_inbox_combined::api::MarkCommentReplyAsRead; use lemmy_db_views_local_user::LocalUserView; +use lemmy_db_views_site::api::SuccessResponse; use lemmy_utils::error::{LemmyErrorType, LemmyResult}; pub async fn mark_reply_as_read( diff --git a/crates/api/api/src/local_user/resend_verification_email.rs b/crates/api/api/src/local_user/resend_verification_email.rs index 8d8f96f94..7536c44b5 100644 --- a/crates/api/api/src/local_user/resend_verification_email.rs +++ b/crates/api/api/src/local_user/resend_verification_email.rs @@ -1,8 +1,10 @@ use actix_web::web::{Data, Json}; use lemmy_api_utils::context::LemmyContext; -use lemmy_db_views_api_misc::{ResendVerificationEmail, SuccessResponse}; use lemmy_db_views_local_user::LocalUserView; -use lemmy_db_views_site::SiteView; +use lemmy_db_views_site::{ + api::{ResendVerificationEmail, SuccessResponse}, + SiteView, +}; use lemmy_email::account::send_verification_email_if_required; use lemmy_utils::error::LemmyResult; diff --git a/crates/api/api/src/local_user/reset_password.rs b/crates/api/api/src/local_user/reset_password.rs index 88f440a63..380de735e 100644 --- a/crates/api/api/src/local_user/reset_password.rs +++ b/crates/api/api/src/local_user/reset_password.rs @@ -1,8 +1,10 @@ use actix_web::web::{Data, Json}; use lemmy_api_utils::{context::LemmyContext, utils::check_email_verified}; -use lemmy_db_views_api_misc::{PasswordReset, SuccessResponse}; use lemmy_db_views_local_user::LocalUserView; -use lemmy_db_views_site::SiteView; +use lemmy_db_views_site::{ + api::{PasswordReset, SuccessResponse}, + SiteView, +}; use lemmy_email::account::send_password_reset_email; use lemmy_utils::error::LemmyResult; use tracing::error; diff --git a/crates/api/api/src/local_user/save_settings.rs b/crates/api/api/src/local_user/save_settings.rs index 7f8800d51..9b314c7a8 100644 --- a/crates/api/api/src/local_user/save_settings.rs +++ b/crates/api/api/src/local_user/save_settings.rs @@ -14,9 +14,11 @@ use lemmy_db_schema::{ traits::Crud, utils::{diesel_opt_number_update, diesel_string_update}, }; -use lemmy_db_views_api_misc::{SaveUserSettings, SuccessResponse}; use lemmy_db_views_local_user::LocalUserView; -use lemmy_db_views_site::SiteView; +use lemmy_db_views_site::{ + api::{SaveUserSettings, SuccessResponse}, + SiteView, +}; use lemmy_email::account::send_verification_email; use lemmy_utils::{ error::{LemmyErrorType, LemmyResult}, diff --git a/crates/api/api/src/local_user/update_totp.rs b/crates/api/api/src/local_user/update_totp.rs index a2f0e7d24..8408461a2 100644 --- a/crates/api/api/src/local_user/update_totp.rs +++ b/crates/api/api/src/local_user/update_totp.rs @@ -2,8 +2,8 @@ use crate::check_totp_2fa_valid; use actix_web::web::{Data, Json}; use lemmy_api_utils::context::LemmyContext; use lemmy_db_schema::source::local_user::{LocalUser, LocalUserUpdateForm}; -use lemmy_db_views_api_misc::{UpdateTotp, UpdateTotpResponse}; use lemmy_db_views_local_user::LocalUserView; +use lemmy_db_views_site::api::{UpdateTotp, UpdateTotpResponse}; use lemmy_utils::error::LemmyResult; /// Enable or disable two-factor-authentication. The current setting is determined from diff --git a/crates/api/api/src/local_user/user_block_instance.rs b/crates/api/api/src/local_user/user_block_instance.rs index 93b905c96..c753e18cd 100644 --- a/crates/api/api/src/local_user/user_block_instance.rs +++ b/crates/api/api/src/local_user/user_block_instance.rs @@ -5,8 +5,8 @@ use lemmy_db_schema::{ source::instance::{InstanceActions, InstanceBlockForm}, traits::Blockable, }; -use lemmy_db_views_api_misc::{SuccessResponse, UserBlockInstanceParams}; use lemmy_db_views_local_user::LocalUserView; +use lemmy_db_views_site::api::{SuccessResponse, UserBlockInstanceParams}; use lemmy_utils::error::{LemmyErrorType, LemmyResult}; pub async fn user_block_instance( diff --git a/crates/api/api/src/local_user/validate_auth.rs b/crates/api/api/src/local_user/validate_auth.rs index c2fc043c2..b9c9963a0 100644 --- a/crates/api/api/src/local_user/validate_auth.rs +++ b/crates/api/api/src/local_user/validate_auth.rs @@ -6,7 +6,7 @@ use lemmy_api_utils::{ context::LemmyContext, utils::{local_user_view_from_jwt, read_auth_token}, }; -use lemmy_db_views_api_misc::SuccessResponse; +use lemmy_db_views_site::api::SuccessResponse; use lemmy_utils::error::{LemmyErrorType, LemmyResult}; /// Returns an error message if the auth token is invalid for any reason. Necessary because other diff --git a/crates/api/api/src/local_user/verify_email.rs b/crates/api/api/src/local_user/verify_email.rs index b72973077..d5f0ea8ac 100644 --- a/crates/api/api/src/local_user/verify_email.rs +++ b/crates/api/api/src/local_user/verify_email.rs @@ -4,9 +4,11 @@ use lemmy_db_schema::source::{ email_verification::EmailVerification, local_user::{LocalUser, LocalUserUpdateForm}, }; -use lemmy_db_views_api_misc::{SuccessResponse, VerifyEmail}; use lemmy_db_views_local_user::LocalUserView; -use lemmy_db_views_site::SiteView; +use lemmy_db_views_site::{ + api::{SuccessResponse, VerifyEmail}, + SiteView, +}; use lemmy_email::{account::send_email_verified_email, admin::send_new_applicant_email_to_admins}; use lemmy_utils::error::LemmyResult; diff --git a/crates/api/api/src/post/mark_many_read.rs b/crates/api/api/src/post/mark_many_read.rs index 009c39f69..e3301975c 100644 --- a/crates/api/api/src/post/mark_many_read.rs +++ b/crates/api/api/src/post/mark_many_read.rs @@ -1,9 +1,9 @@ use actix_web::web::{Data, Json}; use lemmy_api_utils::context::LemmyContext; use lemmy_db_schema::{source::post::PostActions, traits::Readable}; -use lemmy_db_views_api_misc::SuccessResponse; use lemmy_db_views_local_user::LocalUserView; use lemmy_db_views_post::api::MarkManyPostsAsRead; +use lemmy_db_views_site::api::SuccessResponse; use lemmy_utils::error::{LemmyErrorType, LemmyResult, MAX_API_PARAM_ELEMENTS}; pub async fn mark_posts_as_read( diff --git a/crates/api/api/src/private_message/mark_read.rs b/crates/api/api/src/private_message/mark_read.rs index 6aa509560..194b043c8 100644 --- a/crates/api/api/src/private_message/mark_read.rs +++ b/crates/api/api/src/private_message/mark_read.rs @@ -4,9 +4,9 @@ use lemmy_db_schema::{ source::private_message::{PrivateMessage, PrivateMessageUpdateForm}, traits::Crud, }; -use lemmy_db_views_api_misc::SuccessResponse; use lemmy_db_views_inbox_combined::api::MarkPrivateMessageAsRead; use lemmy_db_views_local_user::LocalUserView; +use lemmy_db_views_site::api::SuccessResponse; use lemmy_utils::error::{LemmyErrorType, LemmyResult}; pub async fn mark_pm_as_read( diff --git a/crates/api/api/src/site/admin_allow_instance.rs b/crates/api/api/src/site/admin_allow_instance.rs index f59b7a5d4..38ec5c076 100644 --- a/crates/api/api/src/site/admin_allow_instance.rs +++ b/crates/api/api/src/site/admin_allow_instance.rs @@ -9,9 +9,8 @@ use lemmy_db_schema::{ }, traits::Crud, }; -use lemmy_db_views_api_misc::SuccessResponse; use lemmy_db_views_local_user::LocalUserView; -use lemmy_db_views_site::api::AdminAllowInstanceParams; +use lemmy_db_views_site::api::{AdminAllowInstanceParams, SuccessResponse}; use lemmy_utils::error::{LemmyErrorType, LemmyResult}; pub async fn admin_allow_instance( diff --git a/crates/api/api/src/site/admin_block_instance.rs b/crates/api/api/src/site/admin_block_instance.rs index ad5895436..e3bbd4adc 100644 --- a/crates/api/api/src/site/admin_block_instance.rs +++ b/crates/api/api/src/site/admin_block_instance.rs @@ -9,9 +9,8 @@ use lemmy_db_schema::{ }, traits::Crud, }; -use lemmy_db_views_api_misc::SuccessResponse; use lemmy_db_views_local_user::LocalUserView; -use lemmy_db_views_site::api::AdminBlockInstanceParams; +use lemmy_db_views_site::api::{AdminBlockInstanceParams, SuccessResponse}; use lemmy_utils::error::{LemmyErrorType, LemmyResult}; pub async fn admin_block_instance( diff --git a/crates/api/api/src/site/purge/comment.rs b/crates/api/api/src/site/purge/comment.rs index 3674b9ed9..a1e7e2357 100644 --- a/crates/api/api/src/site/purge/comment.rs +++ b/crates/api/api/src/site/purge/comment.rs @@ -13,9 +13,9 @@ use lemmy_db_schema::{ }, traits::Crud, }; -use lemmy_db_views_api_misc::SuccessResponse; use lemmy_db_views_comment::{api::PurgeComment, CommentView}; use lemmy_db_views_local_user::LocalUserView; +use lemmy_db_views_site::api::SuccessResponse; use lemmy_utils::error::LemmyResult; pub async fn purge_comment( diff --git a/crates/api/api/src/site/purge/community.rs b/crates/api/api/src/site/purge/community.rs index 52ee08b5b..4f4b89ebb 100644 --- a/crates/api/api/src/site/purge/community.rs +++ b/crates/api/api/src/site/purge/community.rs @@ -14,10 +14,10 @@ use lemmy_db_schema::{ }, traits::Crud, }; -use lemmy_db_views_api_misc::SuccessResponse; use lemmy_db_views_community::api::PurgeCommunity; use lemmy_db_views_community_moderator::CommunityModeratorView; use lemmy_db_views_local_user::LocalUserView; +use lemmy_db_views_site::api::SuccessResponse; use lemmy_utils::error::LemmyResult; pub async fn purge_community( diff --git a/crates/api/api/src/site/purge/person.rs b/crates/api/api/src/site/purge/person.rs index 5b04eb9a1..feb052662 100644 --- a/crates/api/api/src/site/purge/person.rs +++ b/crates/api/api/src/site/purge/person.rs @@ -14,9 +14,9 @@ use lemmy_db_schema::{ }, traits::{Bannable, Crud}, }; -use lemmy_db_views_api_misc::SuccessResponse; use lemmy_db_views_local_user::LocalUserView; use lemmy_db_views_person::api::PurgePerson; +use lemmy_db_views_site::api::SuccessResponse; use lemmy_utils::error::LemmyResult; pub async fn purge_person( diff --git a/crates/api/api/src/site/purge/post.rs b/crates/api/api/src/site/purge/post.rs index 99ddd608a..28c348fdd 100644 --- a/crates/api/api/src/site/purge/post.rs +++ b/crates/api/api/src/site/purge/post.rs @@ -13,9 +13,9 @@ use lemmy_db_schema::{ }, traits::Crud, }; -use lemmy_db_views_api_misc::SuccessResponse; use lemmy_db_views_local_user::LocalUserView; use lemmy_db_views_post::api::PurgePost; +use lemmy_db_views_site::api::SuccessResponse; use lemmy_utils::error::LemmyResult; pub async fn purge_post( diff --git a/crates/api/api_common/Cargo.toml b/crates/api/api_common/Cargo.toml index ba8de2bcd..819c7a6f0 100644 --- a/crates/api/api_common/Cargo.toml +++ b/crates/api/api_common/Cargo.toml @@ -18,40 +18,38 @@ doctest = false workspace = true [features] -full = [ - "lemmy_utils/full", - "lemmy_db_schema/full", - "lemmy_db_schema_file/full", - "lemmy_db_views_api_misc/full", - "lemmy_db_views_comment/full", - "lemmy_db_views_community/full", - "lemmy_db_views_community_follower/full", - "lemmy_db_views_community_moderator/full", - "lemmy_db_views_custom_emoji/full", - "lemmy_db_views_inbox_combined/full", - "lemmy_db_views_local_image/full", - "lemmy_db_views_local_user/full", - "lemmy_db_views_modlog_combined/full", - "lemmy_db_views_person/full", - "lemmy_db_views_person_content_combined/full", - "lemmy_db_views_person_liked_combined/full", - "lemmy_db_views_person_saved_combined/full", - "lemmy_db_views_post/full", - "lemmy_db_views_private_message/full", - "lemmy_db_views_readable_federation_state/full", - "lemmy_db_views_registration_applications/full", - "lemmy_db_views_report_combined/full", - "lemmy_db_views_reports/full", - "lemmy_db_views_search_combined/full", - "lemmy_db_views_site/full", - "lemmy_db_views_vote/full", +ts-rs = [ + "lemmy_utils/ts-rs", + "lemmy_db_schema/ts-rs", + "lemmy_db_schema_file/ts-rs", + "lemmy_db_views_comment/ts-rs", + "lemmy_db_views_community/ts-rs", + "lemmy_db_views_community_follower/ts-rs", + "lemmy_db_views_community_moderator/ts-rs", + "lemmy_db_views_custom_emoji/ts-rs", + "lemmy_db_views_inbox_combined/ts-rs", + "lemmy_db_views_local_image/ts-rs", + "lemmy_db_views_local_user/ts-rs", + "lemmy_db_views_modlog_combined/ts-rs", + "lemmy_db_views_person/ts-rs", + "lemmy_db_views_person_content_combined/ts-rs", + "lemmy_db_views_person_liked_combined/ts-rs", + "lemmy_db_views_person_saved_combined/ts-rs", + "lemmy_db_views_post/ts-rs", + "lemmy_db_views_private_message/ts-rs", + "lemmy_db_views_readable_federation_state/ts-rs", + "lemmy_db_views_registration_applications/ts-rs", + "lemmy_db_views_report_combined/ts-rs", + "lemmy_db_views_reports/ts-rs", + "lemmy_db_views_search_combined/ts-rs", + "lemmy_db_views_site/ts-rs", + "lemmy_db_views_vote/ts-rs", ] [dependencies] lemmy_utils.workspace = true lemmy_db_schema.workspace = true lemmy_db_schema_file.workspace = true -lemmy_db_views_api_misc.workspace = true lemmy_db_views_comment.workspace = true lemmy_db_views_community.workspace = true lemmy_db_views_community_follower.workspace = true diff --git a/crates/api/api_common/src/account.rs b/crates/api/api_common/src/account.rs index c000d9322..43feee62c 100644 --- a/crates/api/api_common/src/account.rs +++ b/crates/api/api_common/src/account.rs @@ -1,12 +1,3 @@ -pub use lemmy_db_views_api_misc::{ - DeleteAccount, - ListPersonHidden, - ListPersonHiddenResponse, - ListPersonRead, - ListPersonReadResponse, - MyUserInfo, - SaveUserSettings, -}; pub use lemmy_db_views_person_liked_combined::{ ListPersonLiked, ListPersonLikedResponse, @@ -17,10 +8,20 @@ pub use lemmy_db_views_person_saved_combined::{ ListPersonSavedResponse, PersonSavedCombinedView, }; +pub use lemmy_db_views_site::api::{ + DeleteAccount, + ListPersonHidden, + ListPersonHiddenResponse, + ListPersonRead, + ListPersonReadResponse, + MyUserInfo, + SaveUserSettings, +}; pub mod auth { pub use lemmy_db_schema::source::login_token::LoginToken; - pub use lemmy_db_views_api_misc::{ + pub use lemmy_db_views_registration_applications::api::Register; + pub use lemmy_db_views_site::api::{ CaptchaResponse, ChangePassword, GenerateTotpSecretResponse, @@ -35,5 +36,4 @@ pub mod auth { UpdateTotpResponse, VerifyEmail, }; - pub use lemmy_db_views_registration_applications::api::Register; } diff --git a/crates/api/api_common/src/federation.rs b/crates/api/api_common/src/federation.rs index ace154d43..4dd2f9d26 100644 --- a/crates/api/api_common/src/federation.rs +++ b/crates/api/api_common/src/federation.rs @@ -8,12 +8,13 @@ pub use lemmy_db_schema::{ }, }; pub use lemmy_db_schema_file::enums::FederationMode; -pub use lemmy_db_views_api_misc::{ResolveObject, UserBlockInstanceParams}; pub use lemmy_db_views_readable_federation_state::ReadableFederationState; pub use lemmy_db_views_site::api::{ FederatedInstances, GetFederatedInstancesResponse, InstanceWithFederationState, + ResolveObject, + UserBlockInstanceParams, }; pub mod administration { diff --git a/crates/api/api_common/src/lib.rs b/crates/api/api_common/src/lib.rs index 26498ff26..21c017a5a 100644 --- a/crates/api/api_common/src/lib.rs +++ b/crates/api/api_common/src/lib.rs @@ -20,5 +20,5 @@ pub mod tagline; pub use lemmy_db_schema::{newtypes::DbUrl, sensitive::SensitiveString}; pub use lemmy_db_schema_file::enums::VoteShow; -pub use lemmy_db_views_api_misc::SuccessResponse; +pub use lemmy_db_views_site::api::SuccessResponse; pub use lemmy_db_views_vote::VoteView; diff --git a/crates/api/api_common/src/person.rs b/crates/api/api_common/src/person.rs index 0460dfd99..d52e6d8e8 100644 --- a/crates/api/api_common/src/person.rs +++ b/crates/api/api_common/src/person.rs @@ -14,7 +14,7 @@ pub use lemmy_db_views_person::{ pub mod actions { pub use lemmy_db_schema::newtypes::PersonContentCombinedId; - pub use lemmy_db_views_person::api::{BlockPerson, BlockPersonResponse}; + pub use lemmy_db_views_person::api::{BlockPerson, BlockPersonResponse, NotePerson}; pub use lemmy_db_views_person_content_combined::{ ListPersonContent, ListPersonContentResponse, diff --git a/crates/api/api_common/src/plugin.rs b/crates/api/api_common/src/plugin.rs index 35efa7936..818940ab5 100644 --- a/crates/api/api_common/src/plugin.rs +++ b/crates/api/api_common/src/plugin.rs @@ -1 +1 @@ -pub use lemmy_db_views_api_misc::PluginMetadata; +pub use lemmy_db_views_site::api::PluginMetadata; diff --git a/crates/api/api_common/src/tagline.rs b/crates/api/api_common/src/tagline.rs index 9b836c4ff..a9ee9eb0b 100644 --- a/crates/api/api_common/src/tagline.rs +++ b/crates/api/api_common/src/tagline.rs @@ -2,5 +2,5 @@ pub use lemmy_db_schema::{newtypes::TaglineId, source::tagline::Tagline}; pub use lemmy_db_views_site::api::{ListTaglines, ListTaglinesResponse, TaglineResponse}; pub mod aministration { - pub use lemmy_db_views_site::api::{CreateSite, DeleteTagline, UpdateTagline}; + pub use lemmy_db_views_site::api::{CreateTagline, DeleteTagline, UpdateTagline}; } diff --git a/crates/api/api_crud/Cargo.toml b/crates/api/api_crud/Cargo.toml index e13f183c9..5b2e87283 100644 --- a/crates/api/api_crud/Cargo.toml +++ b/crates/api/api_crud/Cargo.toml @@ -14,7 +14,6 @@ rust-version.workspace = true workspace = true [dependencies] -lemmy_db_views_api_misc = { workspace = true, features = ["full"] } lemmy_db_views_comment = { workspace = true, features = ["full"] } lemmy_db_views_community = { workspace = true, features = ["full"] } lemmy_db_views_community_moderator = { workspace = true, features = ["full"] } diff --git a/crates/api/api_crud/src/custom_emoji/delete.rs b/crates/api/api_crud/src/custom_emoji/delete.rs index 79aa88907..a59e98946 100644 --- a/crates/api/api_crud/src/custom_emoji/delete.rs +++ b/crates/api/api_crud/src/custom_emoji/delete.rs @@ -2,9 +2,9 @@ use activitypub_federation::config::Data; use actix_web::web::Json; use lemmy_api_utils::{context::LemmyContext, utils::is_admin}; use lemmy_db_schema::{source::custom_emoji::CustomEmoji, traits::Crud}; -use lemmy_db_views_api_misc::SuccessResponse; use lemmy_db_views_custom_emoji::api::DeleteCustomEmoji; use lemmy_db_views_local_user::LocalUserView; +use lemmy_db_views_site::api::SuccessResponse; use lemmy_utils::error::LemmyResult; pub async fn delete_custom_emoji( diff --git a/crates/api/api_crud/src/oauth_provider/delete.rs b/crates/api/api_crud/src/oauth_provider/delete.rs index 7458b5db4..0bd04dcc8 100644 --- a/crates/api/api_crud/src/oauth_provider/delete.rs +++ b/crates/api/api_crud/src/oauth_provider/delete.rs @@ -2,9 +2,8 @@ use activitypub_federation::config::Data; use actix_web::web::Json; use lemmy_api_utils::{context::LemmyContext, utils::is_admin}; use lemmy_db_schema::{source::oauth_provider::OAuthProvider, traits::Crud}; -use lemmy_db_views_api_misc::SuccessResponse; use lemmy_db_views_local_user::LocalUserView; -use lemmy_db_views_site::api::DeleteOAuthProvider; +use lemmy_db_views_site::api::{DeleteOAuthProvider, SuccessResponse}; use lemmy_utils::error::LemmyError; pub async fn delete_oauth_provider( diff --git a/crates/api/api_crud/src/tagline/create.rs b/crates/api/api_crud/src/tagline/create.rs index 490480136..b048a788c 100644 --- a/crates/api/api_crud/src/tagline/create.rs +++ b/crates/api/api_crud/src/tagline/create.rs @@ -8,9 +8,8 @@ use lemmy_db_schema::{ source::tagline::{Tagline, TaglineInsertForm}, traits::Crud, }; -use lemmy_db_views_api_misc::CreateTagline; use lemmy_db_views_local_user::LocalUserView; -use lemmy_db_views_site::api::TaglineResponse; +use lemmy_db_views_site::api::{CreateTagline, TaglineResponse}; use lemmy_utils::error::LemmyError; pub async fn create_tagline( diff --git a/crates/api/api_crud/src/tagline/delete.rs b/crates/api/api_crud/src/tagline/delete.rs index d351b7443..e3c967990 100644 --- a/crates/api/api_crud/src/tagline/delete.rs +++ b/crates/api/api_crud/src/tagline/delete.rs @@ -2,9 +2,8 @@ use activitypub_federation::config::Data; use actix_web::web::Json; use lemmy_api_utils::{context::LemmyContext, utils::is_admin}; use lemmy_db_schema::{source::tagline::Tagline, traits::Crud}; -use lemmy_db_views_api_misc::SuccessResponse; use lemmy_db_views_local_user::LocalUserView; -use lemmy_db_views_site::api::DeleteTagline; +use lemmy_db_views_site::api::{DeleteTagline, SuccessResponse}; use lemmy_utils::error::LemmyError; pub async fn delete_tagline( diff --git a/crates/api/api_crud/src/user/create.rs b/crates/api/api_crud/src/user/create.rs index bc575fcfb..28715a5f5 100644 --- a/crates/api/api_crud/src/user/create.rs +++ b/crates/api/api_crud/src/user/create.rs @@ -31,10 +31,12 @@ use lemmy_db_schema::{ utils::get_conn, }; use lemmy_db_schema_file::enums::RegistrationMode; -use lemmy_db_views_api_misc::LoginResponse; use lemmy_db_views_local_user::LocalUserView; use lemmy_db_views_registration_applications::api::Register; -use lemmy_db_views_site::{api::AuthenticateWithOauth, SiteView}; +use lemmy_db_views_site::{ + api::{AuthenticateWithOauth, LoginResponse}, + SiteView, +}; use lemmy_email::{ account::send_verification_email_if_required, admin::send_new_applicant_email_to_admins, diff --git a/crates/api/api_crud/src/user/delete.rs b/crates/api/api_crud/src/user/delete.rs index 5dbf3288a..012cf05a0 100644 --- a/crates/api/api_crud/src/user/delete.rs +++ b/crates/api/api_crud/src/user/delete.rs @@ -12,8 +12,8 @@ use lemmy_db_schema::source::{ oauth_account::OAuthAccount, person::Person, }; -use lemmy_db_views_api_misc::{DeleteAccount, SuccessResponse}; use lemmy_db_views_local_user::LocalUserView; +use lemmy_db_views_site::api::{DeleteAccount, SuccessResponse}; use lemmy_utils::error::{LemmyErrorType, LemmyResult}; pub async fn delete_account( diff --git a/crates/api/api_crud/src/user/my_user.rs b/crates/api/api_crud/src/user/my_user.rs index bc8cdf533..4f29ec407 100644 --- a/crates/api/api_crud/src/user/my_user.rs +++ b/crates/api/api_crud/src/user/my_user.rs @@ -10,10 +10,10 @@ use lemmy_db_schema::{ }, traits::Blockable, }; -use lemmy_db_views_api_misc::MyUserInfo; use lemmy_db_views_community_follower::CommunityFollowerView; use lemmy_db_views_community_moderator::CommunityModeratorView; use lemmy_db_views_local_user::LocalUserView; +use lemmy_db_views_site::api::MyUserInfo; use lemmy_utils::error::LemmyResult; pub async fn get_my_user( diff --git a/crates/api/api_utils/Cargo.toml b/crates/api/api_utils/Cargo.toml index 696072b7c..332761158 100644 --- a/crates/api/api_utils/Cargo.toml +++ b/crates/api/api_utils/Cargo.toml @@ -20,7 +20,6 @@ workspace = true [dependencies] lemmy_db_schema = { workspace = true } lemmy_db_schema_file = { workspace = true } -lemmy_db_views_api_misc = { workspace = true } lemmy_db_views_community = { workspace = true } lemmy_db_views_community_follower = { workspace = true } lemmy_db_views_community_moderator = { workspace = true } diff --git a/crates/api/api_utils/src/plugins.rs b/crates/api/api_utils/src/plugins.rs index 0c1831c37..0cf6e718d 100644 --- a/crates/api/api_utils/src/plugins.rs +++ b/crates/api/api_utils/src/plugins.rs @@ -1,7 +1,7 @@ use anyhow::anyhow; use extism::{Manifest, PluginBuilder, Pool, PoolPlugin}; use extism_convert::Json; -use lemmy_db_views_api_misc::PluginMetadata; +use lemmy_db_views_site::api::PluginMetadata; use lemmy_utils::{ error::{LemmyError, LemmyErrorType, LemmyResult}, settings::SETTINGS, diff --git a/crates/apub/Cargo.toml b/crates/apub/Cargo.toml index f986da3af..d4583d0ec 100644 --- a/crates/apub/Cargo.toml +++ b/crates/apub/Cargo.toml @@ -19,7 +19,6 @@ doctest = false workspace = true [dependencies] -lemmy_db_views_api_misc = { workspace = true, features = ["full"] } lemmy_db_views_comment = { workspace = true, features = ["full"] } lemmy_db_views_community = { workspace = true, features = ["full"] } lemmy_db_views_community_moderator = { workspace = true, features = ["full"] } diff --git a/crates/apub/src/api/resolve_object.rs b/crates/apub/src/api/resolve_object.rs index cd891ab10..b03a54abb 100644 --- a/crates/apub/src/api/resolve_object.rs +++ b/crates/apub/src/api/resolve_object.rs @@ -3,14 +3,13 @@ use activitypub_federation::config::Data; use actix_web::web::{Json, Query}; use either::Either::*; use lemmy_api_utils::{context::LemmyContext, utils::check_private_instance}; -use lemmy_db_views_api_misc::ResolveObject; use lemmy_db_views_comment::CommentView; use lemmy_db_views_community::CommunityView; use lemmy_db_views_local_user::LocalUserView; use lemmy_db_views_person::PersonView; use lemmy_db_views_post::PostView; use lemmy_db_views_search_combined::{SearchCombinedView, SearchResponse}; -use lemmy_db_views_site::SiteView; +use lemmy_db_views_site::{api::ResolveObject, SiteView}; use lemmy_utils::error::{LemmyErrorExt2, LemmyErrorType, LemmyResult}; pub async fn resolve_object( diff --git a/crates/apub/src/api/user_settings_backup.rs b/crates/apub/src/api/user_settings_backup.rs index 44b41dc8a..10c90fea6 100644 --- a/crates/apub/src/api/user_settings_backup.rs +++ b/crates/apub/src/api/user_settings_backup.rs @@ -22,8 +22,8 @@ use lemmy_db_schema::{ traits::{Blockable, Crud, Followable, Saveable}, }; use lemmy_db_schema_file::enums::CommunityFollowerState; -use lemmy_db_views_api_misc::SuccessResponse; use lemmy_db_views_local_user::LocalUserView; +use lemmy_db_views_site::api::SuccessResponse; use lemmy_utils::{ error::{LemmyErrorType, LemmyResult, MAX_API_PARAM_ELEMENTS}, spawn_try_task, diff --git a/crates/db_views/api_misc/Cargo.toml b/crates/db_views/api_misc/Cargo.toml deleted file mode 100644 index 65ef48c0b..000000000 --- a/crates/db_views/api_misc/Cargo.toml +++ /dev/null @@ -1,43 +0,0 @@ -[package] -name = "lemmy_db_views_api_misc" -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_db_schema_file/full", - "lemmy_db_views_community_follower/full", - "lemmy_db_views_community_moderator/full", - "lemmy_db_views_local_user/full", - "lemmy_db_views_post/full", - "lemmy_db_views_post/full", - "extism", - "extism-convert", -] -ts-rs = ["dep:ts-rs"] - -[dependencies] -lemmy_db_schema.workspace = true -lemmy_db_schema_file.workspace = true -lemmy_db_views_community_follower.workspace = true -lemmy_db_views_community_moderator.workspace = true -lemmy_db_views_local_user.workspace = true -lemmy_db_views_post.workspace = true -serde.workspace = true -serde_with.workspace = true -url.workspace = true -ts-rs = { workspace = true, optional = true } -extism = { workspace = true, optional = true } -extism-convert = { workspace = true, optional = true } diff --git a/crates/db_views/api_misc/src/lib.rs b/crates/db_views/api_misc/src/lib.rs deleted file mode 100644 index c8e807d12..000000000 --- a/crates/db_views/api_misc/src/lib.rs +++ /dev/null @@ -1,352 +0,0 @@ -use lemmy_db_schema::{ - newtypes::{InstanceId, LanguageId, PaginationCursor, PersonId}, - sensitive::SensitiveString, - source::{community::Community, instance::Instance, login_token::LoginToken, person::Person}, -}; -use lemmy_db_schema_file::enums::{ - CommentSortType, - ListingType, - PostListingMode, - PostSortType, - VoteShow, -}; -use lemmy_db_views_community_follower::CommunityFollowerView; -use lemmy_db_views_community_moderator::CommunityModeratorView; -use lemmy_db_views_local_user::LocalUserView; -use lemmy_db_views_post::PostView; -use serde::{Deserialize, Serialize}; -use serde_with::skip_serializing_none; -use url::Url; -#[cfg(feature = "full")] -use { - extism::FromBytes, - extism_convert::{encoding, Json}, -}; - -#[derive(Debug, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// A captcha response. -pub struct CaptchaResponse { - /// A Base64 encoded png - pub png: String, - /// A Base64 encoded wav audio - pub wav: String, - /// The UUID for the captcha item. - pub uuid: String, -} - -#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// Changes your account password. -pub struct ChangePassword { - pub new_password: SensitiveString, - pub new_password_verify: SensitiveString, - pub old_password: SensitiveString, -} - -#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// Create a tagline -pub struct CreateTagline { - pub content: String, -} - -#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// Delete your account. -pub struct DeleteAccount { - pub password: SensitiveString, - pub delete_content: bool, -} - -#[skip_serializing_none] -#[derive(Debug, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// A wrapper for the captcha response. -pub struct GetCaptchaResponse { - /// Will be None if captchas are disabled. - pub ok: Option, -} - -#[derive(Debug, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -pub struct GenerateTotpSecretResponse { - pub totp_secret_url: SensitiveString, -} - -#[derive(Debug, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -pub struct ListLoginsResponse { - pub logins: Vec, -} - -#[skip_serializing_none] -#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// Gets your hidden posts. -pub struct ListPersonHidden { - pub page_cursor: Option, - pub page_back: Option, - pub limit: Option, -} - -#[skip_serializing_none] -#[derive(Debug, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// You hidden posts response. -pub struct ListPersonHiddenResponse { - pub hidden: Vec, - /// the pagination cursor to use to fetch the next page - pub next_page: Option, - pub prev_page: Option, -} - -#[skip_serializing_none] -#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// Gets your read posts. -pub struct ListPersonRead { - pub page_cursor: Option, - pub page_back: Option, - pub limit: Option, -} - -#[skip_serializing_none] -#[derive(Debug, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// You read posts response. -pub struct ListPersonReadResponse { - pub read: Vec, - /// the pagination cursor to use to fetch the next page - pub next_page: Option, - pub prev_page: Option, -} - -#[skip_serializing_none] -#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// Logging into lemmy. -/// -/// Note: Banned users can still log in, to be able to do certain things like delete -/// their account. -pub struct Login { - pub username_or_email: SensitiveString, - pub password: SensitiveString, - /// May be required, if totp is enabled for their account. - pub totp_2fa_token: Option, -} - -#[skip_serializing_none] -#[derive(Debug, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// A response for your login. -pub struct LoginResponse { - /// This is None in response to `Register` if email verification is enabled, or the server - /// requires registration applications. - pub jwt: Option, - /// If registration applications are required, this will return true for a signup response. - pub registration_created: bool, - /// If email verifications are required, this will return true for a signup response. - pub verify_email_sent: bool, -} - -#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// Make a note for a person. -/// -/// An empty string deletes the note. -pub struct NotePerson { - pub person_id: PersonId, - pub note: String, -} - -#[derive(Debug, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// Your user info. -pub struct MyUserInfo { - pub local_user_view: LocalUserView, - pub follows: Vec, - pub moderates: Vec, - pub community_blocks: Vec, - pub instance_blocks: Vec, - pub person_blocks: Vec, - pub keyword_blocks: Vec, - pub discussion_languages: Vec, -} - -#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// Change your password after receiving a reset request. -pub struct PasswordChangeAfterReset { - pub token: SensitiveString, - pub password: SensitiveString, - pub password_verify: SensitiveString, -} - -#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// Reset your password via email. -pub struct PasswordReset { - pub email: SensitiveString, -} - -#[derive(Serialize, Deserialize, Debug, Clone)] -#[cfg_attr(feature = "full", derive(FromBytes))] -#[cfg_attr(feature = "full", encoding(Json))] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -pub struct PluginMetadata { - name: String, - url: Url, - description: String, -} - -#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// Make a request to resend your verification email. -pub struct ResendVerificationEmail { - pub email: SensitiveString, -} - -#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// Does an apub fetch for an object. -pub struct ResolveObject { - /// Can be the full url, or a shortened version like: !fediverse@lemmy.ml - pub q: String, -} - -#[skip_serializing_none] -#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// Saves settings for your user. -pub struct SaveUserSettings { - /// Show nsfw posts. - pub show_nsfw: Option, - /// Blur nsfw posts. - pub blur_nsfw: Option, - /// Your user's theme. - pub theme: Option, - /// The default post listing type, usually "local" - pub default_listing_type: Option, - /// A post-view mode that changes how multiple post listings look. - pub post_listing_mode: Option, - /// The default post sort, usually "active" - pub default_post_sort_type: Option, - /// A default time range limit to apply to post sorts, in seconds. 0 means none. - pub default_post_time_range_seconds: Option, - /// The default comment sort, usually "hot" - pub default_comment_sort_type: Option, - /// The language of the lemmy interface - pub interface_language: Option, - /// Your display name, which can contain strange characters, and does not need to be unique. - pub display_name: Option, - /// Your email. - pub email: Option, - /// Your bio / info, in markdown. - pub bio: Option, - /// Your matrix user id. Ex: @my_user:matrix.org - pub matrix_user_id: Option, - /// Whether to show or hide avatars. - pub show_avatars: Option, - /// Sends notifications to your email. - pub send_notifications_to_email: Option, - /// Whether this account is a bot account. Users can hide these accounts easily if they wish. - pub bot_account: Option, - /// Whether to show bot accounts. - pub show_bot_accounts: Option, - /// Whether to show read posts. - pub show_read_posts: Option, - /// A list of languages you are able to see discussion in. - pub discussion_languages: Option>, - // A list of keywords used for blocking posts having them in title,url or body. - pub blocking_keywords: Option>, - /// Open links in a new tab - pub open_links_in_new_tab: Option, - /// Enable infinite scroll - pub infinite_scroll_enabled: Option, - /// Whether to allow keyboard navigation (for browsing and interacting with posts and comments). - pub enable_keyboard_navigation: Option, - /// Whether user avatars or inline images in the UI that are gifs should be allowed to play or - /// should be paused - pub enable_animated_images: Option, - /// Whether a user can send / receive private messages - pub enable_private_messages: Option, - /// Whether to auto-collapse bot comments. - pub collapse_bot_comments: Option, - /// Some vote display mode settings - pub show_scores: Option, - pub show_upvotes: Option, - pub show_downvotes: Option, - pub show_upvote_percentage: Option, - /// Whether to automatically mark fetched posts as read. - pub auto_mark_fetched_posts_as_read: Option, - /// Whether to hide posts containing images/videos. - pub hide_media: Option, -} - -#[derive(Debug, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// A response that completes successfully. -pub struct SuccessResponse { - pub success: bool, -} - -impl Default for SuccessResponse { - fn default() -> Self { - SuccessResponse { success: true } - } -} - -#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -pub struct UpdateTotp { - pub totp_token: String, - pub enabled: bool, -} - -#[derive(Debug, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -pub struct UpdateTotpResponse { - pub enabled: bool, -} - -#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// Block an instance as user -pub struct UserBlockInstanceParams { - pub instance_id: InstanceId, - pub block: bool, -} - -#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// Verify your email. -pub struct VerifyEmail { - pub token: String, -} diff --git a/crates/db_views/comment/Cargo.toml b/crates/db_views/comment/Cargo.toml index 24e55c228..c9937e8a0 100644 --- a/crates/db_views/comment/Cargo.toml +++ b/crates/db_views/comment/Cargo.toml @@ -26,7 +26,12 @@ full = [ "lemmy_db_schema_file/full", "lemmy_db_views_vote/full", ] -ts-rs = ["dep:ts-rs"] +ts-rs = [ + "dep:ts-rs", + "lemmy_db_schema/ts-rs", + "lemmy_db_schema_file/ts-rs", + "lemmy_db_views_vote/ts-rs", +] [dependencies] lemmy_db_schema = { workspace = true } diff --git a/crates/db_views/community/Cargo.toml b/crates/db_views/community/Cargo.toml index eb32fa083..7fe6f9f54 100644 --- a/crates/db_views/community/Cargo.toml +++ b/crates/db_views/community/Cargo.toml @@ -26,7 +26,13 @@ full = [ "lemmy_db_views_community_moderator/full", "lemmy_db_views_person/full", ] -ts-rs = ["dep:ts-rs"] +ts-rs = [ + "dep:ts-rs", + "lemmy_db_schema/ts-rs", + "lemmy_db_schema_file/ts-rs", + "lemmy_db_views_community_moderator/ts-rs", + "lemmy_db_views_person/ts-rs", +] [dependencies] lemmy_db_schema = { workspace = true } diff --git a/crates/db_views/community_follower/Cargo.toml b/crates/db_views/community_follower/Cargo.toml index 68673bfa4..8b4283d55 100644 --- a/crates/db_views/community_follower/Cargo.toml +++ b/crates/db_views/community_follower/Cargo.toml @@ -24,7 +24,7 @@ full = [ "lemmy_db_schema/full", "lemmy_db_schema_file/full", ] -ts-rs = ["dep:ts-rs"] +ts-rs = ["dep:ts-rs", "lemmy_db_schema/ts-rs", "lemmy_db_schema_file/ts-rs"] [dependencies] lemmy_db_schema = { workspace = true } diff --git a/crates/db_views/community_moderator/Cargo.toml b/crates/db_views/community_moderator/Cargo.toml index 528bd1a30..df77abeb7 100644 --- a/crates/db_views/community_moderator/Cargo.toml +++ b/crates/db_views/community_moderator/Cargo.toml @@ -23,7 +23,7 @@ full = [ "lemmy_db_schema/full", "lemmy_db_schema_file/full", ] -ts-rs = ["dep:ts-rs"] +ts-rs = ["dep:ts-rs", "lemmy_db_schema/ts-rs"] [dependencies] lemmy_db_schema = { workspace = true } diff --git a/crates/db_views/custom_emoji/Cargo.toml b/crates/db_views/custom_emoji/Cargo.toml index eafe42acd..b2b5ece8b 100644 --- a/crates/db_views/custom_emoji/Cargo.toml +++ b/crates/db_views/custom_emoji/Cargo.toml @@ -23,7 +23,7 @@ full = [ "lemmy_db_schema/full", "lemmy_db_schema_file/full", ] -ts-rs = ["dep:ts-rs"] +ts-rs = ["dep:ts-rs", "lemmy_db_schema/ts-rs"] [dependencies] lemmy_db_schema = { workspace = true } diff --git a/crates/db_views/inbox_combined/Cargo.toml b/crates/db_views/inbox_combined/Cargo.toml index 67acaf061..6d801f5d1 100644 --- a/crates/db_views/inbox_combined/Cargo.toml +++ b/crates/db_views/inbox_combined/Cargo.toml @@ -23,8 +23,13 @@ full = [ "i-love-jesus", "lemmy_db_schema/full", "lemmy_db_schema_file/full", + "lemmy_db_views_private_message/full", +] +ts-rs = [ + "dep:ts-rs", + "lemmy_db_schema/ts-rs", + "lemmy_db_views_private_message/ts-rs", ] -ts-rs = ["dep:ts-rs"] [dependencies] lemmy_db_views_private_message = { workspace = true } diff --git a/crates/db_views/local_image/Cargo.toml b/crates/db_views/local_image/Cargo.toml index f632502f1..1f91f365f 100644 --- a/crates/db_views/local_image/Cargo.toml +++ b/crates/db_views/local_image/Cargo.toml @@ -24,7 +24,7 @@ full = [ "lemmy_db_schema/full", "lemmy_db_schema_file/full", ] -ts-rs = ["dep:ts-rs"] +ts-rs = ["dep:ts-rs", "lemmy_db_schema/ts-rs"] [dependencies] lemmy_db_schema = { workspace = true } diff --git a/crates/db_views/local_user/Cargo.toml b/crates/db_views/local_user/Cargo.toml index a8d24de77..214be75d9 100644 --- a/crates/db_views/local_user/Cargo.toml +++ b/crates/db_views/local_user/Cargo.toml @@ -25,7 +25,7 @@ full = [ "lemmy_db_schema_file/full", "i-love-jesus", ] -ts-rs = ["dep:ts-rs"] +ts-rs = ["dep:ts-rs", "lemmy_db_schema/ts-rs"] [dependencies] lemmy_db_schema = { workspace = true } diff --git a/crates/db_views/modlog_combined/Cargo.toml b/crates/db_views/modlog_combined/Cargo.toml index 8482081ed..e59aec95c 100644 --- a/crates/db_views/modlog_combined/Cargo.toml +++ b/crates/db_views/modlog_combined/Cargo.toml @@ -24,7 +24,7 @@ full = [ "lemmy_db_schema/full", "lemmy_db_schema_file/full", ] -ts-rs = ["dep:ts-rs"] +ts-rs = ["dep:ts-rs", "lemmy_db_schema/ts-rs", "lemmy_db_schema_file/ts-rs"] [dependencies] lemmy_db_schema = { workspace = true } diff --git a/crates/db_views/person/Cargo.toml b/crates/db_views/person/Cargo.toml index 6a81b55ca..0477a2662 100644 --- a/crates/db_views/person/Cargo.toml +++ b/crates/db_views/person/Cargo.toml @@ -25,7 +25,11 @@ full = [ "lemmy_db_schema_file/full", "lemmy_db_views_community_moderator/full", ] -ts-rs = ["dep:ts-rs"] +ts-rs = [ + "dep:ts-rs", + "lemmy_db_schema/ts-rs", + "lemmy_db_views_community_moderator/ts-rs", +] [dependencies] lemmy_db_schema = { workspace = true } diff --git a/crates/db_views/person/src/api.rs b/crates/db_views/person/src/api.rs index 24950cf98..48390a036 100644 --- a/crates/db_views/person/src/api.rs +++ b/crates/db_views/person/src/api.rs @@ -99,3 +99,14 @@ pub struct PurgePerson { pub person_id: PersonId, pub reason: Option, } + +#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// Make a note for a person. +/// +/// An empty string deletes the note. +pub struct NotePerson { + pub person_id: PersonId, + pub note: String, +} diff --git a/crates/db_views/person_content_combined/Cargo.toml b/crates/db_views/person_content_combined/Cargo.toml index 8c4b07166..b64698279 100644 --- a/crates/db_views/person_content_combined/Cargo.toml +++ b/crates/db_views/person_content_combined/Cargo.toml @@ -24,7 +24,13 @@ full = [ "lemmy_db_schema/full", "lemmy_db_schema_file/full", ] -ts-rs = ["dep:ts-rs"] +ts-rs = [ + "dep:ts-rs", + "lemmy_db_schema/ts-rs", + "lemmy_db_schema_file/ts-rs", + "lemmy_db_views_post/ts-rs", + "lemmy_db_views_comment/ts-rs", +] [dependencies] lemmy_db_views_post = { workspace = true } diff --git a/crates/db_views/person_liked_combined/Cargo.toml b/crates/db_views/person_liked_combined/Cargo.toml index 1f37032ec..46c0b4811 100644 --- a/crates/db_views/person_liked_combined/Cargo.toml +++ b/crates/db_views/person_liked_combined/Cargo.toml @@ -26,7 +26,12 @@ full = [ "lemmy_db_views_comment/full", "lemmy_db_views_post/full", ] -ts-rs = ["dep:ts-rs"] +ts-rs = [ + "dep:ts-rs", + "lemmy_db_schema/ts-rs", + "lemmy_db_views_comment/ts-rs", + "lemmy_db_views_post/ts-rs", +] [dependencies] lemmy_db_views_post = { workspace = true } diff --git a/crates/db_views/person_saved_combined/Cargo.toml b/crates/db_views/person_saved_combined/Cargo.toml index c73aae73f..9fe1f5170 100644 --- a/crates/db_views/person_saved_combined/Cargo.toml +++ b/crates/db_views/person_saved_combined/Cargo.toml @@ -26,7 +26,12 @@ full = [ "lemmy_db_views_post/full", "lemmy_db_views_comment/full", ] -ts-rs = ["dep:ts-rs"] +ts-rs = [ + "dep:ts-rs", + "lemmy_db_schema/ts-rs", + "lemmy_db_views_post/ts-rs", + "lemmy_db_views_comment/ts-rs", +] [dependencies] lemmy_db_views_post = { workspace = true } diff --git a/crates/db_views/post/Cargo.toml b/crates/db_views/post/Cargo.toml index 39b562e16..9a1755b63 100644 --- a/crates/db_views/post/Cargo.toml +++ b/crates/db_views/post/Cargo.toml @@ -26,7 +26,13 @@ full = [ "lemmy_db_views_community/full", "lemmy_db_views_vote/full", ] -ts-rs = ["dep:ts-rs"] +ts-rs = [ + "dep:ts-rs", + "lemmy_db_schema/ts-rs", + "lemmy_db_schema_file/ts-rs", + "lemmy_db_views_community/ts-rs", + "lemmy_db_views_vote/ts-rs", +] [dependencies] lemmy_db_schema = { workspace = true } diff --git a/crates/db_views/private_message/Cargo.toml b/crates/db_views/private_message/Cargo.toml index faa1a9c86..bee10f5fa 100644 --- a/crates/db_views/private_message/Cargo.toml +++ b/crates/db_views/private_message/Cargo.toml @@ -23,7 +23,7 @@ full = [ "lemmy_db_schema/full", "lemmy_db_schema_file/full", ] -ts-rs = ["dep:ts-rs"] +ts-rs = ["dep:ts-rs", "lemmy_db_schema/ts-rs"] [dependencies] lemmy_db_schema = { workspace = true } diff --git a/crates/db_views/readable_federation_state/Cargo.toml b/crates/db_views/readable_federation_state/Cargo.toml index 9883330ba..e210de701 100644 --- a/crates/db_views/readable_federation_state/Cargo.toml +++ b/crates/db_views/readable_federation_state/Cargo.toml @@ -16,7 +16,7 @@ workspace = true [features] full = ["lemmy_db_schema/full", "lemmy_utils/full"] -ts-rs = ["dep:ts-rs"] +ts-rs = ["dep:ts-rs", "lemmy_db_schema/ts-rs"] [dependencies] lemmy_db_schema = { workspace = true } diff --git a/crates/db_views/registration_applications/Cargo.toml b/crates/db_views/registration_applications/Cargo.toml index 999624408..ac6d14e0e 100644 --- a/crates/db_views/registration_applications/Cargo.toml +++ b/crates/db_views/registration_applications/Cargo.toml @@ -24,7 +24,7 @@ full = [ "lemmy_db_schema/full", "lemmy_db_schema_file/full", ] -ts-rs = ["dep:ts-rs"] +ts-rs = ["dep:ts-rs", "lemmy_db_schema/ts-rs"] [dependencies] lemmy_db_schema = { workspace = true } diff --git a/crates/db_views/report_combined/Cargo.toml b/crates/db_views/report_combined/Cargo.toml index 917c44e58..f055b8034 100644 --- a/crates/db_views/report_combined/Cargo.toml +++ b/crates/db_views/report_combined/Cargo.toml @@ -24,7 +24,7 @@ full = [ "lemmy_db_schema/full", "lemmy_db_schema_file/full", ] -ts-rs = ["dep:ts-rs"] +ts-rs = ["dep:ts-rs", "lemmy_db_schema/ts-rs", "lemmy_db_views_reports/ts-rs"] [dependencies] lemmy_db_views_reports = { workspace = true } diff --git a/crates/db_views/reports/Cargo.toml b/crates/db_views/reports/Cargo.toml index 8d3bec64b..eda556bc9 100644 --- a/crates/db_views/reports/Cargo.toml +++ b/crates/db_views/reports/Cargo.toml @@ -23,7 +23,7 @@ full = [ "lemmy_db_schema/full", "lemmy_db_schema_file/full", ] -ts-rs = ["dep:ts-rs"] +ts-rs = ["dep:ts-rs", "lemmy_db_schema/ts-rs"] [dependencies] lemmy_db_schema = { workspace = true } diff --git a/crates/db_views/search_combined/Cargo.toml b/crates/db_views/search_combined/Cargo.toml index 9f39aeac3..da7bbe36c 100644 --- a/crates/db_views/search_combined/Cargo.toml +++ b/crates/db_views/search_combined/Cargo.toml @@ -28,7 +28,15 @@ full = [ "lemmy_db_views_community/full", "lemmy_db_views_person/full", ] -ts-rs = ["dep:ts-rs"] +ts-rs = [ + "dep:ts-rs", + "lemmy_db_schema/ts-rs", + "lemmy_db_schema_file/ts-rs", + "lemmy_db_views_comment/ts-rs", + "lemmy_db_views_community/ts-rs", + "lemmy_db_views_person/ts-rs", + "lemmy_db_views_post/ts-rs", +] [dependencies] lemmy_db_views_post = { workspace = true } diff --git a/crates/db_views/site/Cargo.toml b/crates/db_views/site/Cargo.toml index 6873a913f..84a234fc0 100644 --- a/crates/db_views/site/Cargo.toml +++ b/crates/db_views/site/Cargo.toml @@ -22,19 +22,34 @@ full = [ "diesel-async", "lemmy_db_schema/full", "lemmy_db_schema_file/full", - "lemmy_db_views_api_misc/full", "lemmy_db_views_person/full", + "lemmy_db_views_post/full", "lemmy_db_views_readable_federation_state/full", + "extism", + "extism-convert", "anyhow", ] -ts-rs = ["dep:ts-rs"] +ts-rs = [ + "dep:ts-rs", + "lemmy_db_schema/ts-rs", + "lemmy_db_schema_file/ts-rs", + "lemmy_db_views_community_follower/ts-rs", + "lemmy_db_views_community_moderator/ts-rs", + "lemmy_db_views_local_user/ts-rs", + "lemmy_db_views_person/ts-rs", + "lemmy_db_views_post/ts-rs", + "lemmy_db_views_readable_federation_state/ts-rs", +] [dependencies] lemmy_db_schema = { workspace = true } lemmy_utils = { workspace = true, optional = true } lemmy_db_schema_file = { workspace = true } -lemmy_db_views_api_misc = { workspace = true } +lemmy_db_views_community_follower = { workspace = true } +lemmy_db_views_community_moderator = { workspace = true } +lemmy_db_views_local_user = { workspace = true } lemmy_db_views_person = { workspace = true } +lemmy_db_views_post = { workspace = true } lemmy_db_views_readable_federation_state = { workspace = true } chrono = { workspace = true } diesel = { workspace = true, optional = true } @@ -43,4 +58,6 @@ serde = { workspace = true } serde_with = { workspace = true } ts-rs = { workspace = true, optional = true } url = { workspace = true } +extism = { workspace = true, optional = true } +extism-convert = { workspace = true, optional = true } anyhow = { workspace = true, optional = true } diff --git a/crates/db_views/site/src/api.rs b/crates/db_views/site/src/api.rs index 8e8517f85..eaddef6b3 100644 --- a/crates/db_views/site/src/api.rs +++ b/crates/db_views/site/src/api.rs @@ -1,12 +1,16 @@ use crate::SiteView; use chrono::{DateTime, Utc}; use lemmy_db_schema::{ - newtypes::{LanguageId, OAuthProviderId, PaginationCursor, TaglineId}, + newtypes::{InstanceId, LanguageId, OAuthProviderId, PaginationCursor, TaglineId}, + sensitive::SensitiveString, source::{ + community::Community, instance::Instance, language::Language, local_site_url_blocklist::LocalSiteUrlBlocklist, + login_token::LoginToken, oauth_provider::{OAuthProvider, PublicOAuthProvider}, + person::Person, tagline::Tagline, }, }; @@ -17,13 +21,22 @@ use lemmy_db_schema_file::enums::{ PostListingMode, PostSortType, RegistrationMode, + VoteShow, }; -use lemmy_db_views_api_misc::PluginMetadata; +use lemmy_db_views_community_follower::CommunityFollowerView; +use lemmy_db_views_community_moderator::CommunityModeratorView; +use lemmy_db_views_local_user::LocalUserView; use lemmy_db_views_person::PersonView; +use lemmy_db_views_post::PostView; use lemmy_db_views_readable_federation_state::ReadableFederationState; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; use url::Url; +#[cfg(feature = "full")] +use { + extism::FromBytes, + extism_convert::{encoding, Json}, +}; #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] @@ -140,14 +153,6 @@ pub struct DeleteOAuthProvider { pub id: OAuthProviderId, } -#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// Delete a tagline -pub struct DeleteTagline { - pub id: TaglineId, -} - #[skip_serializing_none] #[derive(Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] @@ -312,6 +317,305 @@ pub struct InstanceWithFederationState { pub federation_state: Option, } +#[derive(Debug, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// The response for a site. +pub struct SiteResponse { + pub site_view: SiteView, +} + +#[derive(Debug, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// A captcha response. +pub struct CaptchaResponse { + /// A Base64 encoded png + pub png: String, + /// A Base64 encoded wav audio + pub wav: String, + /// The UUID for the captcha item. + pub uuid: String, +} + +#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// Changes your account password. +pub struct ChangePassword { + pub new_password: SensitiveString, + pub new_password_verify: SensitiveString, + pub old_password: SensitiveString, +} + +#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// Delete your account. +pub struct DeleteAccount { + pub password: SensitiveString, + pub delete_content: bool, +} + +#[skip_serializing_none] +#[derive(Debug, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// A wrapper for the captcha response. +pub struct GetCaptchaResponse { + /// Will be None if captchas are disabled. + pub ok: Option, +} + +#[derive(Debug, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +pub struct GenerateTotpSecretResponse { + pub totp_secret_url: SensitiveString, +} + +#[derive(Debug, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +pub struct ListLoginsResponse { + pub logins: Vec, +} + +#[skip_serializing_none] +#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// Logging into lemmy. +/// +/// Note: Banned users can still log in, to be able to do certain things like delete +/// their account. +pub struct Login { + pub username_or_email: SensitiveString, + pub password: SensitiveString, + /// May be required, if totp is enabled for their account. + pub totp_2fa_token: Option, +} + +#[skip_serializing_none] +#[derive(Debug, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// A response for your login. +pub struct LoginResponse { + /// This is None in response to `Register` if email verification is enabled, or the server + /// requires registration applications. + pub jwt: Option, + /// If registration applications are required, this will return true for a signup response. + pub registration_created: bool, + /// If email verifications are required, this will return true for a signup response. + pub verify_email_sent: bool, +} + +#[derive(Debug, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// Your user info. +pub struct MyUserInfo { + pub local_user_view: LocalUserView, + pub follows: Vec, + pub moderates: Vec, + pub community_blocks: Vec, + pub instance_blocks: Vec, + pub person_blocks: Vec, + pub keyword_blocks: Vec, + pub discussion_languages: Vec, +} + +#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// Change your password after receiving a reset request. +pub struct PasswordChangeAfterReset { + pub token: SensitiveString, + pub password: SensitiveString, + pub password_verify: SensitiveString, +} + +#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// Reset your password via email. +pub struct PasswordReset { + pub email: SensitiveString, +} + +#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// Make a request to resend your verification email. +pub struct ResendVerificationEmail { + pub email: SensitiveString, +} + +#[skip_serializing_none] +#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// Saves settings for your user. +pub struct SaveUserSettings { + /// Show nsfw posts. + pub show_nsfw: Option, + /// Blur nsfw posts. + pub blur_nsfw: Option, + /// Your user's theme. + pub theme: Option, + /// The default post listing type, usually "local" + pub default_listing_type: Option, + /// A post-view mode that changes how multiple post listings look. + pub post_listing_mode: Option, + /// The default post sort, usually "active" + pub default_post_sort_type: Option, + /// A default time range limit to apply to post sorts, in seconds. 0 means none. + pub default_post_time_range_seconds: Option, + /// The default comment sort, usually "hot" + pub default_comment_sort_type: Option, + /// The language of the lemmy interface + pub interface_language: Option, + /// Your display name, which can contain strange characters, and does not need to be unique. + pub display_name: Option, + /// Your email. + pub email: Option, + /// Your bio / info, in markdown. + pub bio: Option, + /// Your matrix user id. Ex: @my_user:matrix.org + pub matrix_user_id: Option, + /// Whether to show or hide avatars. + pub show_avatars: Option, + /// Sends notifications to your email. + pub send_notifications_to_email: Option, + /// Whether this account is a bot account. Users can hide these accounts easily if they wish. + pub bot_account: Option, + /// Whether to show bot accounts. + pub show_bot_accounts: Option, + /// Whether to show read posts. + pub show_read_posts: Option, + /// A list of languages you are able to see discussion in. + pub discussion_languages: Option>, + // A list of keywords used for blocking posts having them in title,url or body. + pub blocking_keywords: Option>, + /// Open links in a new tab + pub open_links_in_new_tab: Option, + /// Enable infinite scroll + pub infinite_scroll_enabled: Option, + /// Whether to allow keyboard navigation (for browsing and interacting with posts and comments). + pub enable_keyboard_navigation: Option, + /// Whether user avatars or inline images in the UI that are gifs should be allowed to play or + /// should be paused + pub enable_animated_images: Option, + /// Whether a user can send / receive private messages + pub enable_private_messages: Option, + /// Whether to auto-collapse bot comments. + pub collapse_bot_comments: Option, + /// Some vote display mode settings + pub show_scores: Option, + pub show_upvotes: Option, + pub show_downvotes: Option, + pub show_upvote_percentage: Option, + /// Whether to automatically mark fetched posts as read. + pub auto_mark_fetched_posts_as_read: Option, + /// Whether to hide posts containing images/videos. + pub hide_media: Option, +} + +#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +pub struct UpdateTotp { + pub totp_token: String, + pub enabled: bool, +} + +#[derive(Debug, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +pub struct UpdateTotpResponse { + pub enabled: bool, +} + +#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// Block an instance as user +pub struct UserBlockInstanceParams { + pub instance_id: InstanceId, + pub block: bool, +} + +#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// Verify your email. +pub struct VerifyEmail { + pub token: String, +} + +#[skip_serializing_none] +#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// Gets your hidden posts. +pub struct ListPersonHidden { + pub page_cursor: Option, + pub page_back: Option, + pub limit: Option, +} + +#[skip_serializing_none] +#[derive(Debug, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// You hidden posts response. +pub struct ListPersonHiddenResponse { + pub hidden: Vec, + /// the pagination cursor to use to fetch the next page + pub next_page: Option, + pub prev_page: Option, +} + +#[skip_serializing_none] +#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// Gets your read posts. +pub struct ListPersonRead { + pub page_cursor: Option, + pub page_back: Option, + pub limit: Option, +} + +#[skip_serializing_none] +#[derive(Debug, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// You read posts response. +pub struct ListPersonReadResponse { + pub read: Vec, + /// the pagination cursor to use to fetch the next page + pub next_page: Option, + pub prev_page: Option, +} + +#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// Create a tagline +pub struct CreateTagline { + pub content: String, +} + +#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// Delete a tagline +pub struct DeleteTagline { + pub id: TaglineId, +} + #[skip_serializing_none] #[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] @@ -334,14 +638,6 @@ pub struct ListTaglinesResponse { pub prev_page: Option, } -#[derive(Debug, Serialize, Deserialize, Clone)] -#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] -#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] -/// The response for a site. -pub struct SiteResponse { - pub site_view: SiteView, -} - #[derive(Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] #[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] @@ -357,3 +653,37 @@ pub struct UpdateTagline { pub id: TaglineId, pub content: String, } + +#[derive(Serialize, Deserialize, Debug, Clone)] +#[cfg_attr(feature = "full", derive(FromBytes))] +#[cfg_attr(feature = "full", encoding(Json))] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +pub struct PluginMetadata { + name: String, + url: Url, + description: String, +} + +#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// Does an apub fetch for an object. +pub struct ResolveObject { + /// Can be the full url, or a shortened version like: !fediverse@lemmy.ml + pub q: String, +} + +#[derive(Debug, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] +/// A response that completes successfully. +pub struct SuccessResponse { + pub success: bool, +} + +impl Default for SuccessResponse { + fn default() -> Self { + SuccessResponse { success: true } + } +} diff --git a/crates/db_views/vote/Cargo.toml b/crates/db_views/vote/Cargo.toml index 9345b1b1c..43b64b8a3 100644 --- a/crates/db_views/vote/Cargo.toml +++ b/crates/db_views/vote/Cargo.toml @@ -24,7 +24,7 @@ full = [ "lemmy_db_schema/full", "lemmy_db_schema_file/full", ] -ts-rs = ["dep:ts-rs"] +ts-rs = ["dep:ts-rs", "lemmy_db_schema/ts-rs"] [dependencies] lemmy_db_schema = { workspace = true } diff --git a/crates/routes/Cargo.toml b/crates/routes/Cargo.toml index 8b61b1753..fff916852 100644 --- a/crates/routes/Cargo.toml +++ b/crates/routes/Cargo.toml @@ -17,7 +17,6 @@ doctest = false workspace = true [dependencies] -lemmy_db_views_api_misc = { workspace = true, features = ["full"] } lemmy_db_views_community = { workspace = true, features = ["full"] } lemmy_db_views_post = { workspace = true, features = ["full"] } lemmy_db_views_local_image = { workspace = true, features = ["full"] } diff --git a/crates/routes/src/images/delete.rs b/crates/routes/src/images/delete.rs index 8890a3e47..ac613df15 100644 --- a/crates/routes/src/images/delete.rs +++ b/crates/routes/src/images/delete.rs @@ -14,10 +14,10 @@ use lemmy_db_schema::{ }, traits::Crud, }; -use lemmy_db_views_api_misc::SuccessResponse; use lemmy_db_views_community::api::CommunityIdQuery; use lemmy_db_views_local_image::api::DeleteImageParams; use lemmy_db_views_local_user::LocalUserView; +use lemmy_db_views_site::api::SuccessResponse; use lemmy_utils::error::LemmyResult; pub async fn delete_site_icon( diff --git a/crates/routes/src/images/mod.rs b/crates/routes/src/images/mod.rs index fff59e06b..2aaeb86da 100644 --- a/crates/routes/src/images/mod.rs +++ b/crates/routes/src/images/mod.rs @@ -1,6 +1,6 @@ use actix_web::web::*; use lemmy_api_utils::context::LemmyContext; -use lemmy_db_views_api_misc::SuccessResponse; +use lemmy_db_views_site::api::SuccessResponse; use lemmy_utils::error::LemmyResult; pub mod delete;