2021-03-18 20:25:21 +00:00
|
|
|
use lemmy_db_schema::{CommunityId, PersonId};
|
2020-12-21 23:27:42 +00:00
|
|
|
use lemmy_db_views_actor::{
|
|
|
|
community_follower_view::CommunityFollowerView,
|
|
|
|
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
|
|
|
};
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(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>,
|
|
|
|
pub auth: Option<String>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetCommunityResponse {
|
2020-12-06 14:12:51 +00:00
|
|
|
pub community_view: CommunityView,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub moderators: Vec<CommunityModeratorView>,
|
|
|
|
pub online: usize,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(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>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize, 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
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(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>,
|
|
|
|
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 ListCommunitiesResponse {
|
|
|
|
pub communities: Vec<CommunityView>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(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>,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize, 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,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(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,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize, Clone)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct AddModToCommunityResponse {
|
|
|
|
pub moderators: Vec<CommunityModeratorView>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(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>,
|
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 DeleteCommunity {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub community_id: CommunityId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub deleted: bool,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(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>,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(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,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetFollowedCommunities {
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetFollowedCommunitiesResponse {
|
|
|
|
pub communities: Vec<CommunityFollowerView>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(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,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub auth: String,
|
|
|
|
}
|