2022-05-06 20:55:07 +00:00
|
|
|
use lemmy_db_schema::{
|
2022-08-18 19:11:19 +00:00
|
|
|
newtypes::{CommentId, CommunityId, DbUrl, LanguageId, PostId, PostReportId},
|
2022-05-06 20:55:07 +00:00
|
|
|
ListingType,
|
2022-12-12 11:17:10 +00:00
|
|
|
PostFeatureType,
|
2022-05-06 20:55:07 +00:00
|
|
|
SortType,
|
|
|
|
};
|
2024-01-03 18:39:21 +00:00
|
|
|
use lemmy_db_views::structs::{PaginationCursor, PostReportView, PostView, VoteView};
|
2022-05-03 17:44:13 +00:00
|
|
|
use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView};
|
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;
|
2021-03-02 12:41:48 +00:00
|
|
|
use url::Url;
|
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
|
|
|
/// Create a post.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct CreatePost {
|
|
|
|
pub name: String,
|
2021-04-15 03:37:51 +00:00
|
|
|
pub community_id: CommunityId,
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(type = "string"))]
|
2021-03-02 12:41:48 +00:00
|
|
|
pub url: Option<Url>,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// An optional body for the post in markdown.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub body: Option<String>,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A honeypot to catch bots. Should be None.
|
2021-10-01 11:37:39 +00:00
|
|
|
pub honeypot: Option<String>,
|
2021-04-15 03:37:51 +00:00
|
|
|
pub nsfw: Option<bool>,
|
2022-08-18 19:11:19 +00:00
|
|
|
pub language_id: Option<LanguageId>,
|
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))]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct PostResponse {
|
2020-12-11 15:27:33 +00:00
|
|
|
pub post_view: PostView,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Get a post. Needs either the post id, or comment_id.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetPost {
|
2022-07-30 03:55:59 +00:00
|
|
|
pub id: Option<PostId>,
|
|
|
|
pub comment_id: Option<CommentId>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2023-10-23 16:40:29 +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 post response.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetPostResponse {
|
2020-12-11 15:27:33 +00:00
|
|
|
pub post_view: PostView,
|
2020-12-23 21:56:20 +00:00
|
|
|
pub community_view: CommunityView,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub moderators: Vec<CommunityModeratorView>,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A list of cross-posts, or other times / communities this link has been posted to.
|
2023-04-19 20:16:19 +00:00
|
|
|
pub cross_posts: Vec<PostView>,
|
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(Serialize, Deserialize, Debug, 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 list of posts.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetPosts {
|
2022-05-06 20:55:07 +00:00
|
|
|
pub type_: Option<ListingType>,
|
|
|
|
pub sort: Option<SortType>,
|
2023-09-18 13:44:48 +00:00
|
|
|
/// DEPRECATED, use page_cursor
|
2020-09-01 14:25:34 +00:00
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
2021-03-18 20:25:21 +00:00
|
|
|
pub community_id: Option<CommunityId>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub community_name: Option<String>,
|
2021-04-15 03:37:51 +00:00
|
|
|
pub saved_only: Option<bool>,
|
2023-08-08 09:40:28 +00:00
|
|
|
pub liked_only: Option<bool>,
|
|
|
|
pub disliked_only: Option<bool>,
|
2023-09-18 13:44:48 +00:00
|
|
|
pub page_cursor: Option<PaginationCursor>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2023-09-20 09:49:26 +00:00
|
|
|
#[skip_serializing_none]
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Serialize, Deserialize, Debug, 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 post list response.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetPostsResponse {
|
|
|
|
pub posts: Vec<PostView>,
|
2023-09-18 13:44:48 +00:00
|
|
|
/// the pagination cursor to use to fetch the next page
|
|
|
|
pub next_page: Option<PaginationCursor>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
/// Like a post.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct CreatePostLike {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub post_id: PostId,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Score must be -1, 0, or 1.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub score: i16,
|
|
|
|
}
|
|
|
|
|
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 post.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct EditPost {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub post_id: PostId,
|
2021-04-15 03:37:51 +00:00
|
|
|
pub name: Option<String>,
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(type = "string"))]
|
2021-03-02 12:41:48 +00:00
|
|
|
pub url: Option<Url>,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// An optional body for the post in markdown.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub body: Option<String>,
|
2021-04-15 03:37:51 +00:00
|
|
|
pub nsfw: Option<bool>,
|
2022-08-18 19:11:19 +00:00
|
|
|
pub language_id: Option<LanguageId>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
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 a post.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct DeletePost {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub post_id: PostId,
|
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 post (only doable by mods).
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct RemovePost {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub post_id: PostId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub removed: bool,
|
|
|
|
pub reason: Option<String>,
|
|
|
|
}
|
|
|
|
|
2023-10-20 00:16:23 +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
|
|
|
/// Mark a post as read.
|
2021-11-23 14:15:43 +00:00
|
|
|
pub struct MarkPostAsRead {
|
2023-10-17 16:35:51 +00:00
|
|
|
/// TODO: deprecated, send `post_ids` instead
|
2023-10-20 00:16:23 +00:00
|
|
|
pub post_id: Option<PostId>,
|
|
|
|
pub post_ids: Option<Vec<PostId>>,
|
2021-11-23 14:15:43 +00:00
|
|
|
pub read: 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
|
|
|
/// Lock a post (prevent new comments).
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct LockPost {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub post_id: PostId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub locked: 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
|
|
|
/// Feature a post (stickies / pins to the top).
|
2022-12-12 11:17:10 +00:00
|
|
|
pub struct FeaturePost {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub post_id: PostId,
|
2022-12-12 11:17:10 +00:00
|
|
|
pub featured: bool,
|
|
|
|
pub feature_type: PostFeatureType,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
/// Save / bookmark a post.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct SavePost {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub post_id: PostId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub save: bool,
|
|
|
|
}
|
2020-09-15 19:26:47 +00:00
|
|
|
|
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
|
|
|
/// Create a post report.
|
2020-10-25 02:59:13 +00:00
|
|
|
pub struct CreatePostReport {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub post_id: PostId,
|
2020-10-25 02:59:13 +00:00
|
|
|
pub reason: String,
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/// The post report response.
|
2021-09-28 10:36:17 +00:00
|
|
|
pub struct PostReportResponse {
|
|
|
|
pub post_report_view: PostReportView,
|
2020-10-25 02:59:13 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
/// Resolve a post report (mods only).
|
2020-10-25 02:59:13 +00:00
|
|
|
pub struct ResolvePostReport {
|
2021-09-28 10:36:17 +00:00
|
|
|
pub report_id: PostReportId,
|
2020-10-25 02:59:13 +00:00
|
|
|
pub resolved: 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
|
|
|
/// List post reports.
|
2020-10-25 02:59:13 +00:00
|
|
|
pub struct ListPostReports {
|
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
2021-09-28 10:36:17 +00:00
|
|
|
/// Only shows the unresolved reports
|
|
|
|
pub unresolved_only: Option<bool>,
|
|
|
|
/// if no community is given, it returns reports for all communities moderated by the auth user
|
|
|
|
pub community_id: Option<CommunityId>,
|
2020-10-25 02:59:13 +00:00
|
|
|
}
|
|
|
|
|
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 post reports response.
|
2020-10-25 02:59:13 +00:00
|
|
|
pub struct ListPostReportsResponse {
|
2021-09-28 10:36:17 +00:00
|
|
|
pub post_reports: Vec<PostReportView>,
|
2020-10-25 02:59:13 +00:00
|
|
|
}
|
2021-08-19 14:12:49 +00:00
|
|
|
|
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
|
|
|
/// Get metadata for a given site.
|
2021-08-19 14:12:49 +00:00
|
|
|
pub struct GetSiteMetadata {
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(type = "string"))]
|
2021-08-19 14:12:49 +00:00
|
|
|
pub url: Url,
|
|
|
|
}
|
|
|
|
|
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 site metadata response.
|
2021-08-19 14:12:49 +00:00
|
|
|
pub struct GetSiteMetadataResponse {
|
2024-01-25 14:22:11 +00:00
|
|
|
pub metadata: LinkMetadata,
|
2021-08-19 14:12:49 +00:00
|
|
|
}
|
2022-05-03 17:44:13 +00:00
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2024-01-25 14:22:11 +00:00
|
|
|
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, 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
|
|
|
/// Site metadata, from its opengraph tags.
|
2024-01-25 14:22:11 +00:00
|
|
|
pub struct LinkMetadata {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub opengraph_data: OpenGraphData,
|
|
|
|
pub content_type: Option<String>,
|
|
|
|
#[serde(skip)]
|
|
|
|
pub thumbnail: Option<DbUrl>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[skip_serializing_none]
|
|
|
|
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone, Default)]
|
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
|
|
/// Site metadata, from its opengraph tags.
|
|
|
|
pub struct OpenGraphData {
|
2022-05-03 17:44:13 +00:00
|
|
|
pub title: Option<String>,
|
|
|
|
pub description: Option<String>,
|
2022-06-02 21:44:47 +00:00
|
|
|
pub(crate) image: Option<DbUrl>,
|
|
|
|
pub embed_video_url: Option<DbUrl>,
|
2022-05-03 17:44:13 +00:00
|
|
|
}
|
2024-01-03 18:39:21 +00:00
|
|
|
|
|
|
|
#[skip_serializing_none]
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
|
|
/// List post likes. Admins-only.
|
|
|
|
pub struct ListPostLikes {
|
|
|
|
pub post_id: PostId,
|
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
|
|
/// The post likes response
|
|
|
|
pub struct ListPostLikesResponse {
|
|
|
|
pub post_likes: Vec<VoteView>,
|
|
|
|
}
|