2022-05-03 17:44:13 +00:00
|
|
|
use crate::sensitive::Sensitive;
|
2022-05-06 20:55:07 +00:00
|
|
|
use lemmy_db_schema::{
|
|
|
|
newtypes::{CommunityId, PostId, PostReportId},
|
|
|
|
ListingType,
|
|
|
|
SortType,
|
|
|
|
};
|
2022-05-03 17:44:13 +00:00
|
|
|
use lemmy_db_views::structs::{CommentView, PostReportView, PostView};
|
|
|
|
use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView};
|
2020-09-01 14:25:34 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
2021-03-02 12:41:48 +00:00
|
|
|
use url::Url;
|
2020-09-01 14:25:34 +00:00
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
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,
|
2021-03-02 12:41:48 +00:00
|
|
|
pub url: Option<Url>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub body: Option<String>,
|
2021-10-01 11:37:39 +00:00
|
|
|
pub honeypot: Option<String>,
|
2021-04-15 03:37:51 +00:00
|
|
|
pub nsfw: 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 PostResponse {
|
2020-12-11 15:27:33 +00:00
|
|
|
pub post_view: PostView,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetPost {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub id: PostId,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Option<Sensitive<String>>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
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 comments: Vec<CommentView>,
|
|
|
|
pub moderators: Vec<CommunityModeratorView>,
|
|
|
|
pub online: usize,
|
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
|
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>,
|
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>,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Option<Sensitive<String>>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetPostsResponse {
|
|
|
|
pub posts: Vec<PostView>,
|
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct CreatePostLike {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub post_id: PostId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub score: i16,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
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>,
|
2021-03-02 12:41:48 +00:00
|
|
|
pub url: Option<Url>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub body: Option<String>,
|
2021-04-15 03:37:51 +00:00
|
|
|
pub nsfw: Option<bool>,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
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,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
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>,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2021-11-23 14:15:43 +00:00
|
|
|
pub struct MarkPostAsRead {
|
|
|
|
pub post_id: PostId,
|
|
|
|
pub read: bool,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2021-11-23 14:15:43 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
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,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct StickyPost {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub post_id: PostId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub stickied: bool,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
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,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
2020-09-15 19:26:47 +00:00
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
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
|
|
|
pub auth: Sensitive<String>,
|
2020-10-25 02:59:13 +00:00
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
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)]
|
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,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-10-25 02:59:13 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
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>,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-10-25 02:59:13 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
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)]
|
2021-08-19 14:12:49 +00:00
|
|
|
pub struct GetSiteMetadata {
|
|
|
|
pub url: Url,
|
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2021-08-19 14:12:49 +00:00
|
|
|
pub struct GetSiteMetadataResponse {
|
|
|
|
pub metadata: SiteMetadata,
|
|
|
|
}
|
2022-05-03 17:44:13 +00:00
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Deserialize, Serialize, PartialEq, Clone)]
|
2022-05-03 17:44:13 +00:00
|
|
|
pub struct SiteMetadata {
|
|
|
|
pub title: Option<String>,
|
|
|
|
pub description: Option<String>,
|
|
|
|
pub(crate) image: Option<Url>,
|
|
|
|
pub html: Option<String>,
|
|
|
|
}
|