2020-12-06 07:12:51 -07:00
|
|
|
use lemmy_db::views::{
|
2020-12-16 14:28:18 -07:00
|
|
|
community::{
|
|
|
|
community_follower_view::CommunityFollowerView,
|
|
|
|
community_moderator_view::CommunityModeratorView,
|
|
|
|
community_view::CommunityView,
|
|
|
|
},
|
2020-12-06 07:12:51 -07:00
|
|
|
user_view::UserViewSafe,
|
2020-09-01 08:25:34 -06:00
|
|
|
};
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct GetCommunity {
|
|
|
|
pub id: Option<i32>,
|
|
|
|
pub name: Option<String>,
|
|
|
|
pub auth: Option<String>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Serialize)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct GetCommunityResponse {
|
2020-12-06 07:12:51 -07:00
|
|
|
pub community_view: CommunityView,
|
2020-09-01 08:25:34 -06:00
|
|
|
pub moderators: Vec<CommunityModeratorView>,
|
|
|
|
pub online: usize,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct CreateCommunity {
|
|
|
|
pub name: String,
|
|
|
|
pub title: String,
|
|
|
|
pub description: Option<String>,
|
|
|
|
pub icon: Option<String>,
|
|
|
|
pub banner: Option<String>,
|
|
|
|
pub category_id: i32,
|
|
|
|
pub nsfw: bool,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Serialize, Clone)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct CommunityResponse {
|
2020-12-06 07:12:51 -07:00
|
|
|
pub community_view: CommunityView,
|
2020-09-01 08:25:34 -06:00
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Deserialize, Debug)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct ListCommunities {
|
|
|
|
pub sort: String,
|
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
|
|
|
pub auth: Option<String>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Serialize, Debug)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct ListCommunitiesResponse {
|
|
|
|
pub communities: Vec<CommunityView>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Deserialize, Clone)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct BanFromCommunity {
|
|
|
|
pub community_id: i32,
|
|
|
|
pub user_id: i32,
|
|
|
|
pub ban: bool,
|
|
|
|
pub remove_data: Option<bool>,
|
|
|
|
pub reason: Option<String>,
|
|
|
|
pub expires: Option<i64>,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Serialize, Clone)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct BanFromCommunityResponse {
|
2020-12-06 07:12:51 -07:00
|
|
|
pub user_view: UserViewSafe,
|
2020-09-01 08:25:34 -06:00
|
|
|
pub banned: bool,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct AddModToCommunity {
|
|
|
|
pub community_id: i32,
|
|
|
|
pub user_id: i32,
|
|
|
|
pub added: bool,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Serialize, Clone)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct AddModToCommunityResponse {
|
|
|
|
pub moderators: Vec<CommunityModeratorView>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct EditCommunity {
|
|
|
|
pub edit_id: i32,
|
|
|
|
pub title: String,
|
|
|
|
pub description: Option<String>,
|
|
|
|
pub icon: Option<String>,
|
|
|
|
pub banner: Option<String>,
|
|
|
|
pub category_id: i32,
|
|
|
|
pub nsfw: bool,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct DeleteCommunity {
|
|
|
|
pub edit_id: i32,
|
|
|
|
pub deleted: bool,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct RemoveCommunity {
|
|
|
|
pub edit_id: i32,
|
|
|
|
pub removed: bool,
|
|
|
|
pub reason: Option<String>,
|
|
|
|
pub expires: Option<i64>,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct FollowCommunity {
|
|
|
|
pub community_id: i32,
|
|
|
|
pub follow: bool,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct GetFollowedCommunities {
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Serialize)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct GetFollowedCommunitiesResponse {
|
|
|
|
pub communities: Vec<CommunityFollowerView>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct TransferCommunity {
|
|
|
|
pub community_id: i32,
|
|
|
|
pub user_id: i32,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
2020-09-15 13:26:47 -06:00
|
|
|
|
|
|
|
#[derive(Deserialize, Debug)]
|
|
|
|
pub struct CommunityJoin {
|
|
|
|
pub community_id: i32,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Clone)]
|
|
|
|
pub struct CommunityJoinResponse {
|
|
|
|
pub joined: bool,
|
|
|
|
}
|
2020-10-26 18:25:18 -06:00
|
|
|
|
|
|
|
#[derive(Deserialize, Debug)]
|
|
|
|
pub struct ModJoin {
|
|
|
|
pub community_id: i32,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Clone)]
|
|
|
|
pub struct ModJoinResponse {
|
|
|
|
pub joined: bool,
|
|
|
|
}
|