2021-03-18 20:25:21 +00:00
|
|
|
use lemmy_db_schema::{CommunityId, PersonId};
|
2021-03-11 04:43:11 +00:00
|
|
|
use lemmy_db_views::{
|
|
|
|
comment_view::CommentView,
|
|
|
|
local_user_view::LocalUserSettingsView,
|
|
|
|
post_view::PostView,
|
|
|
|
site_view::SiteView,
|
|
|
|
};
|
2021-03-10 22:33:55 +00:00
|
|
|
use lemmy_db_views_actor::{community_view::CommunityView, 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,
|
|
|
|
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,
|
2020-09-01 14:25:34 +00:00
|
|
|
};
|
|
|
|
use serde::{Deserialize, Serialize};
|
2021-03-02 12:41:48 +00:00
|
|
|
use url::Url;
|
2020-09-01 14:25:34 +00:00
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize, Debug)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct Search {
|
|
|
|
pub q: String,
|
|
|
|
pub type_: 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>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub sort: String,
|
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
|
|
|
pub auth: Option<String>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize, 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
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(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>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize)]
|
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>,
|
|
|
|
pub added: Vec<ModAddView>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct CreateSite {
|
|
|
|
pub name: String,
|
|
|
|
pub description: Option<String>,
|
2021-03-02 12:41:48 +00:00
|
|
|
pub icon: Option<Url>,
|
|
|
|
pub banner: Option<Url>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub enable_downvotes: bool,
|
|
|
|
pub open_registration: bool,
|
|
|
|
pub enable_nsfw: bool,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct EditSite {
|
|
|
|
pub name: String,
|
|
|
|
pub description: Option<String>,
|
|
|
|
pub icon: Option<String>,
|
|
|
|
pub banner: Option<String>,
|
|
|
|
pub enable_downvotes: bool,
|
|
|
|
pub open_registration: bool,
|
|
|
|
pub enable_nsfw: bool,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetSite {
|
|
|
|
pub auth: Option<String>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize, 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
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize)]
|
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>,
|
|
|
|
pub banned: Vec<PersonViewSafe>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub online: usize,
|
|
|
|
pub version: String,
|
2021-03-10 22:33:55 +00:00
|
|
|
pub my_user: Option<LocalUserSettingsView>,
|
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
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct TransferSite {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub person_id: PersonId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetSiteConfig {
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetSiteConfigResponse {
|
|
|
|
pub config_hjson: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct SaveSiteConfig {
|
|
|
|
pub config_hjson: String,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
2021-02-01 18:11:37 +00:00
|
|
|
|
|
|
|
#[derive(Serialize)]
|
|
|
|
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
|
|
|
}
|