2022-04-13 16:37:54 +00:00
|
|
|
use lemmy_db_schema::{
|
|
|
|
newtypes::{CommunityId, PersonId},
|
|
|
|
source::site::Site,
|
|
|
|
};
|
2020-12-21 23:27:42 +00:00
|
|
|
use lemmy_db_views_actor::{
|
|
|
|
community_moderator_view::CommunityModeratorView,
|
|
|
|
community_view::CommunityView,
|
2021-03-10 22:33:55 +00:00
|
|
|
person_view::PersonViewSafe,
|
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-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetCommunity {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub id: Option<CommunityId>,
|
2021-07-20 04:29:50 +00:00
|
|
|
/// Example: star_trek , or star_trek@xyz.tld
|
2020-09-01 14:25:34 +00:00
|
|
|
pub name: Option<String>,
|
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)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetCommunityResponse {
|
2020-12-06 14:12:51 +00:00
|
|
|
pub community_view: CommunityView,
|
2022-04-13 16:37:54 +00:00
|
|
|
pub site: Option<Site>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub moderators: Vec<CommunityModeratorView>,
|
|
|
|
pub online: usize,
|
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct CreateCommunity {
|
|
|
|
pub name: String,
|
|
|
|
pub title: String,
|
|
|
|
pub description: Option<String>,
|
|
|
|
pub icon: Option<String>,
|
|
|
|
pub banner: Option<String>,
|
2021-03-20 20:59:07 +00:00
|
|
|
pub nsfw: Option<bool>,
|
2022-04-29 14:01:10 +00:00
|
|
|
pub posting_restricted_to_mods: Option<bool>,
|
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, Clone)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct CommunityResponse {
|
2020-12-06 14:12:51 +00:00
|
|
|
pub community_view: CommunityView,
|
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 ListCommunities {
|
2021-04-15 03:37:51 +00:00
|
|
|
pub type_: Option<String>,
|
|
|
|
pub sort: 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 ListCommunitiesResponse {
|
|
|
|
pub communities: Vec<CommunityView>,
|
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct BanFromCommunity {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub community_id: CommunityId,
|
|
|
|
pub person_id: PersonId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub ban: bool,
|
2021-04-15 03:37:51 +00:00
|
|
|
pub remove_data: Option<bool>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub reason: Option<String>,
|
|
|
|
pub expires: Option<i64>,
|
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, Clone)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct BanFromCommunityResponse {
|
2021-03-10 22:33:55 +00:00
|
|
|
pub person_view: PersonViewSafe,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub banned: bool,
|
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct AddModToCommunity {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub community_id: CommunityId,
|
|
|
|
pub person_id: PersonId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub added: bool,
|
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, Clone)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct AddModToCommunityResponse {
|
|
|
|
pub moderators: Vec<CommunityModeratorView>,
|
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct EditCommunity {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub community_id: CommunityId,
|
2021-04-15 03:37:51 +00:00
|
|
|
pub title: Option<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub description: Option<String>,
|
|
|
|
pub icon: Option<String>,
|
|
|
|
pub banner: Option<String>,
|
2021-03-20 20:59:07 +00:00
|
|
|
pub nsfw: Option<bool>,
|
2022-04-29 14:01:10 +00:00
|
|
|
pub posting_restricted_to_mods: Option<bool>,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2022-02-18 02:30:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
pub struct HideCommunity {
|
|
|
|
pub community_id: CommunityId,
|
|
|
|
pub hidden: bool,
|
|
|
|
pub reason: Option<String>,
|
|
|
|
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 DeleteCommunity {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub community_id: CommunityId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub deleted: bool,
|
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 RemoveCommunity {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub community_id: CommunityId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub removed: bool,
|
|
|
|
pub reason: Option<String>,
|
|
|
|
pub expires: Option<i64>,
|
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 FollowCommunity {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub community_id: CommunityId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub follow: bool,
|
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)]
|
2021-08-19 20:54:15 +00:00
|
|
|
pub struct BlockCommunity {
|
|
|
|
pub community_id: CommunityId,
|
|
|
|
pub block: bool,
|
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, Clone)]
|
2021-08-19 20:54:15 +00:00
|
|
|
pub struct BlockCommunityResponse {
|
|
|
|
pub community_view: CommunityView,
|
|
|
|
pub blocked: bool,
|
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 TransferCommunity {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub community_id: CommunityId,
|
|
|
|
pub person_id: PersonId,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|