2021-10-16 13:33:38 +00:00
|
|
|
use lemmy_db_schema::newtypes::{CommunityId, PersonId};
|
2021-03-11 04:43:11 +00:00
|
|
|
use lemmy_db_views::{
|
|
|
|
comment_view::CommentView,
|
|
|
|
local_user_view::LocalUserSettingsView,
|
|
|
|
post_view::PostView,
|
2021-12-15 19:49:59 +00:00
|
|
|
registration_application_view::RegistrationApplicationView,
|
2021-03-11 04:43:11 +00:00
|
|
|
site_view::SiteView,
|
|
|
|
};
|
2021-08-19 20:54:15 +00:00
|
|
|
use lemmy_db_views_actor::{
|
|
|
|
community_block_view::CommunityBlockView,
|
|
|
|
community_follower_view::CommunityFollowerView,
|
|
|
|
community_moderator_view::CommunityModeratorView,
|
|
|
|
community_view::CommunityView,
|
|
|
|
person_block_view::PersonBlockView,
|
|
|
|
person_view::PersonViewSafe,
|
|
|
|
};
|
2020-12-21 23:27:42 +00:00
|
|
|
use lemmy_db_views_moderator::{
|
|
|
|
mod_add_community_view::ModAddCommunityView,
|
|
|
|
mod_add_view::ModAddView,
|
|
|
|
mod_ban_from_community_view::ModBanFromCommunityView,
|
|
|
|
mod_ban_view::ModBanView,
|
2022-02-18 02:30:47 +00:00
|
|
|
mod_hide_community_view::ModHideCommunityView,
|
2020-12-21 23:27:42 +00:00
|
|
|
mod_lock_post_view::ModLockPostView,
|
|
|
|
mod_remove_comment_view::ModRemoveCommentView,
|
|
|
|
mod_remove_community_view::ModRemoveCommunityView,
|
|
|
|
mod_remove_post_view::ModRemovePostView,
|
|
|
|
mod_sticky_post_view::ModStickyPostView,
|
2021-08-17 21:52:28 +00:00
|
|
|
mod_transfer_community_view::ModTransferCommunityView,
|
2020-09-01 14:25:34 +00:00
|
|
|
};
|
2021-12-06 14:54:47 +00:00
|
|
|
use lemmy_utils::Sensitive;
|
2020-09-01 14:25:34 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct Search {
|
|
|
|
pub q: String,
|
2021-03-18 20:25:21 +00:00
|
|
|
pub community_id: Option<CommunityId>,
|
2020-10-05 00:57:35 +00:00
|
|
|
pub community_name: Option<String>,
|
2021-04-09 20:09:58 +00:00
|
|
|
pub creator_id: Option<PersonId>,
|
2021-04-15 03:37:51 +00:00
|
|
|
pub type_: Option<String>,
|
|
|
|
pub sort: Option<String>,
|
|
|
|
pub listing_type: Option<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Option<Sensitive<String>>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct SearchResponse {
|
|
|
|
pub type_: String,
|
|
|
|
pub comments: Vec<CommentView>,
|
|
|
|
pub posts: Vec<PostView>,
|
|
|
|
pub communities: Vec<CommunityView>,
|
2021-03-10 22:33:55 +00:00
|
|
|
pub users: Vec<PersonViewSafe>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
2021-07-20 07:00:20 +00:00
|
|
|
pub struct ResolveObject {
|
|
|
|
pub q: String,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Option<Sensitive<String>>,
|
2021-07-20 07:00:20 +00:00
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Default)]
|
2021-08-23 15:25:39 +00:00
|
|
|
pub struct ResolveObjectResponse {
|
|
|
|
pub comment: Option<CommentView>,
|
|
|
|
pub post: Option<PostView>,
|
|
|
|
pub community: Option<CommunityView>,
|
|
|
|
pub person: Option<PersonViewSafe>,
|
2021-07-20 07:00:20 +00:00
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetModlog {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub mod_person_id: Option<PersonId>,
|
|
|
|
pub community_id: Option<CommunityId>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
2021-12-15 19:49:59 +00:00
|
|
|
pub auth: Option<Sensitive<String>>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetModlogResponse {
|
|
|
|
pub removed_posts: Vec<ModRemovePostView>,
|
|
|
|
pub locked_posts: Vec<ModLockPostView>,
|
|
|
|
pub stickied_posts: Vec<ModStickyPostView>,
|
|
|
|
pub removed_comments: Vec<ModRemoveCommentView>,
|
|
|
|
pub removed_communities: Vec<ModRemoveCommunityView>,
|
|
|
|
pub banned_from_community: Vec<ModBanFromCommunityView>,
|
|
|
|
pub banned: Vec<ModBanView>,
|
|
|
|
pub added_to_community: Vec<ModAddCommunityView>,
|
2021-08-17 21:52:28 +00:00
|
|
|
pub transferred_to_community: Vec<ModTransferCommunityView>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub added: Vec<ModAddView>,
|
2022-02-18 02:30:47 +00:00
|
|
|
pub hidden_communities: Vec<ModHideCommunityView>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct CreateSite {
|
|
|
|
pub name: String,
|
2021-04-07 11:40:35 +00:00
|
|
|
pub sidebar: Option<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub description: Option<String>,
|
2021-04-07 11:40:35 +00:00
|
|
|
pub icon: Option<String>,
|
|
|
|
pub banner: Option<String>,
|
2021-04-15 03:37:51 +00:00
|
|
|
pub enable_downvotes: Option<bool>,
|
|
|
|
pub open_registration: Option<bool>,
|
|
|
|
pub enable_nsfw: Option<bool>,
|
|
|
|
pub community_creation_admin_only: Option<bool>,
|
2021-12-15 19:49:59 +00:00
|
|
|
pub require_email_verification: Option<bool>,
|
|
|
|
pub require_application: Option<bool>,
|
|
|
|
pub application_question: Option<String>,
|
|
|
|
pub private_instance: Option<bool>,
|
2022-02-23 16:40:36 +00:00
|
|
|
pub default_theme: Option<String>,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct EditSite {
|
2021-04-15 03:37:51 +00:00
|
|
|
pub name: Option<String>,
|
2021-04-07 11:40:35 +00:00
|
|
|
pub sidebar: Option<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub description: Option<String>,
|
|
|
|
pub icon: Option<String>,
|
|
|
|
pub banner: Option<String>,
|
2021-04-15 03:37:51 +00:00
|
|
|
pub enable_downvotes: Option<bool>,
|
|
|
|
pub open_registration: Option<bool>,
|
|
|
|
pub enable_nsfw: Option<bool>,
|
2021-04-22 23:42:58 +00:00
|
|
|
pub community_creation_admin_only: Option<bool>,
|
2021-12-15 19:49:59 +00:00
|
|
|
pub require_email_verification: Option<bool>,
|
|
|
|
pub require_application: Option<bool>,
|
|
|
|
pub application_question: Option<String>,
|
|
|
|
pub private_instance: Option<bool>,
|
2022-02-23 16:40:36 +00:00
|
|
|
pub default_theme: Option<String>,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetSite {
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Option<Sensitive<String>>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct SiteResponse {
|
2020-12-20 01:10:47 +00:00
|
|
|
pub site_view: SiteView,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetSiteResponse {
|
2020-12-20 01:10:47 +00:00
|
|
|
pub site_view: Option<SiteView>, // Because the site might not be set up yet
|
2021-03-10 22:33:55 +00:00
|
|
|
pub admins: Vec<PersonViewSafe>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub online: usize,
|
|
|
|
pub version: String,
|
2021-08-19 20:54:15 +00:00
|
|
|
pub my_user: Option<MyUserInfo>,
|
2021-02-01 18:11:37 +00:00
|
|
|
pub federated_instances: Option<FederatedInstances>, // Federation may be disabled
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2021-08-19 20:54:15 +00:00
|
|
|
pub struct MyUserInfo {
|
|
|
|
pub local_user_view: LocalUserSettingsView,
|
|
|
|
pub follows: Vec<CommunityFollowerView>,
|
|
|
|
pub moderates: Vec<CommunityModeratorView>,
|
|
|
|
pub community_blocks: Vec<CommunityBlockView>,
|
|
|
|
pub person_blocks: Vec<PersonBlockView>,
|
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2022-01-26 17:57:16 +00:00
|
|
|
pub struct LeaveAdmin {
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetSiteConfig {
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetSiteConfigResponse {
|
|
|
|
pub config_hjson: String,
|
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct SaveSiteConfig {
|
|
|
|
pub config_hjson: String,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
2021-02-01 18:11:37 +00:00
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2021-02-01 18:11:37 +00:00
|
|
|
pub struct FederatedInstances {
|
|
|
|
pub linked: Vec<String>,
|
2021-03-01 17:24:11 +00:00
|
|
|
pub allowed: Option<Vec<String>>,
|
|
|
|
pub blocked: Option<Vec<String>>,
|
2021-02-01 18:11:37 +00:00
|
|
|
}
|
2021-12-15 19:49:59 +00:00
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
|
|
pub struct ListRegistrationApplications {
|
|
|
|
/// Only shows the unread applications (IE those without an admin actor)
|
|
|
|
pub unread_only: Option<bool>,
|
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
|
|
pub struct ListRegistrationApplicationsResponse {
|
|
|
|
pub registration_applications: Vec<RegistrationApplicationView>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
|
|
pub struct ApproveRegistrationApplication {
|
|
|
|
pub id: i32,
|
|
|
|
pub approve: bool,
|
|
|
|
pub deny_reason: Option<String>,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
|
|
pub struct RegistrationApplicationResponse {
|
|
|
|
pub registration_application: RegistrationApplicationView,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
|
|
pub struct GetUnreadRegistrationApplicationCount {
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Clone)]
|
|
|
|
pub struct GetUnreadRegistrationApplicationCountResponse {
|
|
|
|
pub registration_applications: i64,
|
|
|
|
}
|