mirror of
https://github.com/LemmyNet/lemmy.git
synced 2025-09-02 19:23:49 +00:00
Move lemmy_api_common structs to view crates, make a lemmy_api_utils crate (#5735)
* Move EditCommunity * Move more community stuff * Finish moving community related structs to db views * Move comment structs to db views * Move person structs to db views * Forgot to add file to staged changes * Move custom emoji structs to db views * Move post structs to db views * Move private message structs to db views * Finish moving structs out of lemmy_api_common * Re-export post, comment, and community structs from lemmy_api_common * Export person structs from lemmy_api_common * Re-export custom emoji structs * Re-export private message structs * Re-export federation, media, moderation, search, and site structs * Re-export most of everything * Handle re-exports that weren't already covered (except errors) * Add error types, reorganize some more * Another once over to make sure I missed nothing * Finish re-arranging re-exports for draft PR * Update email translations submodule * Ensure that exporting typescript bindings works * Run taplo fmt and cargo fmt * Move API structs into relevantly grouped crates instead of having 1 crate per struct * Fix compilation error * Fix broken cargo shear CI step * fix SuccessResponse::default * set publish false --------- Co-authored-by: Felix Ableitner <me@nutomic.com>
This commit is contained in:
parent
eef8821b42
commit
db44742bbb
301 changed files with 4768 additions and 3900 deletions
1551
Cargo.lock
generated
1551
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
31
Cargo.toml
31
Cargo.toml
|
@ -51,6 +51,7 @@ members = [
|
|||
"crates/db_perf",
|
||||
"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",
|
||||
|
@ -113,32 +114,34 @@ lemmy_apub_objects = { version = "=1.0.0-alpha.5", path = "./crates/apub_objects
|
|||
lemmy_utils = { version = "=1.0.0-alpha.5", path = "./crates/utils", default-features = false }
|
||||
lemmy_db_schema = { version = "=1.0.0-alpha.5", path = "./crates/db_schema" }
|
||||
lemmy_db_schema_file = { version = "=1.0.0-alpha.5", path = "./crates/db_schema_file" }
|
||||
lemmy_api_common = { version = "=1.0.0-alpha.5", path = "./crates/api_common" }
|
||||
lemmy_api_utils = { version = "=1.0.0-alpha.5", path = "./crates/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_private_message = { version = "=1.0.0-alpha.5", path = "./crates/db_views/private_message" }
|
||||
lemmy_db_views_registration_applications = { version = "=1.0.0-alpha.5", path = "./crates/db_views/registration_applications" }
|
||||
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_local_user = { version = "=1.0.0-alpha.5", path = "./crates/db_views/local_user" }
|
||||
lemmy_db_views_person = { version = "=1.0.0-alpha.5", path = "./crates/db_views/person" }
|
||||
lemmy_db_views_custom_emoji = { version = "=1.0.0-alpha.5", path = "./crates/db_views/custom_emoji" }
|
||||
lemmy_db_views_post = { version = "=1.0.0-alpha.5", path = "./crates/db_views/post" }
|
||||
lemmy_db_views_vote = { version = "=1.0.0-alpha.5", path = "./crates/db_views/vote" }
|
||||
lemmy_db_views_community = { version = "=1.0.0-alpha.5", path = "./crates/db_views/community" }
|
||||
lemmy_db_views_community_moderator = { version = "=1.0.0-alpha.5", path = "./crates/db_views/community_moderator" }
|
||||
lemmy_db_views_community_follower = { version = "=1.0.0-alpha.5", path = "./crates/db_views/community_follower" }
|
||||
lemmy_db_views_community_moderator = { version = "=1.0.0-alpha.5", path = "./crates/db_views/community_moderator" }
|
||||
lemmy_db_views_community_person_ban = { version = "=1.0.0-alpha.5", path = "./crates/db_views/community_person_ban" }
|
||||
lemmy_db_views_reports = { version = "=1.0.0-alpha.5", path = "./crates/db_views/reports" }
|
||||
lemmy_db_views_local_image = { version = "=1.0.0-alpha.5", path = "./crates/db_views/local_image" }
|
||||
lemmy_db_views_custom_emoji = { version = "=1.0.0-alpha.5", path = "./crates/db_views/custom_emoji" }
|
||||
lemmy_db_views_inbox_combined = { version = "=1.0.0-alpha.5", path = "./crates/db_views/inbox_combined" }
|
||||
lemmy_db_views_local_image = { version = "=1.0.0-alpha.5", path = "./crates/db_views/local_image" }
|
||||
lemmy_db_views_local_user = { version = "=1.0.0-alpha.5", path = "./crates/db_views/local_user" }
|
||||
lemmy_db_views_modlog_combined = { version = "=1.0.0-alpha.5", path = "./crates/db_views/modlog_combined" }
|
||||
lemmy_db_views_person = { version = "=1.0.0-alpha.5", path = "./crates/db_views/person" }
|
||||
lemmy_db_views_person_content_combined = { version = "=1.0.0-alpha.5", path = "./crates/db_views/person_content_combined" }
|
||||
lemmy_db_views_person_saved_combined = { version = "=1.0.0-alpha.5", path = "./crates/db_views/person_saved_combined" }
|
||||
lemmy_db_views_person_liked_combined = { version = "=1.0.0-alpha.5", path = "./crates/db_views/person_liked_combined" }
|
||||
lemmy_db_views_person_saved_combined = { version = "=1.0.0-alpha.5", path = "./crates/db_views/person_saved_combined" }
|
||||
lemmy_db_views_post = { version = "=1.0.0-alpha.5", path = "./crates/db_views/post" }
|
||||
lemmy_db_views_private_message = { version = "=1.0.0-alpha.5", path = "./crates/db_views/private_message" }
|
||||
lemmy_db_views_readable_federation_state = { version = "=1.0.0-alpha.5", path = "./crates/db_views/readable_federation_state" }
|
||||
lemmy_db_views_registration_applications = { version = "=1.0.0-alpha.5", path = "./crates/db_views/registration_applications" }
|
||||
lemmy_db_views_report_combined = { version = "=1.0.0-alpha.5", path = "./crates/db_views/report_combined" }
|
||||
lemmy_db_views_reports = { version = "=1.0.0-alpha.5", path = "./crates/db_views/reports" }
|
||||
lemmy_db_views_search_combined = { version = "=1.0.0-alpha.5", path = "./crates/db_views/search_combined" }
|
||||
lemmy_db_views_site = { version = "=1.0.0-alpha.5", path = "./crates/db_views/site" }
|
||||
lemmy_db_views_vote = { version = "=1.0.0-alpha.5", path = "./crates/db_views/vote" }
|
||||
activitypub_federation = { version = "0.7.0-beta.1", default-features = false, features = [
|
||||
"actix-web",
|
||||
] }
|
||||
|
@ -172,7 +175,7 @@ reqwest = { version = "0.12.18", default-features = false, features = [
|
|||
"rustls-tls",
|
||||
] }
|
||||
reqwest-middleware = "0.4.2"
|
||||
reqwest-tracing = "0.5.5"
|
||||
reqwest-tracing = "0.5.7"
|
||||
clokwerk = "0.4.0"
|
||||
doku = { version = "0.21.1", features = ["url-2"] }
|
||||
bcrypt = "0.17.0"
|
||||
|
@ -225,7 +228,7 @@ lemmy_apub_objects = { workspace = true }
|
|||
lemmy_utils = { workspace = true }
|
||||
lemmy_db_schema = { workspace = true }
|
||||
lemmy_db_schema_file = { workspace = true }
|
||||
lemmy_api_common = { workspace = true }
|
||||
lemmy_api_utils = { workspace = true }
|
||||
lemmy_routes = { workspace = true }
|
||||
lemmy_federate = { workspace = true }
|
||||
activitypub_federation = { workspace = true }
|
||||
|
|
|
@ -19,6 +19,7 @@ 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"] }
|
||||
|
@ -41,7 +42,7 @@ lemmy_db_views_registration_applications = { workspace = true, features = [
|
|||
] }
|
||||
lemmy_utils = { workspace = true }
|
||||
lemmy_db_schema = { workspace = true, features = ["full"] }
|
||||
lemmy_api_common = { workspace = true, features = ["full"] }
|
||||
lemmy_api_utils = { workspace = true, features = ["full"] }
|
||||
lemmy_db_schema_file = { workspace = true }
|
||||
lemmy_email = { workspace = true }
|
||||
activitypub_federation = { workspace = true }
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use lemmy_api_common::{
|
||||
comment::{CommentResponse, DistinguishComment},
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
utils::{check_community_mod_action, check_community_user_action},
|
||||
|
@ -10,7 +9,10 @@ use lemmy_db_schema::{
|
|||
source::comment::{Comment, CommentUpdateForm},
|
||||
traits::Crud,
|
||||
};
|
||||
use lemmy_db_views_comment::CommentView;
|
||||
use lemmy_db_views_comment::{
|
||||
api::{CommentResponse, DistinguishComment},
|
||||
CommentView,
|
||||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_utils::error::{LemmyErrorType, LemmyResult};
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use lemmy_api_common::{
|
||||
use lemmy_api_utils::{
|
||||
build_response::build_comment_response,
|
||||
comment::{CommentResponse, CreateCommentLike},
|
||||
context::LemmyContext,
|
||||
plugins::{plugin_hook_after, plugin_hook_before},
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
|
@ -16,7 +15,10 @@ use lemmy_db_schema::{
|
|||
},
|
||||
traits::Likeable,
|
||||
};
|
||||
use lemmy_db_views_comment::CommentView;
|
||||
use lemmy_db_views_comment::{
|
||||
api::{CommentResponse, CreateCommentLike},
|
||||
CommentView,
|
||||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_site::SiteView;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
use actix_web::web::{Data, Json, Query};
|
||||
use lemmy_api_common::{
|
||||
comment::{ListCommentLikes, ListCommentLikesResponse},
|
||||
context::LemmyContext,
|
||||
utils::is_mod_or_admin,
|
||||
use lemmy_api_utils::{context::LemmyContext, utils::is_mod_or_admin};
|
||||
use lemmy_db_views_comment::{
|
||||
api::{ListCommentLikes, ListCommentLikesResponse},
|
||||
CommentView,
|
||||
};
|
||||
use lemmy_db_views_comment::CommentView;
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_vote::VoteView;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{
|
||||
comment::{CommentResponse, SaveComment},
|
||||
context::LemmyContext,
|
||||
};
|
||||
use lemmy_api_utils::context::LemmyContext;
|
||||
use lemmy_db_schema::{
|
||||
source::comment::{CommentActions, CommentSavedForm},
|
||||
traits::Saveable,
|
||||
};
|
||||
use lemmy_db_views_comment::CommentView;
|
||||
use lemmy_db_views_comment::{
|
||||
api::{CommentResponse, SaveComment},
|
||||
CommentView,
|
||||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use diesel_async::scoped_futures::ScopedFutureExt;
|
||||
use lemmy_api_common::{
|
||||
community::{AddModToCommunity, AddModToCommunityResponse},
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
utils::check_community_mod_action,
|
||||
|
@ -16,6 +15,7 @@ use lemmy_db_schema::{
|
|||
traits::{Crud, Joinable},
|
||||
utils::get_conn,
|
||||
};
|
||||
use lemmy_db_views_community::api::{AddModToCommunity, AddModToCommunityResponse};
|
||||
use lemmy_db_views_community_moderator::CommunityModeratorView;
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use diesel_async::scoped_futures::ScopedFutureExt;
|
||||
use lemmy_api_common::{
|
||||
community::{BanFromCommunity, BanFromCommunityResponse},
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
utils::{
|
||||
|
@ -20,6 +19,7 @@ use lemmy_db_schema::{
|
|||
traits::{Bannable, Crud, Followable},
|
||||
utils::get_conn,
|
||||
};
|
||||
use lemmy_db_views_community::api::{BanFromCommunity, BanFromCommunityResponse};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_person::PersonView;
|
||||
use lemmy_utils::{error::LemmyResult, utils::validation::is_valid_body_field};
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use diesel_async::scoped_futures::ScopedFutureExt;
|
||||
use lemmy_api_common::{
|
||||
community::{BlockCommunity, BlockCommunityResponse},
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
};
|
||||
|
@ -11,7 +10,10 @@ use lemmy_db_schema::{
|
|||
traits::{Blockable, Followable},
|
||||
utils::get_conn,
|
||||
};
|
||||
use lemmy_db_views_community::CommunityView;
|
||||
use lemmy_db_views_community::{
|
||||
api::{BlockCommunity, BlockCommunityResponse},
|
||||
CommunityView,
|
||||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use lemmy_api_common::{
|
||||
community::{CommunityResponse, FollowCommunity},
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
utils::{check_community_deleted_removed, check_local_user_valid},
|
||||
|
@ -14,7 +13,10 @@ use lemmy_db_schema::{
|
|||
traits::{Crud, Followable},
|
||||
};
|
||||
use lemmy_db_schema_file::enums::{CommunityFollowerState, CommunityVisibility};
|
||||
use lemmy_db_views_community::CommunityView;
|
||||
use lemmy_db_views_community::{
|
||||
api::{CommunityResponse, FollowCommunity},
|
||||
CommunityView,
|
||||
};
|
||||
use lemmy_db_views_community_person_ban::CommunityPersonBanView;
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use lemmy_api_common::{
|
||||
community::ApproveCommunityPendingFollower,
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
utils::is_mod_or_admin,
|
||||
SuccessResponse,
|
||||
};
|
||||
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_utils::error::LemmyResult;
|
||||
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
use actix_web::web::{Data, Json, Query};
|
||||
use lemmy_api_common::{
|
||||
community::{GetCommunityPendingFollowsCount, GetCommunityPendingFollowsCountResponse},
|
||||
context::LemmyContext,
|
||||
utils::is_mod_or_admin,
|
||||
use lemmy_api_utils::{context::LemmyContext, utils::is_mod_or_admin};
|
||||
use lemmy_db_views_community_follower::{
|
||||
api::{GetCommunityPendingFollowsCount, GetCommunityPendingFollowsCountResponse},
|
||||
CommunityFollowerView,
|
||||
};
|
||||
use lemmy_db_views_community_follower::CommunityFollowerView;
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use actix_web::web::{Data, Json, Query};
|
||||
use lemmy_api_common::{
|
||||
community::{ListCommunityPendingFollows, ListCommunityPendingFollowsResponse},
|
||||
context::LemmyContext,
|
||||
utils::check_community_mod_of_any_or_admin_action,
|
||||
};
|
||||
use lemmy_api_utils::{context::LemmyContext, utils::check_community_mod_of_any_or_admin_action};
|
||||
use lemmy_db_schema::traits::PaginationCursorBuilder;
|
||||
use lemmy_db_views_community_follower::{CommunityFollowerView, PendingFollow};
|
||||
use lemmy_db_views_community_follower::{
|
||||
api::{ListCommunityPendingFollows, ListCommunityPendingFollowsResponse},
|
||||
CommunityFollowerView,
|
||||
PendingFollow,
|
||||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::{Json, Query};
|
||||
use lemmy_api_common::{
|
||||
community::{CommunityResponse, GetRandomCommunity},
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
utils::{check_private_instance, is_mod_or_admin_opt},
|
||||
};
|
||||
use lemmy_db_schema::source::{actor_language::CommunityLanguage, community::Community};
|
||||
use lemmy_db_views_community::CommunityView;
|
||||
use lemmy_db_views_community::{
|
||||
api::{CommunityResponse, GetRandomCommunity},
|
||||
CommunityView,
|
||||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_site::SiteView;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use chrono::Utc;
|
||||
use lemmy_api_common::{
|
||||
community::{CreateCommunityTag, DeleteCommunityTag, UpdateCommunityTag},
|
||||
context::LemmyContext,
|
||||
utils::check_community_mod_action,
|
||||
};
|
||||
use lemmy_api_utils::{context::LemmyContext, utils::check_community_mod_action};
|
||||
use lemmy_db_schema::{
|
||||
source::{
|
||||
community::Community,
|
||||
|
@ -13,6 +9,7 @@ use lemmy_db_schema::{
|
|||
},
|
||||
traits::Crud,
|
||||
};
|
||||
use lemmy_db_views_community::api::{CreateCommunityTag, DeleteCommunityTag, UpdateCommunityTag};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_utils::{error::LemmyResult, utils::validation::tag_name_length_check};
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use anyhow::Context;
|
||||
use diesel_async::scoped_futures::ScopedFutureExt;
|
||||
use lemmy_api_common::{
|
||||
community::{GetCommunityResponse, TransferCommunity},
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
utils::{check_community_user_action, is_admin, is_top_mod},
|
||||
};
|
||||
|
@ -14,7 +13,10 @@ use lemmy_db_schema::{
|
|||
traits::{Crud, Joinable},
|
||||
utils::get_conn,
|
||||
};
|
||||
use lemmy_db_views_community::CommunityView;
|
||||
use lemmy_db_views_community::{
|
||||
api::{GetCommunityResponse, TransferCommunity},
|
||||
CommunityView,
|
||||
};
|
||||
use lemmy_db_views_community_moderator::CommunityModeratorView;
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_utils::{
|
||||
|
@ -22,7 +24,7 @@ use lemmy_utils::{
|
|||
location_info,
|
||||
};
|
||||
|
||||
// TODO: we dont do anything for federation here, it should be updated the next time the community
|
||||
// TODO: we don't do anything for federation here, it should be updated the next time the community
|
||||
// gets fetched. i hope we can get rid of the community creator role soon.
|
||||
|
||||
pub async fn transfer_community(
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
person::{AddAdmin, AddAdminResponse},
|
||||
utils::is_admin,
|
||||
};
|
||||
use lemmy_api_utils::{context::LemmyContext, utils::is_admin};
|
||||
use lemmy_db_schema::{
|
||||
source::{
|
||||
local_user::{LocalUser, LocalUserUpdateForm},
|
||||
|
@ -12,7 +8,10 @@ use lemmy_db_schema::{
|
|||
traits::Crud,
|
||||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_person::impls::PersonQuery;
|
||||
use lemmy_db_views_person::{
|
||||
api::{AddAdmin, AddAdminResponse},
|
||||
impls::PersonQuery,
|
||||
};
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
pub async fn add_admin(
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use lemmy_api_common::{
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
person::{BanPerson, BanPersonResponse},
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
utils::{check_expire_time, is_admin, remove_or_restore_user_data},
|
||||
};
|
||||
|
@ -15,7 +14,10 @@ use lemmy_db_schema::{
|
|||
traits::{Bannable, Crud},
|
||||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_person::PersonView;
|
||||
use lemmy_db_views_person::{
|
||||
api::{BanPerson, BanPersonResponse},
|
||||
PersonView,
|
||||
};
|
||||
use lemmy_utils::{error::LemmyResult, utils::validation::is_valid_body_field};
|
||||
|
||||
pub async fn ban_from_site(
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
person::{BlockPerson, BlockPersonResponse},
|
||||
};
|
||||
use lemmy_api_utils::context::LemmyContext;
|
||||
use lemmy_db_schema::{
|
||||
source::person::{PersonActions, PersonBlockForm},
|
||||
traits::Blockable,
|
||||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_person::PersonView;
|
||||
use lemmy_db_views_person::{
|
||||
api::{BlockPerson, BlockPersonResponse},
|
||||
PersonView,
|
||||
};
|
||||
use lemmy_utils::error::{LemmyErrorType, LemmyResult};
|
||||
|
||||
pub async fn user_block_person(
|
||||
|
|
|
@ -3,13 +3,9 @@ use actix_web::{
|
|||
HttpRequest,
|
||||
};
|
||||
use bcrypt::verify;
|
||||
use lemmy_api_common::{
|
||||
claims::Claims,
|
||||
context::LemmyContext,
|
||||
person::{ChangePassword, LoginResponse},
|
||||
utils::password_length_check,
|
||||
};
|
||||
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_utils::error::{LemmyErrorType, LemmyResult};
|
||||
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
person::PasswordChangeAfterReset,
|
||||
utils::password_length_check,
|
||||
SuccessResponse,
|
||||
};
|
||||
use lemmy_api_utils::{context::LemmyContext, utils::password_length_check};
|
||||
use lemmy_db_schema::source::{
|
||||
local_user::LocalUser,
|
||||
login_token::LoginToken,
|
||||
password_reset_request::PasswordResetRequest,
|
||||
};
|
||||
use lemmy_db_views_api_misc::{PasswordChangeAfterReset, SuccessResponse};
|
||||
use lemmy_utils::error::{LemmyErrorType, LemmyResult};
|
||||
|
||||
pub async fn change_password_after_reset(
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use chrono::Utc;
|
||||
use lemmy_api_common::{context::LemmyContext, SuccessResponse};
|
||||
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_utils::error::LemmyResult;
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
use crate::{build_totp_2fa, generate_totp_2fa_secret};
|
||||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use lemmy_api_common::{context::LemmyContext, person::GenerateTotpSecretResponse};
|
||||
use lemmy_api_utils::context::LemmyContext;
|
||||
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_utils::error::{LemmyErrorType, LemmyResult};
|
||||
|
||||
|
|
|
@ -9,14 +9,11 @@ use actix_web::{
|
|||
HttpResponseBuilder,
|
||||
};
|
||||
use captcha::{generate, Difficulty};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
person::{CaptchaResponse, GetCaptchaResponse},
|
||||
LemmyErrorType,
|
||||
};
|
||||
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_utils::error::LemmyResult;
|
||||
use lemmy_utils::error::{LemmyErrorType, LemmyResult};
|
||||
|
||||
pub async fn get_captcha(context: Data<LemmyContext>) -> LemmyResult<HttpResponse> {
|
||||
let local_site = SiteView::read_local(&mut context.pool()).await?.local_site;
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::{Json, Query};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
person::{ListPersonHidden, ListPersonHiddenResponse},
|
||||
};
|
||||
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_utils::error::LemmyResult;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::{Json, Query};
|
||||
use lemmy_api_common::context::LemmyContext;
|
||||
use lemmy_api_utils::context::LemmyContext;
|
||||
use lemmy_db_schema::traits::PaginationCursorBuilder;
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_person_liked_combined::{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{context::LemmyContext, person::ListLoginsResponse};
|
||||
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_utils::error::LemmyResult;
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use actix_web::web::{Data, Json, Query};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
person::{ListMedia, ListMediaResponse},
|
||||
};
|
||||
use lemmy_api_utils::context::LemmyContext;
|
||||
use lemmy_db_schema::traits::PaginationCursorBuilder;
|
||||
use lemmy_db_views_local_image::LocalImageView;
|
||||
use lemmy_db_views_local_image::{
|
||||
api::{ListMedia, ListMediaResponse},
|
||||
LocalImageView,
|
||||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::{Json, Query};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
person::{ListPersonRead, ListPersonReadResponse},
|
||||
};
|
||||
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_utils::error::LemmyResult;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::{Json, Query};
|
||||
use lemmy_api_common::{context::LemmyContext, utils::check_private_instance};
|
||||
use lemmy_api_utils::{context::LemmyContext, utils::check_private_instance};
|
||||
use lemmy_db_schema::traits::PaginationCursorBuilder;
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_person_saved_combined::{
|
||||
|
|
|
@ -4,12 +4,12 @@ use actix_web::{
|
|||
HttpRequest,
|
||||
};
|
||||
use bcrypt::verify;
|
||||
use lemmy_api_common::{
|
||||
use lemmy_api_utils::{
|
||||
claims::Claims,
|
||||
context::LemmyContext,
|
||||
person::{Login, LoginResponse},
|
||||
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_utils::error::{LemmyErrorType, LemmyResult};
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::{cookie::Cookie, HttpRequest, HttpResponse};
|
||||
use lemmy_api_common::{
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
utils::{read_auth_token, AUTH_COOKIE_NAME},
|
||||
SuccessResponse,
|
||||
};
|
||||
use lemmy_db_schema::source::login_token::LoginToken;
|
||||
use lemmy_db_views_api_misc::SuccessResponse;
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_utils::error::{LemmyErrorType, LemmyResult};
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use actix_web::web::{Data, Json, Query};
|
||||
use lemmy_api_common::context::LemmyContext;
|
||||
use lemmy_api_utils::context::LemmyContext;
|
||||
use lemmy_db_schema::traits::PaginationCursorBuilder;
|
||||
use lemmy_db_views_inbox_combined::{
|
||||
impls::InboxCombinedQuery,
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{context::LemmyContext, SuccessResponse};
|
||||
use lemmy_api_utils::context::LemmyContext;
|
||||
use lemmy_db_schema::source::{
|
||||
comment_reply::CommentReply,
|
||||
person_comment_mention::PersonCommentMention,
|
||||
person_post_mention::PersonPostMention,
|
||||
private_message::PrivateMessage,
|
||||
};
|
||||
use lemmy_db_views_api_misc::SuccessResponse;
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
person::MarkPersonCommentMentionAsRead,
|
||||
SuccessResponse,
|
||||
};
|
||||
use lemmy_api_utils::context::LemmyContext;
|
||||
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_utils::error::{LemmyErrorType, LemmyResult};
|
||||
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
person::MarkPersonPostMentionAsRead,
|
||||
SuccessResponse,
|
||||
};
|
||||
use lemmy_api_utils::context::LemmyContext;
|
||||
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_utils::error::{LemmyErrorType, LemmyResult};
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{context::LemmyContext, person::MarkCommentReplyAsRead, SuccessResponse};
|
||||
use lemmy_api_utils::context::LemmyContext;
|
||||
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_utils::error::{LemmyErrorType, LemmyResult};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{context::LemmyContext, person::GetUnreadCountResponse};
|
||||
use lemmy_db_views_inbox_combined::InboxCombinedViewInternal;
|
||||
use lemmy_api_utils::context::LemmyContext;
|
||||
use lemmy_db_views_inbox_combined::{api::GetUnreadCountResponse, InboxCombinedViewInternal};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
use actix_web::web::{Data, Json, Query};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
person::{GetReportCount, GetReportCountResponse},
|
||||
utils::check_community_mod_of_any_or_admin_action,
|
||||
};
|
||||
use lemmy_api_utils::{context::LemmyContext, utils::check_community_mod_of_any_or_admin_action};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_report_combined::ReportCombinedViewInternal;
|
||||
use lemmy_db_views_reports::api::{GetReportCount, GetReportCountResponse};
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
pub async fn report_count(
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{context::LemmyContext, person::ResendVerificationEmail, SuccessResponse};
|
||||
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_email::account::send_verification_email_if_required;
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
person::PasswordReset,
|
||||
utils::check_email_verified,
|
||||
SuccessResponse,
|
||||
};
|
||||
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_email::account::send_password_reset_email;
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use lemmy_api_common::{
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
person::SaveUserSettings,
|
||||
utils::{get_url_blocklist, process_markdown_opt, slur_regex},
|
||||
SuccessResponse,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
source::{
|
||||
|
@ -16,6 +14,7 @@ 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_email::account::send_verification_email;
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
use crate::check_totp_2fa_valid;
|
||||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
person::{UpdateTotp, UpdateTotpResponse},
|
||||
};
|
||||
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_utils::error::LemmyResult;
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use lemmy_api_common::{context::LemmyContext, site::UserBlockInstanceParams, SuccessResponse};
|
||||
use lemmy_api_utils::context::LemmyContext;
|
||||
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_utils::error::{LemmyErrorType, LemmyResult};
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@ use actix_web::{
|
|||
web::{Data, Json},
|
||||
HttpRequest,
|
||||
};
|
||||
use lemmy_api_common::{
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
utils::{local_user_view_from_jwt, read_auth_token},
|
||||
SuccessResponse,
|
||||
};
|
||||
use lemmy_db_views_api_misc::SuccessResponse;
|
||||
use lemmy_utils::error::{LemmyErrorType, LemmyResult};
|
||||
|
||||
/// Returns an error message if the auth token is invalid for any reason. Necessary because other
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{context::LemmyContext, person::VerifyEmail, SuccessResponse};
|
||||
use lemmy_api_utils::context::LemmyContext;
|
||||
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_email::{account::send_email_verified_email, admin::send_new_applicant_email_to_admins};
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use lemmy_api_common::{
|
||||
use lemmy_api_utils::{
|
||||
build_response::build_post_response,
|
||||
context::LemmyContext,
|
||||
post::{FeaturePost, PostResponse},
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
utils::{check_community_mod_action, is_admin},
|
||||
};
|
||||
|
@ -17,6 +16,7 @@ use lemmy_db_schema::{
|
|||
PostFeatureType,
|
||||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_post::api::{FeaturePost, PostResponse};
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
pub async fn feature_post(
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
use actix_web::web::{Data, Json, Query};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
post::{GetSiteMetadata, GetSiteMetadataResponse},
|
||||
request::fetch_link_metadata,
|
||||
};
|
||||
use lemmy_api_utils::{context::LemmyContext, request::fetch_link_metadata};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_post::api::{GetSiteMetadata, GetSiteMetadataResponse};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
use url::Url;
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
post::{HidePost, PostResponse},
|
||||
};
|
||||
use lemmy_api_utils::context::LemmyContext;
|
||||
use lemmy_db_schema::{
|
||||
source::post::{PostActions, PostHideForm},
|
||||
traits::Hideable,
|
||||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_post::PostView;
|
||||
use lemmy_db_views_post::{
|
||||
api::{HidePost, PostResponse},
|
||||
PostView,
|
||||
};
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
pub async fn hide_post(
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use lemmy_api_common::{
|
||||
use lemmy_api_utils::{
|
||||
build_response::build_post_response,
|
||||
context::LemmyContext,
|
||||
plugins::{plugin_hook_after, plugin_hook_before},
|
||||
post::{CreatePostLike, PostResponse},
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
utils::{check_bot_account, check_community_user_action, check_local_vote_mode},
|
||||
};
|
||||
|
@ -14,7 +13,10 @@ use lemmy_db_schema::{
|
|||
traits::{Likeable, Readable},
|
||||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_post::PostView;
|
||||
use lemmy_db_views_post::{
|
||||
api::{CreatePostLike, PostResponse},
|
||||
PostView,
|
||||
};
|
||||
use lemmy_db_views_site::SiteView;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
use std::ops::Deref;
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
use actix_web::web::{Data, Json, Query};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
post::{ListPostLikes, ListPostLikesResponse},
|
||||
utils::is_mod_or_admin,
|
||||
};
|
||||
use lemmy_api_utils::{context::LemmyContext, utils::is_mod_or_admin};
|
||||
use lemmy_db_schema::{source::post::Post, traits::Crud};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_post::api::{ListPostLikes, ListPostLikesResponse};
|
||||
use lemmy_db_views_vote::VoteView;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use lemmy_api_common::{
|
||||
use lemmy_api_utils::{
|
||||
build_response::build_post_response,
|
||||
context::LemmyContext,
|
||||
post::{LockPost, PostResponse},
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
utils::check_community_mod_action,
|
||||
};
|
||||
|
@ -15,7 +14,10 @@ use lemmy_db_schema::{
|
|||
traits::Crud,
|
||||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_post::PostView;
|
||||
use lemmy_db_views_post::{
|
||||
api::{LockPost, PostResponse},
|
||||
PostView,
|
||||
};
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
pub async fn lock_post(
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{context::LemmyContext, post::MarkManyPostsAsRead, SuccessResponse};
|
||||
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_utils::error::{LemmyErrorType, LemmyResult, MAX_API_PARAM_ELEMENTS};
|
||||
|
||||
pub async fn mark_posts_as_read(
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
post::{MarkPostAsRead, PostResponse},
|
||||
};
|
||||
use lemmy_api_utils::context::LemmyContext;
|
||||
use lemmy_db_schema::{
|
||||
source::post::{PostActions, PostReadForm},
|
||||
traits::Readable,
|
||||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_post::PostView;
|
||||
use lemmy_db_views_post::{
|
||||
api::{MarkPostAsRead, PostResponse},
|
||||
PostView,
|
||||
};
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
pub async fn mark_post_as_read(
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
post::{PostResponse, SavePost},
|
||||
};
|
||||
use lemmy_api_utils::context::LemmyContext;
|
||||
use lemmy_db_schema::{
|
||||
source::post::{PostActions, PostReadForm, PostSavedForm},
|
||||
traits::{Readable, Saveable},
|
||||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_post::PostView;
|
||||
use lemmy_db_views_post::{
|
||||
api::{PostResponse, SavePost},
|
||||
PostView,
|
||||
};
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
pub async fn save_post(
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
private_message::MarkPrivateMessageAsRead,
|
||||
SuccessResponse,
|
||||
};
|
||||
use lemmy_api_utils::context::LemmyContext;
|
||||
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_utils::error::{LemmyErrorType, LemmyResult};
|
||||
|
||||
|
|
|
@ -2,9 +2,8 @@ use crate::check_report_reason;
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use either::Either;
|
||||
use lemmy_api_common::{
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
reports::comment::{CommentReportResponse, CreateCommentReport},
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
utils::{check_comment_deleted_or_removed, check_community_user_action, slur_regex},
|
||||
};
|
||||
|
@ -14,7 +13,10 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_db_views_comment::CommentView;
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_reports::CommentReportView;
|
||||
use lemmy_db_views_reports::{
|
||||
api::{CommentReportResponse, CreateCommentReport},
|
||||
CommentReportView,
|
||||
};
|
||||
use lemmy_db_views_site::SiteView;
|
||||
use lemmy_email::admin::send_new_report_email_to_admins;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use either::Either;
|
||||
use lemmy_api_common::{
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
reports::comment::{CommentReportResponse, ResolveCommentReport},
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
utils::check_community_mod_action,
|
||||
};
|
||||
use lemmy_db_schema::{source::comment_report::CommentReport, traits::Reportable};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_reports::CommentReportView;
|
||||
use lemmy_db_views_reports::{
|
||||
api::{CommentReportResponse, ResolveCommentReport},
|
||||
CommentReportView,
|
||||
};
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
/// Resolves or unresolves a comment report and notifies the moderators of the community
|
||||
|
|
|
@ -2,9 +2,8 @@ use crate::check_report_reason;
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use either::Either;
|
||||
use lemmy_api_common::{
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
reports::community::{CommunityReportResponse, CreateCommunityReport},
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
utils::slur_regex,
|
||||
};
|
||||
|
@ -17,7 +16,10 @@ use lemmy_db_schema::{
|
|||
traits::{Crud, Reportable},
|
||||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_reports::CommunityReportView;
|
||||
use lemmy_db_views_reports::{
|
||||
api::{CommunityReportResponse, CreateCommunityReport},
|
||||
CommunityReportView,
|
||||
};
|
||||
use lemmy_db_views_site::SiteView;
|
||||
use lemmy_email::admin::send_new_report_email_to_admins;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use either::Either;
|
||||
use lemmy_api_common::{
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
reports::community::{CommunityReportResponse, ResolveCommunityReport},
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
utils::is_admin,
|
||||
};
|
||||
|
@ -12,7 +11,10 @@ use lemmy_db_schema::{
|
|||
traits::Reportable,
|
||||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_reports::CommunityReportView;
|
||||
use lemmy_db_views_reports::{
|
||||
api::{CommunityReportResponse, ResolveCommunityReport},
|
||||
CommunityReportView,
|
||||
};
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
pub async fn resolve_community_report(
|
||||
|
|
|
@ -2,9 +2,8 @@ use crate::check_report_reason;
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use either::Either;
|
||||
use lemmy_api_common::{
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
reports::post::{CreatePostReport, PostReportResponse},
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
utils::{check_community_user_action, check_post_deleted_or_removed, slur_regex},
|
||||
};
|
||||
|
@ -14,7 +13,10 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_post::PostView;
|
||||
use lemmy_db_views_reports::PostReportView;
|
||||
use lemmy_db_views_reports::{
|
||||
api::{CreatePostReport, PostReportResponse},
|
||||
PostReportView,
|
||||
};
|
||||
use lemmy_db_views_site::SiteView;
|
||||
use lemmy_email::admin::send_new_report_email_to_admins;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use either::Either;
|
||||
use lemmy_api_common::{
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
reports::post::{PostReportResponse, ResolvePostReport},
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
utils::check_community_mod_action,
|
||||
};
|
||||
use lemmy_db_schema::{source::post_report::PostReport, traits::Reportable};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_reports::PostReportView;
|
||||
use lemmy_db_views_reports::{
|
||||
api::{PostReportResponse, ResolvePostReport},
|
||||
PostReportView,
|
||||
};
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
/// Resolves or unresolves a post report and notifies the moderators of the community
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
use crate::check_report_reason;
|
||||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
reports::private_message::{CreatePrivateMessageReport, PrivateMessageReportResponse},
|
||||
utils::slur_regex,
|
||||
};
|
||||
use lemmy_api_utils::{context::LemmyContext, utils::slur_regex};
|
||||
use lemmy_db_schema::{
|
||||
source::{
|
||||
private_message::PrivateMessage,
|
||||
|
@ -13,7 +9,10 @@ use lemmy_db_schema::{
|
|||
traits::{Crud, Reportable},
|
||||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_reports::PrivateMessageReportView;
|
||||
use lemmy_db_views_reports::{
|
||||
api::{CreatePrivateMessageReport, PrivateMessageReportResponse},
|
||||
PrivateMessageReportView,
|
||||
};
|
||||
use lemmy_db_views_site::SiteView;
|
||||
use lemmy_email::admin::send_new_report_email_to_admins;
|
||||
use lemmy_utils::error::{LemmyErrorType, LemmyResult};
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
reports::private_message::{PrivateMessageReportResponse, ResolvePrivateMessageReport},
|
||||
utils::is_admin,
|
||||
};
|
||||
use lemmy_api_utils::{context::LemmyContext, utils::is_admin};
|
||||
use lemmy_db_schema::{source::private_message_report::PrivateMessageReport, traits::Reportable};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_reports::PrivateMessageReportView;
|
||||
use lemmy_db_views_reports::{
|
||||
api::{PrivateMessageReportResponse, ResolvePrivateMessageReport},
|
||||
PrivateMessageReportView,
|
||||
};
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
pub async fn resolve_pm_report(
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use actix_web::web::{Data, Json, Query};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
reports::combined::{ListReports, ListReportsResponse},
|
||||
utils::check_community_mod_of_any_or_admin_action,
|
||||
};
|
||||
use lemmy_api_utils::{context::LemmyContext, utils::check_community_mod_of_any_or_admin_action};
|
||||
use lemmy_db_schema::traits::PaginationCursorBuilder;
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_report_combined::{impls::ReportCombinedQuery, ReportCombinedView};
|
||||
use lemmy_db_views_report_combined::{
|
||||
api::{ListReports, ListReportsResponse},
|
||||
impls::ReportCombinedQuery,
|
||||
ReportCombinedView,
|
||||
};
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
/// Lists reports for a community if an id is supplied
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
site::AdminAllowInstanceParams,
|
||||
utils::is_admin,
|
||||
LemmyErrorType,
|
||||
SuccessResponse,
|
||||
};
|
||||
use lemmy_api_utils::{context::LemmyContext, utils::is_admin};
|
||||
use lemmy_db_schema::{
|
||||
source::{
|
||||
federation_allowlist::{FederationAllowList, FederationAllowListForm},
|
||||
|
@ -15,8 +9,10 @@ use lemmy_db_schema::{
|
|||
},
|
||||
traits::Crud,
|
||||
};
|
||||
use lemmy_db_views_api_misc::SuccessResponse;
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
use lemmy_db_views_site::api::AdminAllowInstanceParams;
|
||||
use lemmy_utils::error::{LemmyErrorType, LemmyResult};
|
||||
|
||||
pub async fn admin_allow_instance(
|
||||
data: Json<AdminAllowInstanceParams>,
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
site::AdminBlockInstanceParams,
|
||||
utils::is_admin,
|
||||
LemmyErrorType,
|
||||
SuccessResponse,
|
||||
};
|
||||
use lemmy_api_utils::{context::LemmyContext, utils::is_admin};
|
||||
use lemmy_db_schema::{
|
||||
source::{
|
||||
federation_blocklist::{FederationBlockList, FederationBlockListForm},
|
||||
|
@ -15,8 +9,10 @@ use lemmy_db_schema::{
|
|||
},
|
||||
traits::Crud,
|
||||
};
|
||||
use lemmy_db_views_api_misc::SuccessResponse;
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
use lemmy_db_views_site::api::AdminBlockInstanceParams;
|
||||
use lemmy_utils::error::{LemmyErrorType, LemmyResult};
|
||||
|
||||
pub async fn admin_block_instance(
|
||||
data: Json<AdminBlockInstanceParams>,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
site::{AdminListUsers, AdminListUsersResponse},
|
||||
utils::is_admin,
|
||||
};
|
||||
use lemmy_api_utils::{context::LemmyContext, utils::is_admin};
|
||||
use lemmy_db_schema::traits::PaginationCursorBuilder;
|
||||
use lemmy_db_views_local_user::{impls::LocalUserQuery, LocalUserView};
|
||||
use lemmy_db_views_local_user::{
|
||||
api::{AdminListUsers, AdminListUsersResponse},
|
||||
impls::LocalUserQuery,
|
||||
LocalUserView,
|
||||
};
|
||||
use lemmy_db_views_person::PersonView;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
site::GetFederatedInstancesResponse,
|
||||
utils::build_federated_instances,
|
||||
};
|
||||
use lemmy_db_views_site::SiteView;
|
||||
use lemmy_api_utils::{context::LemmyContext, utils::build_federated_instances};
|
||||
use lemmy_db_views_site::{api::GetFederatedInstancesResponse, SiteView};
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
pub async fn get_federated_instances(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{context::LemmyContext, site::GetSiteResponse, utils::is_admin};
|
||||
use lemmy_api_utils::{context::LemmyContext, utils::is_admin};
|
||||
use lemmy_db_schema::{
|
||||
source::{
|
||||
actor_language::SiteLanguage,
|
||||
|
@ -14,7 +14,7 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_person::impls::PersonQuery;
|
||||
use lemmy_db_views_site::SiteView;
|
||||
use lemmy_db_views_site::{api::GetSiteResponse, SiteView};
|
||||
use lemmy_utils::{
|
||||
error::{LemmyErrorType, LemmyResult},
|
||||
VERSION,
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
use actix_web::web::{Data, Json, Query};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
person::{ListMedia, ListMediaResponse},
|
||||
utils::is_admin,
|
||||
};
|
||||
use lemmy_api_utils::{context::LemmyContext, utils::is_admin};
|
||||
use lemmy_db_schema::traits::PaginationCursorBuilder;
|
||||
use lemmy_db_views_local_image::LocalImageView;
|
||||
use lemmy_db_views_local_image::{
|
||||
api::{ListMedia, ListMediaResponse},
|
||||
LocalImageView,
|
||||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
use actix_web::web::{Data, Json, Query};
|
||||
use lemmy_api_common::{
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
site::GetModlog,
|
||||
utils::{check_private_instance, is_mod_or_admin_opt},
|
||||
};
|
||||
use lemmy_db_schema::traits::PaginationCursorBuilder;
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_modlog_combined::{
|
||||
api::{GetModlog, GetModlogResponse},
|
||||
impls::ModlogCombinedQuery,
|
||||
GetModlogResponse,
|
||||
ModlogCombinedView,
|
||||
};
|
||||
use lemmy_db_views_site::SiteView;
|
||||
|
@ -85,7 +84,7 @@ pub async fn get_mod_log(
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use lemmy_api_common::utils::remove_or_restore_user_data;
|
||||
use lemmy_api_utils::utils::remove_or_restore_user_data;
|
||||
use lemmy_db_schema::{
|
||||
source::{
|
||||
comment::{Comment, CommentInsertForm},
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use lemmy_api_common::{
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
site::PurgeComment,
|
||||
utils::is_admin,
|
||||
SuccessResponse,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
source::{
|
||||
|
@ -15,7 +13,8 @@ use lemmy_db_schema::{
|
|||
},
|
||||
traits::Crud,
|
||||
};
|
||||
use lemmy_db_views_comment::CommentView;
|
||||
use lemmy_db_views_api_misc::SuccessResponse;
|
||||
use lemmy_db_views_comment::{api::PurgeComment, CommentView};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use lemmy_api_common::{
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
site::PurgeCommunity,
|
||||
utils::is_admin,
|
||||
SuccessResponse,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
newtypes::PersonId,
|
||||
|
@ -16,6 +14,8 @@ 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_utils::error::LemmyResult;
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use lemmy_api_common::{
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
site::PurgePerson,
|
||||
utils::{is_admin, purge_user_account},
|
||||
SuccessResponse,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
source::{
|
||||
|
@ -16,7 +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_utils::error::LemmyResult;
|
||||
|
||||
pub async fn purge_person(
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use lemmy_api_common::{
|
||||
use lemmy_api_utils::{
|
||||
context::LemmyContext,
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
site::PurgePost,
|
||||
utils::{is_admin, purge_post_images},
|
||||
SuccessResponse,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
source::{
|
||||
|
@ -15,7 +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_utils::error::LemmyResult;
|
||||
|
||||
pub async fn purge_post(
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use diesel_async::scoped_futures::ScopedFutureExt;
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
site::{ApproveRegistrationApplication, RegistrationApplicationResponse},
|
||||
utils::is_admin,
|
||||
};
|
||||
use lemmy_api_utils::{context::LemmyContext, utils::is_admin};
|
||||
use lemmy_db_schema::{
|
||||
source::{
|
||||
local_user::{LocalUser, LocalUserUpdateForm},
|
||||
|
@ -15,7 +11,10 @@ use lemmy_db_schema::{
|
|||
utils::{diesel_string_update, get_conn},
|
||||
};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_registration_applications::RegistrationApplicationView;
|
||||
use lemmy_db_views_registration_applications::{
|
||||
api::{ApproveRegistrationApplication, RegistrationApplicationResponse},
|
||||
RegistrationApplicationView,
|
||||
};
|
||||
use lemmy_email::account::{send_application_approved_email, send_application_denied_email};
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
use actix_web::web::{Data, Json, Query};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
site::{GetRegistrationApplication, RegistrationApplicationResponse},
|
||||
utils::is_admin,
|
||||
};
|
||||
use lemmy_api_utils::{context::LemmyContext, utils::is_admin};
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_registration_applications::RegistrationApplicationView;
|
||||
use lemmy_db_views_registration_applications::{
|
||||
api::{GetRegistrationApplication, RegistrationApplicationResponse},
|
||||
RegistrationApplicationView,
|
||||
};
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
/// Lists registration applications, filterable by undenied only.
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::{Json, Query};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
site::{ListRegistrationApplications, ListRegistrationApplicationsResponse},
|
||||
utils::is_admin,
|
||||
};
|
||||
use lemmy_api_utils::{context::LemmyContext, utils::is_admin};
|
||||
use lemmy_db_schema::traits::PaginationCursorBuilder;
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_registration_applications::{
|
||||
api::{ListRegistrationApplications, ListRegistrationApplicationsResponse},
|
||||
impls::RegistrationApplicationQuery,
|
||||
RegistrationApplicationView,
|
||||
};
|
||||
|
|
|
@ -5,16 +5,8 @@ use crate::site::registration_applications::{
|
|||
};
|
||||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::{Json, Query};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
site::{
|
||||
ApproveRegistrationApplication,
|
||||
EditSite,
|
||||
GetUnreadRegistrationApplicationCountResponse,
|
||||
ListRegistrationApplicationsResponse,
|
||||
},
|
||||
};
|
||||
use lemmy_api_crud::site::update::update_site;
|
||||
use lemmy_api_utils::context::LemmyContext;
|
||||
use lemmy_db_schema::{
|
||||
newtypes::InstanceId,
|
||||
source::{
|
||||
|
@ -30,7 +22,13 @@ use lemmy_db_schema::{
|
|||
utils::DbPool,
|
||||
};
|
||||
use lemmy_db_schema_file::enums::RegistrationMode;
|
||||
use lemmy_db_views_inbox_combined::api::GetUnreadRegistrationApplicationCountResponse;
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_registration_applications::api::{
|
||||
ApproveRegistrationApplication,
|
||||
ListRegistrationApplicationsResponse,
|
||||
};
|
||||
use lemmy_db_views_site::api::EditSite;
|
||||
use lemmy_utils::{
|
||||
error::{LemmyErrorType, LemmyResult},
|
||||
CACHE_DURATION_API,
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
site::GetUnreadRegistrationApplicationCountResponse,
|
||||
utils::is_admin,
|
||||
};
|
||||
use lemmy_api_utils::{context::LemmyContext, utils::is_admin};
|
||||
use lemmy_db_views_inbox_combined::api::GetUnreadRegistrationApplicationCountResponse;
|
||||
use lemmy_db_views_local_user::LocalUserView;
|
||||
use lemmy_db_views_registration_applications::RegistrationApplicationView;
|
||||
use lemmy_db_views_site::SiteView;
|
||||
|
|
|
@ -3,7 +3,7 @@ use actix_web::{
|
|||
web::Data,
|
||||
HttpResponse,
|
||||
};
|
||||
use lemmy_api_common::context::LemmyContext;
|
||||
use lemmy_api_utils::context::LemmyContext;
|
||||
use lemmy_db_schema::{newtypes::DbUrl, source::post::Post};
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
use sitemap_rs::{url::Url, url_set::UrlSet};
|
||||
|
|
|
@ -19,102 +19,58 @@ workspace = true
|
|||
|
||||
[features]
|
||||
full = [
|
||||
"tracing",
|
||||
"activitypub_federation",
|
||||
"encoding_rs",
|
||||
"reqwest-middleware",
|
||||
"webpage",
|
||||
"ts-rs",
|
||||
"tokio",
|
||||
"reqwest",
|
||||
"actix-web",
|
||||
"futures",
|
||||
"jsonwebtoken",
|
||||
"mime",
|
||||
"moka",
|
||||
"actix-web-httpauth",
|
||||
"webmention",
|
||||
"extism",
|
||||
"extism-convert",
|
||||
"once_cell",
|
||||
"serde_json",
|
||||
"lemmy_email",
|
||||
"lemmy_utils/full",
|
||||
"lemmy_db_schema/full",
|
||||
"lemmy_db_schema_file/full",
|
||||
"lemmy_utils/full",
|
||||
"lemmy_db_views_api_misc/full",
|
||||
"lemmy_db_views_comment/full",
|
||||
"lemmy_db_views_community/full",
|
||||
"lemmy_db_views_community_moderator/full",
|
||||
"lemmy_db_views_community_follower/full",
|
||||
"lemmy_db_views_community_person_ban/full",
|
||||
"lemmy_db_views_post/full",
|
||||
"lemmy_db_views_vote/full",
|
||||
"lemmy_db_views_local_user/full",
|
||||
"lemmy_db_views_person/full",
|
||||
"lemmy_db_views_community_moderator/full",
|
||||
"lemmy_db_views_custom_emoji/full",
|
||||
"lemmy_db_views_reports/full",
|
||||
"lemmy_db_views_private_message/full",
|
||||
"lemmy_db_views_inbox_combined/full",
|
||||
"lemmy_db_views_local_image/full",
|
||||
"lemmy_db_views_report_combined/full",
|
||||
"lemmy_db_views_site/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",
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
lemmy_db_views_comment = { workspace = true }
|
||||
lemmy_db_views_community = { workspace = true }
|
||||
lemmy_db_views_community_moderator = { workspace = true }
|
||||
lemmy_db_views_community_follower = { workspace = true }
|
||||
lemmy_db_views_community_person_ban = { workspace = true }
|
||||
lemmy_db_views_post = { workspace = true }
|
||||
lemmy_db_views_vote = { workspace = true }
|
||||
lemmy_db_views_local_user = { workspace = true }
|
||||
lemmy_db_views_person = { workspace = true }
|
||||
lemmy_db_views_custom_emoji = { workspace = true }
|
||||
lemmy_db_views_reports = { workspace = true }
|
||||
lemmy_db_views_private_message = { workspace = true }
|
||||
lemmy_db_views_local_image = { workspace = true }
|
||||
lemmy_db_views_report_combined = { workspace = true }
|
||||
lemmy_db_views_site = { workspace = true }
|
||||
lemmy_db_views_registration_applications = { workspace = true }
|
||||
lemmy_db_schema = { workspace = true }
|
||||
lemmy_utils = { workspace = true }
|
||||
lemmy_db_schema_file = { workspace = true }
|
||||
lemmy_email = { workspace = true, optional = true }
|
||||
activitypub_federation = { workspace = true, optional = true }
|
||||
serde = { workspace = true }
|
||||
serde_with = { workspace = true }
|
||||
url = { workspace = true }
|
||||
chrono = { workspace = true }
|
||||
tracing = { workspace = true, optional = true }
|
||||
reqwest-middleware = { workspace = true, optional = true }
|
||||
regex = { workspace = true }
|
||||
futures = { workspace = true, optional = true }
|
||||
tokio = { workspace = true, optional = true }
|
||||
reqwest = { workspace = true, optional = true }
|
||||
ts-rs = { workspace = true, optional = true }
|
||||
moka = { workspace = true, optional = true }
|
||||
anyhow.workspace = true
|
||||
enum-map = { workspace = true }
|
||||
actix-web = { workspace = true, optional = true }
|
||||
urlencoding = { workspace = true }
|
||||
serde_json = { workspace = true, optional = true }
|
||||
mime = { version = "0.3.17", optional = true }
|
||||
mime_guess = "2.0.5"
|
||||
infer = "0.19.0"
|
||||
webpage = { version = "2.0", default-features = false, optional = true, features = [
|
||||
"serde",
|
||||
] }
|
||||
encoding_rs = { version = "0.8.35", optional = true }
|
||||
jsonwebtoken = { version = "9.3.1", optional = true }
|
||||
actix-web-httpauth = { version = "0.8.2", optional = true }
|
||||
webmention = { version = "0.6.0", optional = true }
|
||||
extism = { git = "https://github.com/extism/extism.git", branch = "pool", optional = true }
|
||||
extism-convert = { git = "https://github.com/extism/extism.git", branch = "pool", optional = true }
|
||||
once_cell = { version = "1.21.3", optional = true }
|
||||
either = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
serial_test = { workspace = true }
|
||||
reqwest-middleware = { workspace = true }
|
||||
pretty_assertions = { workspace = true }
|
||||
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
|
||||
lemmy_db_views_community_moderator.workspace = true
|
||||
lemmy_db_views_custom_emoji.workspace = true
|
||||
lemmy_db_views_inbox_combined.workspace = true
|
||||
lemmy_db_views_local_image.workspace = true
|
||||
lemmy_db_views_local_user.workspace = true
|
||||
lemmy_db_views_modlog_combined.workspace = true
|
||||
lemmy_db_views_person.workspace = true
|
||||
lemmy_db_views_person_content_combined.workspace = true
|
||||
lemmy_db_views_person_liked_combined.workspace = true
|
||||
lemmy_db_views_person_saved_combined.workspace = true
|
||||
lemmy_db_views_post.workspace = true
|
||||
lemmy_db_views_private_message.workspace = true
|
||||
lemmy_db_views_readable_federation_state.workspace = true
|
||||
lemmy_db_views_registration_applications.workspace = true
|
||||
lemmy_db_views_report_combined.workspace = true
|
||||
lemmy_db_views_reports.workspace = true
|
||||
lemmy_db_views_search_combined.workspace = true
|
||||
lemmy_db_views_site.workspace = true
|
||||
lemmy_db_views_vote.workspace = true
|
||||
|
|
39
crates/api_common/src/account.rs
Normal file
39
crates/api_common/src/account.rs
Normal file
|
@ -0,0 +1,39 @@
|
|||
pub use lemmy_db_views_api_misc::{
|
||||
DeleteAccount,
|
||||
ListPersonHidden,
|
||||
ListPersonHiddenResponse,
|
||||
ListPersonRead,
|
||||
ListPersonReadResponse,
|
||||
MyUserInfo,
|
||||
SaveUserSettings,
|
||||
};
|
||||
pub use lemmy_db_views_person_liked_combined::{
|
||||
ListPersonLiked,
|
||||
ListPersonLikedResponse,
|
||||
PersonLikedCombinedView,
|
||||
};
|
||||
pub use lemmy_db_views_person_saved_combined::{
|
||||
ListPersonSaved,
|
||||
ListPersonSavedResponse,
|
||||
PersonSavedCombinedView,
|
||||
};
|
||||
|
||||
pub mod auth {
|
||||
pub use lemmy_db_schema::source::login_token::LoginToken;
|
||||
pub use lemmy_db_views_api_misc::{
|
||||
CaptchaResponse,
|
||||
ChangePassword,
|
||||
GenerateTotpSecretResponse,
|
||||
GetCaptchaResponse,
|
||||
ListLoginsResponse,
|
||||
Login,
|
||||
LoginResponse,
|
||||
PasswordChangeAfterReset,
|
||||
PasswordReset,
|
||||
ResendVerificationEmail,
|
||||
UpdateTotp,
|
||||
UpdateTotpResponse,
|
||||
VerifyEmail,
|
||||
};
|
||||
pub use lemmy_db_views_registration_applications::api::Register;
|
||||
}
|
|
@ -1,196 +1,29 @@
|
|||
use lemmy_db_schema::newtypes::{
|
||||
CommentId,
|
||||
CommunityId,
|
||||
LanguageId,
|
||||
LocalUserId,
|
||||
PaginationCursor,
|
||||
PostId,
|
||||
pub use lemmy_db_schema::{
|
||||
newtypes::CommentId,
|
||||
source::comment::{Comment, CommentActions},
|
||||
};
|
||||
pub use lemmy_db_views_comment::{
|
||||
api::{CommentResponse, GetComment, GetComments, GetCommentsResponse, GetCommentsSlimResponse},
|
||||
CommentSlimView,
|
||||
CommentView,
|
||||
};
|
||||
use lemmy_db_schema_file::enums::{CommentSortType, ListingType};
|
||||
use lemmy_db_views_comment::{CommentSlimView, CommentView};
|
||||
use lemmy_db_views_vote::VoteView;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
use ts_rs::TS;
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Create a comment.
|
||||
pub struct CreateComment {
|
||||
pub content: String,
|
||||
pub post_id: PostId,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub parent_id: Option<CommentId>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub language_id: Option<LanguageId>,
|
||||
}
|
||||
pub mod actions {
|
||||
pub use lemmy_db_views_comment::api::{
|
||||
CreateComment,
|
||||
CreateCommentLike,
|
||||
DeleteComment,
|
||||
EditComment,
|
||||
SaveComment,
|
||||
};
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, Copy, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Fetch an individual comment.
|
||||
pub struct GetComment {
|
||||
pub id: CommentId,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Edit a comment.
|
||||
pub struct EditComment {
|
||||
pub comment_id: CommentId,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub content: Option<String>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub language_id: Option<LanguageId>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Distinguish a comment (IE speak as moderator).
|
||||
pub struct DistinguishComment {
|
||||
pub comment_id: CommentId,
|
||||
pub distinguished: bool,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Delete your own comment.
|
||||
pub struct DeleteComment {
|
||||
pub comment_id: CommentId,
|
||||
pub deleted: bool,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Remove a comment (only doable by mods).
|
||||
pub struct RemoveComment {
|
||||
pub comment_id: CommentId,
|
||||
pub removed: bool,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub reason: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Save / bookmark a comment.
|
||||
pub struct SaveComment {
|
||||
pub comment_id: CommentId,
|
||||
pub save: bool,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// A comment response.
|
||||
pub struct CommentResponse {
|
||||
pub comment_view: CommentView,
|
||||
pub recipient_ids: Vec<LocalUserId>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Like a comment.
|
||||
pub struct CreateCommentLike {
|
||||
pub comment_id: CommentId,
|
||||
/// Must be -1, 0, or 1 .
|
||||
pub score: i16,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Get a list of comments.
|
||||
pub struct GetComments {
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub type_: Option<ListingType>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub sort: Option<CommentSortType>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
/// Filter to within a given time range, in seconds.
|
||||
/// IE 60 would give results for the past minute.
|
||||
pub time_range_seconds: Option<i32>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub max_depth: Option<i32>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub page_cursor: Option<PaginationCursor>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub page_back: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub limit: Option<i64>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub community_id: Option<CommunityId>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub community_name: Option<String>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub post_id: Option<PostId>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub parent_id: Option<CommentId>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// The comment list response.
|
||||
pub struct GetCommentsResponse {
|
||||
pub comments: Vec<CommentView>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub next_page: Option<PaginationCursor>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub prev_page: Option<PaginationCursor>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// A slimmer comment list response, without the post or community.
|
||||
pub struct GetCommentsSlimResponse {
|
||||
pub comments: Vec<CommentSlimView>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub next_page: Option<PaginationCursor>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub prev_page: Option<PaginationCursor>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// List comment likes. Admins-only.
|
||||
pub struct ListCommentLikes {
|
||||
pub comment_id: CommentId,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub page_cursor: Option<PaginationCursor>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub page_back: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub limit: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// The comment likes response
|
||||
pub struct ListCommentLikesResponse {
|
||||
pub comment_likes: Vec<VoteView>,
|
||||
/// the pagination cursor to use to fetch the next page
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub next_page: Option<PaginationCursor>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub prev_page: Option<PaginationCursor>,
|
||||
pub mod moderation {
|
||||
pub use lemmy_db_views_comment::api::{
|
||||
DistinguishComment,
|
||||
ListCommentLikes,
|
||||
ListCommentLikesResponse,
|
||||
PurgeComment,
|
||||
RemoveComment,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,364 +1,60 @@
|
|||
use lemmy_db_schema::{
|
||||
newtypes::{CommunityId, LanguageId, PaginationCursor, PersonId, TagId},
|
||||
source::site::Site,
|
||||
CommunitySortType,
|
||||
pub use lemmy_db_schema::{
|
||||
newtypes::{CommunityId, TagId},
|
||||
source::{
|
||||
community::{Community, CommunityActions},
|
||||
tag::{Tag, TagsView},
|
||||
},
|
||||
};
|
||||
use lemmy_db_schema_file::enums::{CommunityVisibility, ListingType};
|
||||
use lemmy_db_views_community::CommunityView;
|
||||
use lemmy_db_views_community_follower::PendingFollow;
|
||||
use lemmy_db_views_community_moderator::CommunityModeratorView;
|
||||
use lemmy_db_views_person::PersonView;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
use ts_rs::TS;
|
||||
pub use lemmy_db_schema_file::enums::CommunityVisibility;
|
||||
pub use lemmy_db_views_community::{
|
||||
api::{
|
||||
CommunityResponse,
|
||||
GetCommunity,
|
||||
GetCommunityResponse,
|
||||
GetRandomCommunity,
|
||||
ListCommunities,
|
||||
ListCommunitiesResponse,
|
||||
},
|
||||
CommunityView,
|
||||
};
|
||||
pub use lemmy_db_views_community_follower::PendingFollow;
|
||||
pub use lemmy_db_views_community_moderator::CommunityModeratorView;
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Create a tag for a community.
|
||||
pub struct CreateCommunityTag {
|
||||
pub community_id: CommunityId,
|
||||
pub display_name: String,
|
||||
}
|
||||
pub mod actions {
|
||||
pub use lemmy_db_views_community::api::{
|
||||
BlockCommunity,
|
||||
BlockCommunityResponse,
|
||||
CreateCommunity,
|
||||
FollowCommunity,
|
||||
HideCommunity,
|
||||
};
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Update a community tag.
|
||||
pub struct UpdateCommunityTag {
|
||||
pub tag_id: TagId,
|
||||
pub display_name: String,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Delete a community tag.
|
||||
pub struct DeleteCommunityTag {
|
||||
pub tag_id: TagId,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
// TODO make this into a tagged enum
|
||||
/// Get a community. Must provide either an id, or a name.
|
||||
pub struct GetCommunity {
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub id: Option<CommunityId>,
|
||||
/// Example: star_trek , or star_trek@xyz.tld
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub name: Option<String>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// The community response.
|
||||
pub struct GetCommunityResponse {
|
||||
pub community_view: CommunityView,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub site: Option<Site>,
|
||||
pub moderators: Vec<CommunityModeratorView>,
|
||||
pub discussion_languages: Vec<LanguageId>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
/// Create a community.
|
||||
pub struct CreateCommunity {
|
||||
/// The unique name.
|
||||
pub name: String,
|
||||
/// A longer title.
|
||||
pub title: String,
|
||||
/// A sidebar for the community in markdown.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub sidebar: Option<String>,
|
||||
/// A shorter, one line description of your community.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub description: Option<String>,
|
||||
/// An icon URL.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub icon: Option<String>,
|
||||
/// A banner URL.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub banner: Option<String>,
|
||||
/// Whether its an NSFW community.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub nsfw: Option<bool>,
|
||||
/// Whether to restrict posting only to moderators.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub posting_restricted_to_mods: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub discussion_languages: Option<Vec<LanguageId>>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub visibility: Option<CommunityVisibility>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// A simple community response.
|
||||
pub struct CommunityResponse {
|
||||
pub community_view: CommunityView,
|
||||
pub discussion_languages: Vec<LanguageId>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Fetches a list of communities.
|
||||
pub struct ListCommunities {
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub type_: Option<ListingType>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub sort: Option<CommunitySortType>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
/// Filter to within a given time range, in seconds.
|
||||
/// IE 60 would give results for the past minute.
|
||||
pub time_range_seconds: Option<i32>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub show_nsfw: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub page_cursor: Option<PaginationCursor>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub page_back: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub limit: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// The response for listing communities.
|
||||
pub struct ListCommunitiesResponse {
|
||||
pub communities: Vec<CommunityView>,
|
||||
/// the pagination cursor to use to fetch the next page
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub next_page: Option<PaginationCursor>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub prev_page: Option<PaginationCursor>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Ban a user from a community.
|
||||
pub struct BanFromCommunity {
|
||||
pub community_id: CommunityId,
|
||||
pub person_id: PersonId,
|
||||
pub ban: bool,
|
||||
/// Optionally remove or restore all their data. Useful for new troll accounts.
|
||||
/// If ban is true, then this means remove. If ban is false, it means restore.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub remove_or_restore_data: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub reason: Option<String>,
|
||||
/// A time that the ban will expire, in unix epoch seconds.
|
||||
///
|
||||
/// An i64 unix timestamp is used for a simpler API client implementation.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub expires: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// The response for banning a user from a community.
|
||||
pub struct BanFromCommunityResponse {
|
||||
pub person_view: PersonView,
|
||||
pub banned: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Add a moderator to a community.
|
||||
pub struct AddModToCommunity {
|
||||
pub community_id: CommunityId,
|
||||
pub person_id: PersonId,
|
||||
pub added: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// The response of adding a moderator to a community.
|
||||
pub struct AddModToCommunityResponse {
|
||||
pub moderators: Vec<CommunityModeratorView>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Edit a community.
|
||||
pub struct EditCommunity {
|
||||
pub community_id: CommunityId,
|
||||
/// A longer title.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub title: Option<String>,
|
||||
/// A sidebar for the community in markdown.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub sidebar: Option<String>,
|
||||
/// A shorter, one line description of your community.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub description: Option<String>,
|
||||
/// Whether its an NSFW community.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub nsfw: Option<bool>,
|
||||
/// Whether to restrict posting only to moderators.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub posting_restricted_to_mods: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub discussion_languages: Option<Vec<LanguageId>>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub visibility: Option<CommunityVisibility>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Hide a community from the main view.
|
||||
pub struct HideCommunity {
|
||||
pub community_id: CommunityId,
|
||||
pub hidden: bool,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub reason: Option<String>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Delete your own community.
|
||||
pub struct DeleteCommunity {
|
||||
pub community_id: CommunityId,
|
||||
pub deleted: bool,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Remove a community (only doable by moderators).
|
||||
pub struct RemoveCommunity {
|
||||
pub community_id: CommunityId,
|
||||
pub removed: bool,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub reason: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Follow / subscribe to a community.
|
||||
pub struct FollowCommunity {
|
||||
pub community_id: CommunityId,
|
||||
pub follow: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Block a community.
|
||||
pub struct BlockCommunity {
|
||||
pub community_id: CommunityId,
|
||||
pub block: bool,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// The block community response.
|
||||
pub struct BlockCommunityResponse {
|
||||
pub community_view: CommunityView,
|
||||
pub blocked: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Transfer a community to a new owner.
|
||||
pub struct TransferCommunity {
|
||||
pub community_id: CommunityId,
|
||||
pub person_id: PersonId,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Fetches a random community
|
||||
pub struct GetRandomCommunity {
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub type_: Option<ListingType>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub show_nsfw: Option<bool>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
pub struct ListCommunityPendingFollows {
|
||||
/// Only shows the unapproved applications
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub pending_only: Option<bool>,
|
||||
// Only for admins, show pending follows for communities which you dont moderate
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub all_communities: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub page_cursor: Option<PaginationCursor>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub page_back: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub limit: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
pub struct GetCommunityPendingFollowsCount {
|
||||
pub community_id: CommunityId,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
pub struct GetCommunityPendingFollowsCountResponse {
|
||||
pub count: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
pub struct ListCommunityPendingFollowsResponse {
|
||||
pub items: Vec<PendingFollow>,
|
||||
/// the pagination cursor to use to fetch the next page
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub next_page: Option<PaginationCursor>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub prev_page: Option<PaginationCursor>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
pub struct ApproveCommunityPendingFollower {
|
||||
pub community_id: CommunityId,
|
||||
pub follower_id: PersonId,
|
||||
pub approve: bool,
|
||||
pub mod moderation {
|
||||
pub use lemmy_db_schema_file::enums::CommunityFollowerState;
|
||||
pub use lemmy_db_views_community::api::{
|
||||
AddModToCommunity,
|
||||
AddModToCommunityResponse,
|
||||
ApproveCommunityPendingFollower,
|
||||
BanFromCommunity,
|
||||
BanFromCommunityResponse,
|
||||
CommunityIdQuery,
|
||||
CreateCommunityTag,
|
||||
DeleteCommunity,
|
||||
DeleteCommunityTag,
|
||||
EditCommunity,
|
||||
PurgeCommunity,
|
||||
RemoveCommunity,
|
||||
TransferCommunity,
|
||||
UpdateCommunityTag,
|
||||
};
|
||||
pub use lemmy_db_views_community_follower::{
|
||||
api::{
|
||||
GetCommunityPendingFollowsCount,
|
||||
GetCommunityPendingFollowsCountResponse,
|
||||
ListCommunityPendingFollows,
|
||||
ListCommunityPendingFollowsResponse,
|
||||
},
|
||||
CommunityFollowerView,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,67 +1,14 @@
|
|||
use lemmy_db_schema::newtypes::CustomEmojiId;
|
||||
use lemmy_db_views_custom_emoji::CustomEmojiView;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
use ts_rs::TS;
|
||||
use url::Url;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Create a custom emoji.
|
||||
pub struct CreateCustomEmoji {
|
||||
pub category: String,
|
||||
pub shortcode: String,
|
||||
#[cfg_attr(feature = "full", ts(type = "string"))]
|
||||
pub image_url: Url,
|
||||
pub alt_text: String,
|
||||
pub keywords: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Edit a custom emoji.
|
||||
pub struct EditCustomEmoji {
|
||||
pub id: CustomEmojiId,
|
||||
pub category: String,
|
||||
#[cfg_attr(feature = "full", ts(type = "string"))]
|
||||
pub image_url: Url,
|
||||
pub alt_text: String,
|
||||
pub keywords: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Delete a custom emoji.
|
||||
pub struct DeleteCustomEmoji {
|
||||
pub id: CustomEmojiId,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// A response for a custom emoji.
|
||||
pub struct CustomEmojiResponse {
|
||||
pub custom_emoji: CustomEmojiView,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// A response for custom emojis.
|
||||
pub struct ListCustomEmojisResponse {
|
||||
pub custom_emojis: Vec<CustomEmojiView>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Fetches a list of custom emojis.
|
||||
pub struct ListCustomEmojis {
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub category: Option<String>,
|
||||
}
|
||||
pub use lemmy_db_schema::{
|
||||
newtypes::CustomEmojiId,
|
||||
source::{custom_emoji::CustomEmoji, custom_emoji_keyword::CustomEmojiKeyword},
|
||||
};
|
||||
pub use lemmy_db_views_custom_emoji::{
|
||||
api::{
|
||||
CreateCustomEmoji,
|
||||
DeleteCustomEmoji,
|
||||
EditCustomEmoji,
|
||||
ListCustomEmojis,
|
||||
ListCustomEmojisResponse,
|
||||
},
|
||||
CustomEmojiView,
|
||||
};
|
||||
|
|
1
crates/api_common/src/error.rs
Normal file
1
crates/api_common/src/error.rs
Normal file
|
@ -0,0 +1 @@
|
|||
pub use lemmy_utils::error::{FederationError, LemmyErrorType};
|
21
crates/api_common/src/federation.rs
Normal file
21
crates/api_common/src/federation.rs
Normal file
|
@ -0,0 +1,21 @@
|
|||
pub use lemmy_db_schema::{
|
||||
newtypes::{ActivityId, InstanceId},
|
||||
source::{
|
||||
federation_allowlist::FederationAllowList,
|
||||
federation_blocklist::FederationBlockList,
|
||||
federation_queue_state::FederationQueueState,
|
||||
instance::{Instance, InstanceActions},
|
||||
},
|
||||
};
|
||||
pub use lemmy_db_schema_file::enums::FederationMode;
|
||||
pub use lemmy_db_views_api_misc::{ResolveObject, ResolveObjectResponse, UserBlockInstanceParams};
|
||||
pub use lemmy_db_views_readable_federation_state::ReadableFederationState;
|
||||
pub use lemmy_db_views_site::api::{
|
||||
FederatedInstances,
|
||||
GetFederatedInstancesResponse,
|
||||
InstanceWithFederationState,
|
||||
};
|
||||
|
||||
pub mod administration {
|
||||
pub use lemmy_db_views_site::api::{AdminAllowInstanceParams, AdminBlockInstanceParams};
|
||||
}
|
24
crates/api_common/src/inbox.rs
Normal file
24
crates/api_common/src/inbox.rs
Normal file
|
@ -0,0 +1,24 @@
|
|||
pub use lemmy_db_schema::{
|
||||
newtypes::{CommentReplyId, PersonCommentMentionId, PersonPostMentionId},
|
||||
source::{
|
||||
comment_reply::CommentReply,
|
||||
person_comment_mention::PersonCommentMention,
|
||||
person_post_mention::PersonPostMention,
|
||||
},
|
||||
InboxDataType,
|
||||
};
|
||||
pub use lemmy_db_views_inbox_combined::{
|
||||
api::{
|
||||
GetUnreadCountResponse,
|
||||
MarkCommentReplyAsRead,
|
||||
MarkPersonCommentMentionAsRead,
|
||||
MarkPersonPostMentionAsRead,
|
||||
MarkPrivateMessageAsRead,
|
||||
},
|
||||
CommentReplyView,
|
||||
InboxCombinedView,
|
||||
ListInbox,
|
||||
ListInboxResponse,
|
||||
PersonCommentMentionView,
|
||||
PersonPostMentionView,
|
||||
};
|
1
crates/api_common/src/language.rs
Normal file
1
crates/api_common/src/language.rs
Normal file
|
@ -0,0 +1 @@
|
|||
pub use lemmy_db_schema::{newtypes::LanguageId, source::language::Language};
|
|
@ -1,85 +1,24 @@
|
|||
#[cfg(feature = "full")]
|
||||
pub mod build_response;
|
||||
#[cfg(feature = "full")]
|
||||
pub mod claims;
|
||||
pub mod account;
|
||||
pub mod comment;
|
||||
pub mod community;
|
||||
#[cfg(feature = "full")]
|
||||
pub mod context;
|
||||
pub mod custom_emoji;
|
||||
pub mod image;
|
||||
pub mod oauth_provider;
|
||||
pub mod error;
|
||||
pub mod federation;
|
||||
pub mod inbox;
|
||||
pub mod language;
|
||||
pub mod media;
|
||||
pub mod modlog;
|
||||
pub mod oauth;
|
||||
pub mod person;
|
||||
#[cfg(feature = "full")]
|
||||
pub mod plugins;
|
||||
pub mod plugin;
|
||||
pub mod post;
|
||||
pub mod private_message;
|
||||
pub mod reports;
|
||||
#[cfg(feature = "full")]
|
||||
pub mod request;
|
||||
#[cfg(feature = "full")]
|
||||
pub mod send_activity;
|
||||
pub mod report;
|
||||
pub mod search;
|
||||
pub mod site;
|
||||
pub mod tagline;
|
||||
#[cfg(feature = "full")]
|
||||
pub mod tags;
|
||||
#[cfg(feature = "full")]
|
||||
pub mod utils;
|
||||
|
||||
pub extern crate lemmy_db_schema;
|
||||
pub extern crate lemmy_utils;
|
||||
|
||||
pub use lemmy_utils::error::LemmyErrorType;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{cmp::min, time::Duration};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(ts_rs::TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// A response that completes successfully.
|
||||
pub struct SuccessResponse {
|
||||
pub success: bool,
|
||||
}
|
||||
|
||||
impl Default for SuccessResponse {
|
||||
fn default() -> Self {
|
||||
SuccessResponse { success: true }
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: use from_days once stabilized
|
||||
// https://github.com/rust-lang/rust/issues/120301
|
||||
const DAY: Duration = Duration::from_secs(24 * 60 * 60);
|
||||
|
||||
/// Calculate how long to sleep until next federation send based on how many
|
||||
/// retries have already happened. Uses exponential backoff with maximum of one day. The first
|
||||
/// error is ignored.
|
||||
pub fn federate_retry_sleep_duration(retry_count: i32) -> Duration {
|
||||
debug_assert!(retry_count != 0);
|
||||
if retry_count == 1 {
|
||||
return Duration::from_secs(0);
|
||||
}
|
||||
let retry_count = retry_count - 1;
|
||||
let pow = 1.25_f64.powf(retry_count.into());
|
||||
let pow = Duration::try_from_secs_f64(pow).unwrap_or(DAY);
|
||||
min(DAY, pow)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_federate_retry_sleep_duration() {
|
||||
assert_eq!(Duration::from_secs(0), federate_retry_sleep_duration(1));
|
||||
assert_eq!(
|
||||
Duration::new(1, 250000000),
|
||||
federate_retry_sleep_duration(2)
|
||||
);
|
||||
assert_eq!(
|
||||
Duration::new(2, 441406250),
|
||||
federate_retry_sleep_duration(5)
|
||||
);
|
||||
assert_eq!(DAY, federate_retry_sleep_duration(100));
|
||||
}
|
||||
}
|
||||
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_vote::VoteView;
|
||||
|
|
12
crates/api_common/src/media.rs
Normal file
12
crates/api_common/src/media.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
pub use lemmy_db_schema::source::images::{ImageDetails, LocalImage, RemoteImage};
|
||||
pub use lemmy_db_views_local_image::{
|
||||
api::{
|
||||
DeleteImageParams,
|
||||
ImageGetParams,
|
||||
ImageProxyParams,
|
||||
ListMedia,
|
||||
ListMediaResponse,
|
||||
UploadImageResponse,
|
||||
},
|
||||
LocalImageView,
|
||||
};
|
70
crates/api_common/src/modlog.rs
Normal file
70
crates/api_common/src/modlog.rs
Normal file
|
@ -0,0 +1,70 @@
|
|||
pub use lemmy_db_schema::{
|
||||
newtypes::{
|
||||
AdminAllowInstanceId,
|
||||
AdminBlockInstanceId,
|
||||
AdminPurgeCommentId,
|
||||
AdminPurgeCommunityId,
|
||||
AdminPurgePersonId,
|
||||
AdminPurgePostId,
|
||||
ModAddCommunityId,
|
||||
ModAddId,
|
||||
ModBanFromCommunityId,
|
||||
ModBanId,
|
||||
ModChangeCommunityVisibilityId,
|
||||
ModFeaturePostId,
|
||||
ModLockPostId,
|
||||
ModRemoveCommentId,
|
||||
ModRemoveCommunityId,
|
||||
ModRemovePostId,
|
||||
ModTransferCommunityId,
|
||||
ModlogCombinedId,
|
||||
},
|
||||
source::{
|
||||
combined::modlog::ModlogCombined,
|
||||
mod_log::{
|
||||
admin::{
|
||||
AdminAllowInstance,
|
||||
AdminBlockInstance,
|
||||
AdminPurgeComment,
|
||||
AdminPurgeCommunity,
|
||||
AdminPurgePerson,
|
||||
AdminPurgePost,
|
||||
},
|
||||
moderator::{
|
||||
ModAdd,
|
||||
ModAddCommunity,
|
||||
ModBan,
|
||||
ModBanFromCommunity,
|
||||
ModChangeCommunityVisibility,
|
||||
ModFeaturePost,
|
||||
ModLockPost,
|
||||
ModRemoveComment,
|
||||
ModRemoveCommunity,
|
||||
ModRemovePost,
|
||||
ModTransferCommunity,
|
||||
},
|
||||
},
|
||||
},
|
||||
ModlogActionType,
|
||||
};
|
||||
pub use lemmy_db_views_modlog_combined::{
|
||||
api::{GetModlog, GetModlogResponse},
|
||||
AdminAllowInstanceView,
|
||||
AdminBlockInstanceView,
|
||||
AdminPurgeCommentView,
|
||||
AdminPurgeCommunityView,
|
||||
AdminPurgePersonView,
|
||||
AdminPurgePostView,
|
||||
ModAddCommunityView,
|
||||
ModAddView,
|
||||
ModBanFromCommunityView,
|
||||
ModBanView,
|
||||
ModChangeCommunityVisibilityView,
|
||||
ModFeaturePostView,
|
||||
ModLockPostView,
|
||||
ModRemoveCommentView,
|
||||
ModRemoveCommunityView,
|
||||
ModRemovePostView,
|
||||
ModTransferCommunityView,
|
||||
ModlogCombinedView,
|
||||
};
|
13
crates/api_common/src/oauth.rs
Normal file
13
crates/api_common/src/oauth.rs
Normal file
|
@ -0,0 +1,13 @@
|
|||
pub use lemmy_db_schema::{
|
||||
newtypes::OAuthProviderId,
|
||||
source::{
|
||||
oauth_account::OAuthAccount,
|
||||
oauth_provider::{OAuthProvider, PublicOAuthProvider},
|
||||
},
|
||||
};
|
||||
pub use lemmy_db_views_site::api::{
|
||||
AuthenticateWithOauth,
|
||||
CreateOAuthProvider,
|
||||
DeleteOAuthProvider,
|
||||
EditOAuthProvider,
|
||||
};
|
|
@ -1,91 +0,0 @@
|
|||
use lemmy_db_schema::newtypes::OAuthProviderId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
use ts_rs::TS;
|
||||
use url::Url;
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Create an external auth method.
|
||||
pub struct CreateOAuthProvider {
|
||||
pub display_name: String,
|
||||
pub issuer: String,
|
||||
pub authorization_endpoint: String,
|
||||
pub token_endpoint: String,
|
||||
pub userinfo_endpoint: String,
|
||||
pub id_claim: String,
|
||||
pub client_id: String,
|
||||
pub client_secret: String,
|
||||
pub scopes: String,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub auto_verify_email: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub account_linking_enabled: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub use_pkce: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub enabled: Option<bool>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Edit an external auth method.
|
||||
pub struct EditOAuthProvider {
|
||||
pub id: OAuthProviderId,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub display_name: Option<String>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub authorization_endpoint: Option<String>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub token_endpoint: Option<String>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub userinfo_endpoint: Option<String>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub id_claim: Option<String>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub client_secret: Option<String>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub scopes: Option<String>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub auto_verify_email: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub account_linking_enabled: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub use_pkce: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub enabled: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Delete an external auth method.
|
||||
pub struct DeleteOAuthProvider {
|
||||
pub id: OAuthProviderId,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Logging in with an OAuth 2.0 authorization
|
||||
pub struct AuthenticateWithOauth {
|
||||
pub code: String,
|
||||
pub oauth_provider_id: OAuthProviderId,
|
||||
pub redirect_uri: Url,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub show_nsfw: Option<bool>,
|
||||
/// Username is mandatory at registration time
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub username: Option<String>,
|
||||
/// An answer is mandatory if require application is enabled on the server
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub answer: Option<String>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub pkce_code_verifier: Option<String>,
|
||||
}
|
|
@ -1,524 +1,35 @@
|
|||
use lemmy_db_schema::{
|
||||
newtypes::{
|
||||
CommentReplyId,
|
||||
CommunityId,
|
||||
LanguageId,
|
||||
PaginationCursor,
|
||||
PersonCommentMentionId,
|
||||
PersonId,
|
||||
PersonPostMentionId,
|
||||
pub use lemmy_db_schema::{
|
||||
newtypes::{LocalUserId, PersonId},
|
||||
source::{
|
||||
local_user::LocalUser,
|
||||
person::{Person, PersonActions},
|
||||
},
|
||||
sensitive::SensitiveString,
|
||||
source::{login_token::LoginToken, site::Site},
|
||||
PersonContentType,
|
||||
};
|
||||
use lemmy_db_schema_file::enums::{
|
||||
CommentSortType,
|
||||
ListingType,
|
||||
PostListingMode,
|
||||
PostSortType,
|
||||
VoteShow,
|
||||
pub use lemmy_db_views_local_user::LocalUserView;
|
||||
pub use lemmy_db_views_person::{
|
||||
api::{GetPersonDetails, GetPersonDetailsResponse},
|
||||
PersonView,
|
||||
};
|
||||
use lemmy_db_views_community_moderator::CommunityModeratorView;
|
||||
use lemmy_db_views_local_image::LocalImageView;
|
||||
use lemmy_db_views_person::PersonView;
|
||||
use lemmy_db_views_post::PostView;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
use ts_rs::TS;
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(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.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub totp_2fa_token: Option<String>,
|
||||
}
|
||||
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_content_combined::{
|
||||
ListPersonContent,
|
||||
ListPersonContentResponse,
|
||||
PersonContentCombinedView,
|
||||
};
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Register / Sign up to lemmy.
|
||||
pub struct Register {
|
||||
pub username: String,
|
||||
pub password: SensitiveString,
|
||||
pub password_verify: SensitiveString,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub show_nsfw: Option<bool>,
|
||||
/// email is mandatory if email verification is enabled on the server
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub email: Option<SensitiveString>,
|
||||
/// The UUID of the captcha item.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub captcha_uuid: Option<String>,
|
||||
/// Your captcha answer.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub captcha_answer: Option<String>,
|
||||
/// A form field to trick signup bots. Should be None.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub honeypot: Option<String>,
|
||||
/// An answer is mandatory if require application is enabled on the server
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub answer: Option<String>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// A wrapper for the captcha response.
|
||||
pub struct GetCaptchaResponse {
|
||||
/// Will be None if captchas are disabled.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub ok: Option<CaptchaResponse>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(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,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Saves settings for your user.
|
||||
pub struct SaveUserSettings {
|
||||
/// Show nsfw posts.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub show_nsfw: Option<bool>,
|
||||
/// Blur nsfw posts.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub blur_nsfw: Option<bool>,
|
||||
/// Your user's theme.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub theme: Option<String>,
|
||||
/// The default post listing type, usually "local"
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub default_listing_type: Option<ListingType>,
|
||||
/// A post-view mode that changes how multiple post listings look.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub post_listing_mode: Option<PostListingMode>,
|
||||
/// The default post sort, usually "active"
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub default_post_sort_type: Option<PostSortType>,
|
||||
/// A default time range limit to apply to post sorts, in seconds. 0 means none.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub default_post_time_range_seconds: Option<i32>,
|
||||
/// The default comment sort, usually "hot"
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub default_comment_sort_type: Option<CommentSortType>,
|
||||
/// The language of the lemmy interface
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub interface_language: Option<String>,
|
||||
/// Your display name, which can contain strange characters, and does not need to be unique.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub display_name: Option<String>,
|
||||
/// Your email.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub email: Option<SensitiveString>,
|
||||
/// Your bio / info, in markdown.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub bio: Option<String>,
|
||||
/// Your matrix user id. Ex: @my_user:matrix.org
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub matrix_user_id: Option<String>,
|
||||
/// Whether to show or hide avatars.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub show_avatars: Option<bool>,
|
||||
/// Sends notifications to your email.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub send_notifications_to_email: Option<bool>,
|
||||
/// Whether this account is a bot account. Users can hide these accounts easily if they wish.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub bot_account: Option<bool>,
|
||||
/// Whether to show bot accounts.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub show_bot_accounts: Option<bool>,
|
||||
/// Whether to show read posts.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub show_read_posts: Option<bool>,
|
||||
/// A list of languages you are able to see discussion in.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub discussion_languages: Option<Vec<LanguageId>>,
|
||||
// A list of keywords used for blocking posts having them in title,url or body.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub blocking_keywords: Option<Vec<String>>,
|
||||
/// Open links in a new tab
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub open_links_in_new_tab: Option<bool>,
|
||||
/// Enable infinite scroll
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub infinite_scroll_enabled: Option<bool>,
|
||||
/// Whether to allow keyboard navigation (for browsing and interacting with posts and comments).
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub enable_keyboard_navigation: Option<bool>,
|
||||
/// Whether user avatars or inline images in the UI that are gifs should be allowed to play or
|
||||
/// should be paused
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub enable_animated_images: Option<bool>,
|
||||
/// Whether a user can send / receive private messages
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub enable_private_messages: Option<bool>,
|
||||
/// Whether to auto-collapse bot comments.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub collapse_bot_comments: Option<bool>,
|
||||
/// Some vote display mode settings
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub show_scores: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub show_upvotes: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub show_downvotes: Option<VoteShow>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub show_upvote_percentage: Option<bool>,
|
||||
/// Whether to automatically mark fetched posts as read.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub auto_mark_fetched_posts_as_read: Option<bool>,
|
||||
/// Whether to hide posts containing images/videos.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub hide_media: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Changes your account password.
|
||||
pub struct ChangePassword {
|
||||
pub new_password: SensitiveString,
|
||||
pub new_password_verify: SensitiveString,
|
||||
pub old_password: SensitiveString,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(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.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub jwt: Option<SensitiveString>,
|
||||
/// 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,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Gets a person's details.
|
||||
///
|
||||
/// Either person_id, or username are required.
|
||||
pub struct GetPersonDetails {
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub person_id: Option<PersonId>,
|
||||
/// Example: dessalines , or dessalines@xyz.tld
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub username: Option<String>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// A person's details response.
|
||||
pub struct GetPersonDetailsResponse {
|
||||
pub person_view: PersonView,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub site: Option<Site>,
|
||||
pub moderates: Vec<CommunityModeratorView>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Gets your read posts.
|
||||
pub struct ListPersonRead {
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub page_cursor: Option<PaginationCursor>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub page_back: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub limit: Option<i64>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// You read posts response.
|
||||
pub struct ListPersonReadResponse {
|
||||
pub read: Vec<PostView>,
|
||||
/// the pagination cursor to use to fetch the next page
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub next_page: Option<PaginationCursor>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub prev_page: Option<PaginationCursor>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Gets your hidden posts.
|
||||
pub struct ListPersonHidden {
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub page_cursor: Option<PaginationCursor>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub page_back: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub limit: Option<i64>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// You hidden posts response.
|
||||
pub struct ListPersonHiddenResponse {
|
||||
pub hidden: Vec<PostView>,
|
||||
/// the pagination cursor to use to fetch the next page
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub next_page: Option<PaginationCursor>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub prev_page: Option<PaginationCursor>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Adds an admin to a site.
|
||||
pub struct AddAdmin {
|
||||
pub person_id: PersonId,
|
||||
pub added: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// The response of current admins.
|
||||
pub struct AddAdminResponse {
|
||||
pub admins: Vec<PersonView>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Ban a person from the site.
|
||||
pub struct BanPerson {
|
||||
pub person_id: PersonId,
|
||||
pub ban: bool,
|
||||
/// Optionally remove or restore all their data. Useful for new troll accounts.
|
||||
/// If ban is true, then this means remove. If ban is false, it means restore.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub remove_or_restore_data: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub reason: Option<String>,
|
||||
/// A time that the ban will expire, in unix epoch seconds.
|
||||
///
|
||||
/// An i64 unix timestamp is used for a simpler API client implementation.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub expires: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// A response for a banned person.
|
||||
pub struct BanPersonResponse {
|
||||
pub person_view: PersonView,
|
||||
pub banned: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Block a person.
|
||||
pub struct BlockPerson {
|
||||
pub person_id: PersonId,
|
||||
pub block: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// The response for a person block.
|
||||
pub struct BlockPersonResponse {
|
||||
pub person_view: PersonView,
|
||||
pub blocked: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Mark a person mention as read.
|
||||
pub struct MarkPersonCommentMentionAsRead {
|
||||
pub person_comment_mention_id: PersonCommentMentionId,
|
||||
pub read: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Mark a person mention as read.
|
||||
pub struct MarkPersonPostMentionAsRead {
|
||||
pub person_post_mention_id: PersonPostMentionId,
|
||||
pub read: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Mark a comment reply as read.
|
||||
pub struct MarkCommentReplyAsRead {
|
||||
pub comment_reply_id: CommentReplyId,
|
||||
pub read: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Delete your account.
|
||||
pub struct DeleteAccount {
|
||||
pub password: SensitiveString,
|
||||
pub delete_content: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Reset your password via email.
|
||||
pub struct PasswordReset {
|
||||
pub email: SensitiveString,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Change your password after receiving a reset request.
|
||||
pub struct PasswordChangeAfterReset {
|
||||
pub token: SensitiveString,
|
||||
pub password: SensitiveString,
|
||||
pub password_verify: SensitiveString,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Get a count of the number of reports.
|
||||
pub struct GetReportCount {
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub community_id: Option<CommunityId>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// A response for the number of reports.
|
||||
pub struct GetReportCountResponse {
|
||||
pub count: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// A response containing a count of unread notifications.
|
||||
pub struct GetUnreadCountResponse {
|
||||
pub count: i64,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Verify your email.
|
||||
pub struct VerifyEmail {
|
||||
pub token: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
pub struct GenerateTotpSecretResponse {
|
||||
pub totp_secret_url: SensitiveString,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
pub struct UpdateTotp {
|
||||
pub totp_token: String,
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
pub struct UpdateTotpResponse {
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Get your user's image / media uploads.
|
||||
pub struct ListMedia {
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub page_cursor: Option<PaginationCursor>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub page_back: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub limit: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
pub struct ListMediaResponse {
|
||||
pub images: Vec<LocalImageView>,
|
||||
/// the pagination cursor to use to fetch the next page
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub next_page: Option<PaginationCursor>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub prev_page: Option<PaginationCursor>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
pub struct ListLoginsResponse {
|
||||
pub logins: Vec<LoginToken>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Make a request to resend your verification email.
|
||||
pub struct ResendVerificationEmail {
|
||||
pub email: SensitiveString,
|
||||
pub mod moderation {
|
||||
pub use lemmy_db_schema::{
|
||||
newtypes::RegistrationApplicationId,
|
||||
source::registration_application::RegistrationApplication,
|
||||
};
|
||||
pub use lemmy_db_views_person::api::{BanPerson, BanPersonResponse, PurgePerson};
|
||||
pub use lemmy_db_views_registration_applications::{
|
||||
api::{GetRegistrationApplication, RegistrationApplicationResponse},
|
||||
RegistrationApplicationView,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
1
crates/api_common/src/plugin.rs
Normal file
1
crates/api_common/src/plugin.rs
Normal file
|
@ -0,0 +1 @@
|
|||
pub use lemmy_db_views_api_misc::PluginMetadata;
|
|
@ -1,328 +1,44 @@
|
|||
use lemmy_db_schema::{
|
||||
newtypes::{CommentId, CommunityId, DbUrl, LanguageId, PaginationCursor, PostId, TagId},
|
||||
pub use lemmy_db_schema::{
|
||||
newtypes::PostId,
|
||||
source::post::{Post, PostActions},
|
||||
PostFeatureType,
|
||||
};
|
||||
use lemmy_db_schema_file::enums::{ListingType, PostSortType};
|
||||
use lemmy_db_views_community::CommunityView;
|
||||
use lemmy_db_views_post::PostView;
|
||||
use lemmy_db_views_vote::VoteView;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
use ts_rs::TS;
|
||||
pub use lemmy_db_schema_file::enums::PostListingMode;
|
||||
pub use lemmy_db_views_post::{
|
||||
api::{
|
||||
GetPost,
|
||||
GetPostResponse,
|
||||
GetPosts,
|
||||
GetPostsResponse,
|
||||
GetSiteMetadata,
|
||||
GetSiteMetadataResponse,
|
||||
LinkMetadata,
|
||||
OpenGraphData,
|
||||
PostResponse,
|
||||
},
|
||||
PostView,
|
||||
};
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Create a post.
|
||||
pub struct CreatePost {
|
||||
pub name: String,
|
||||
pub community_id: CommunityId,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub url: Option<String>,
|
||||
/// An optional body for the post in markdown.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub body: Option<String>,
|
||||
/// An optional alt_text, usable for image posts.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub alt_text: Option<String>,
|
||||
/// A honeypot to catch bots. Should be None.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub honeypot: Option<String>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub nsfw: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub language_id: Option<LanguageId>,
|
||||
/// Instead of fetching a thumbnail, use a custom one.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub custom_thumbnail: Option<String>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub tags: Option<Vec<TagId>>,
|
||||
/// Time when this post should be scheduled. Null means publish immediately.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub scheduled_publish_time: Option<i64>,
|
||||
}
|
||||
pub mod actions {
|
||||
pub use lemmy_db_views_post::api::{
|
||||
CreatePost,
|
||||
CreatePostLike,
|
||||
DeletePost,
|
||||
EditPost,
|
||||
HidePost,
|
||||
MarkManyPostsAsRead,
|
||||
MarkPostAsRead,
|
||||
SavePost,
|
||||
};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
pub struct PostResponse {
|
||||
pub post_view: PostView,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
// TODO this should be made into a tagged enum
|
||||
/// Get a post. Needs either the post id, or comment_id.
|
||||
pub struct GetPost {
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub id: Option<PostId>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub comment_id: Option<CommentId>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// The post response.
|
||||
pub struct GetPostResponse {
|
||||
pub post_view: PostView,
|
||||
pub community_view: CommunityView,
|
||||
/// A list of cross-posts, or other times / communities this link has been posted to.
|
||||
pub cross_posts: Vec<PostView>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Get a list of posts.
|
||||
pub struct GetPosts {
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub type_: Option<ListingType>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub sort: Option<PostSortType>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
/// Filter to within a given time range, in seconds.
|
||||
/// IE 60 would give results for the past minute.
|
||||
/// Use Zero to override the local_site and local_user time_range.
|
||||
pub time_range_seconds: Option<i32>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub community_id: Option<CommunityId>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub community_name: Option<String>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub show_hidden: Option<bool>,
|
||||
/// If true, then show the read posts (even if your user setting is to hide them)
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub show_read: Option<bool>,
|
||||
/// If true, then show the nsfw posts (even if your user setting is to hide them)
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub show_nsfw: Option<bool>,
|
||||
/// If false, then show posts with media attached (even if your user setting is to hide them)
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub hide_media: Option<bool>,
|
||||
/// Whether to automatically mark fetched posts as read.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub mark_as_read: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
/// If true, then only show posts with no comments
|
||||
pub no_comments_only: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub page_cursor: Option<PaginationCursor>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub page_back: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub limit: Option<i64>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// The post list response.
|
||||
pub struct GetPostsResponse {
|
||||
pub posts: Vec<PostView>,
|
||||
/// the pagination cursor to use to fetch the next page
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub next_page: Option<PaginationCursor>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub prev_page: Option<PaginationCursor>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Like a post.
|
||||
pub struct CreatePostLike {
|
||||
pub post_id: PostId,
|
||||
/// Score must be -1, 0, or 1.
|
||||
pub score: i16,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Edit a post.
|
||||
pub struct EditPost {
|
||||
pub post_id: PostId,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub name: Option<String>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub url: Option<String>,
|
||||
/// An optional body for the post in markdown.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub body: Option<String>,
|
||||
/// An optional alt_text, usable for image posts.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub alt_text: Option<String>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub nsfw: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub language_id: Option<LanguageId>,
|
||||
/// Instead of fetching a thumbnail, use a custom one.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub custom_thumbnail: Option<String>,
|
||||
/// Time when this post should be scheduled. Null means publish immediately.
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub scheduled_publish_time: Option<i64>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub tags: Option<Vec<TagId>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Delete a post.
|
||||
pub struct DeletePost {
|
||||
pub post_id: PostId,
|
||||
pub deleted: bool,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Remove a post (only doable by mods).
|
||||
pub struct RemovePost {
|
||||
pub post_id: PostId,
|
||||
pub removed: bool,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub reason: Option<String>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Mark a post as read.
|
||||
pub struct MarkPostAsRead {
|
||||
pub post_id: PostId,
|
||||
pub read: bool,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Mark several posts as read.
|
||||
pub struct MarkManyPostsAsRead {
|
||||
pub post_ids: Vec<PostId>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Hide a post from list views
|
||||
pub struct HidePost {
|
||||
pub post_id: PostId,
|
||||
pub hide: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Lock a post (prevent new comments).
|
||||
pub struct LockPost {
|
||||
pub post_id: PostId,
|
||||
pub locked: bool,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub reason: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Feature a post (stickies / pins to the top).
|
||||
pub struct FeaturePost {
|
||||
pub post_id: PostId,
|
||||
pub featured: bool,
|
||||
pub feature_type: PostFeatureType,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Save / bookmark a post.
|
||||
pub struct SavePost {
|
||||
pub post_id: PostId,
|
||||
pub save: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Get metadata for a given site.
|
||||
pub struct GetSiteMetadata {
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// The site metadata response.
|
||||
pub struct GetSiteMetadataResponse {
|
||||
pub metadata: LinkMetadata,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone, Default, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Site metadata, from its opengraph tags.
|
||||
pub struct LinkMetadata {
|
||||
#[serde(flatten)]
|
||||
pub opengraph_data: OpenGraphData,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub content_type: Option<String>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone, Default, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// Site metadata, from its opengraph tags.
|
||||
pub struct OpenGraphData {
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub title: Option<String>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub description: Option<String>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub(crate) image: Option<DbUrl>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub embed_video_url: Option<DbUrl>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// List post likes. Admins-only.
|
||||
pub struct ListPostLikes {
|
||||
pub post_id: PostId,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub page_cursor: Option<PaginationCursor>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub page_back: Option<bool>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub limit: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// The post likes response
|
||||
pub struct ListPostLikesResponse {
|
||||
pub post_likes: Vec<VoteView>,
|
||||
/// the pagination cursor to use to fetch the next page
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub next_page: Option<PaginationCursor>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub prev_page: Option<PaginationCursor>,
|
||||
pub mod moderation {
|
||||
pub use lemmy_db_views_post::api::{
|
||||
FeaturePost,
|
||||
ListPostLikes,
|
||||
ListPostLikesResponse,
|
||||
LockPost,
|
||||
PurgePost,
|
||||
RemovePost,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue