2022-04-13 16:37:54 +00:00
|
|
|
use lemmy_db_schema::{
|
2022-10-06 18:27:58 +00:00
|
|
|
newtypes::{CommunityId, LanguageId, PersonId},
|
2022-04-13 16:37:54 +00:00
|
|
|
source::site::Site,
|
2024-01-25 16:04:25 +00:00
|
|
|
CommunityVisibility,
|
2022-05-06 20:55:07 +00:00
|
|
|
ListingType,
|
|
|
|
SortType,
|
2022-04-13 16:37:54 +00:00
|
|
|
};
|
2023-10-20 00:15:55 +00:00
|
|
|
use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView, PersonView};
|
2020-09-01 14:25:34 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
2023-04-26 04:26:10 +00:00
|
|
|
use serde_with::skip_serializing_none;
|
|
|
|
#[cfg(feature = "full")]
|
|
|
|
use ts_rs::TS;
|
2020-09-01 14:25:34 +00:00
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Get a community. Must provide either an id, or a name.
|
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>,
|
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The community response.
|
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>,
|
2022-10-06 18:27:58 +00:00
|
|
|
pub discussion_languages: Vec<LanguageId>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Create a community.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct CreateCommunity {
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The unique name.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub name: String,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A longer title.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub title: String,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A longer sidebar, or description of your community, in markdown.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub description: Option<String>,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// An icon URL.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub icon: Option<String>,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A banner URL.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub banner: Option<String>,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Whether its an NSFW community.
|
2021-03-20 20:59:07 +00:00
|
|
|
pub nsfw: Option<bool>,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Whether to restrict posting only to moderators.
|
2022-04-29 14:01:10 +00:00
|
|
|
pub posting_restricted_to_mods: Option<bool>,
|
2022-12-19 11:40:22 +00:00
|
|
|
pub discussion_languages: Option<Vec<LanguageId>>,
|
2024-01-25 16:04:25 +00:00
|
|
|
pub visibility: Option<CommunityVisibility>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A simple community response.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct CommunityResponse {
|
2020-12-06 14:12:51 +00:00
|
|
|
pub community_view: CommunityView,
|
2022-12-19 11:40:22 +00:00
|
|
|
pub discussion_languages: Vec<LanguageId>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Fetches a list of communities.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct ListCommunities {
|
2022-05-06 20:55:07 +00:00
|
|
|
pub type_: Option<ListingType>,
|
|
|
|
pub sort: Option<SortType>,
|
2023-06-27 10:45:26 +00:00
|
|
|
pub show_nsfw: Option<bool>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The response for listing communities.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct ListCommunitiesResponse {
|
|
|
|
pub communities: Vec<CommunityView>,
|
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Ban a user from a community.
|
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>,
|
2024-01-25 15:45:42 +00:00
|
|
|
/// A time that the ban will expire, in unix epoch seconds.
|
|
|
|
///
|
|
|
|
/// An i64 unix timestamp is used for a simpler API client implementation.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub expires: Option<i64>,
|
|
|
|
}
|
|
|
|
|
2023-10-20 00:15:55 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
|
|
/// The response for banning a user from a community.
|
|
|
|
pub struct BanFromCommunityResponse {
|
|
|
|
pub person_view: PersonView,
|
|
|
|
pub banned: bool,
|
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Add a moderator to a community.
|
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,
|
|
|
|
}
|
|
|
|
|
2023-10-20 00:15:55 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
|
|
/// The response of adding a moderator to a community.
|
|
|
|
pub struct AddModToCommunityResponse {
|
|
|
|
pub moderators: Vec<CommunityModeratorView>,
|
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Edit a community.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct EditCommunity {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub community_id: CommunityId,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A longer title.
|
2021-04-15 03:37:51 +00:00
|
|
|
pub title: Option<String>,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A longer sidebar, or description of your community, in markdown.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub description: Option<String>,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// An icon URL.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub icon: Option<String>,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A banner URL.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub banner: Option<String>,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Whether its an NSFW community.
|
2021-03-20 20:59:07 +00:00
|
|
|
pub nsfw: Option<bool>,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Whether to restrict posting only to moderators.
|
2022-04-29 14:01:10 +00:00
|
|
|
pub posting_restricted_to_mods: Option<bool>,
|
2022-10-06 18:27:58 +00:00
|
|
|
pub discussion_languages: Option<Vec<LanguageId>>,
|
2024-01-25 16:04:25 +00:00
|
|
|
pub visibility: Option<CommunityVisibility>,
|
2022-02-18 02:30:47 +00:00
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Hide a community from the main view.
|
2022-02-18 02:30:47 +00:00
|
|
|
pub struct HideCommunity {
|
|
|
|
pub community_id: CommunityId,
|
|
|
|
pub hidden: bool,
|
|
|
|
pub reason: Option<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Delete your own community.
|
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,
|
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Remove a community (only doable by moderators).
|
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>,
|
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Follow / subscribe to a community.
|
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,
|
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Block a community.
|
2021-08-19 20:54:15 +00:00
|
|
|
pub struct BlockCommunity {
|
|
|
|
pub community_id: CommunityId,
|
|
|
|
pub block: bool,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2023-10-20 00:15:55 +00:00
|
|
|
#[skip_serializing_none]
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
|
|
/// The block community response.
|
|
|
|
pub struct BlockCommunityResponse {
|
|
|
|
pub community_view: CommunityView,
|
|
|
|
pub blocked: bool,
|
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Transfer a community to a new owner.
|
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
|
|
|
}
|