2020-09-01 14:25:34 +00:00
|
|
|
use lemmy_db::{
|
2020-12-03 18:39:56 +00:00
|
|
|
aggregates::site_aggregates::SiteAggregates,
|
2020-09-01 14:25:34 +00:00
|
|
|
moderator_views::*,
|
2020-12-13 17:04:42 +00:00
|
|
|
source::{category::*, user::*},
|
2020-12-11 15:27:33 +00:00
|
|
|
views::{
|
2020-12-15 19:39:18 +00:00
|
|
|
comment_view::CommentView,
|
2020-12-11 15:27:33 +00:00
|
|
|
community_view::CommunityView,
|
|
|
|
post_view::PostView,
|
|
|
|
site_view::SiteView,
|
|
|
|
user_view::UserViewSafe,
|
|
|
|
},
|
2020-09-01 14:25:34 +00:00
|
|
|
};
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct ListCategories {}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct ListCategoriesResponse {
|
|
|
|
pub categories: Vec<Category>,
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
pub community_id: Option<i32>,
|
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>,
|
2020-12-04 00:47:58 +00:00
|
|
|
pub users: Vec<UserViewSafe>,
|
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 {
|
|
|
|
pub mod_user_id: Option<i32>,
|
|
|
|
pub community_id: Option<i32>,
|
|
|
|
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>,
|
|
|
|
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 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-12-02 19:32:47 +00:00
|
|
|
// TODO combine siteresponse and getsiteresponse
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize, Clone)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct SiteResponse {
|
|
|
|
pub site: SiteView,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetSiteResponse {
|
2020-12-02 19:32:47 +00:00
|
|
|
pub site: Option<SiteView>, // Because the site might not be set up yet
|
2020-12-03 03:39:31 +00:00
|
|
|
pub counts: SiteAggregates,
|
2020-12-04 00:47:58 +00:00
|
|
|
pub admins: Vec<UserViewSafe>,
|
|
|
|
pub banned: Vec<UserViewSafe>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub online: usize,
|
|
|
|
pub version: String,
|
|
|
|
pub my_user: Option<User_>,
|
|
|
|
pub federated_instances: Vec<String>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct TransferSite {
|
|
|
|
pub user_id: i32,
|
|
|
|
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,
|
|
|
|
}
|