2021-09-28 10:36:17 +00:00
|
|
|
use lemmy_db_schema::{CommunityId, PostId, PostReportId};
|
2020-12-21 16:30:34 +00:00
|
|
|
use lemmy_db_views::{
|
2020-12-17 03:03:03 +00:00
|
|
|
comment_view::CommentView,
|
|
|
|
post_report_view::PostReportView,
|
|
|
|
post_view::PostView,
|
2020-09-01 14:25:34 +00:00
|
|
|
};
|
2020-12-24 00:09:41 +00:00
|
|
|
use lemmy_db_views_actor::{
|
|
|
|
community_moderator_view::CommunityModeratorView,
|
|
|
|
community_view::CommunityView,
|
|
|
|
};
|
2021-08-19 14:12:49 +00:00
|
|
|
use lemmy_utils::request::SiteMetadata;
|
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
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
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>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(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
|
|
|
}
|
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(Serialize, Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetPost {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub id: PostId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub auth: Option<String>,
|
|
|
|
}
|
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(Serialize, Deserialize)]
|
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,
|
|
|
|
}
|
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetPosts {
|
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>,
|
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>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub auth: Option<String>,
|
|
|
|
}
|
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetPostsResponse {
|
|
|
|
pub posts: Vec<PostView>,
|
|
|
|
}
|
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(Serialize, Deserialize)]
|
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,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(Serialize, Deserialize)]
|
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>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(Serialize, Deserialize)]
|
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,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(Serialize, Deserialize)]
|
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>,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(Serialize, Deserialize)]
|
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,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(Serialize, Deserialize)]
|
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,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(Serialize, Deserialize)]
|
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,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
2020-09-15 19:26:47 +00:00
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(Serialize, Deserialize)]
|
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,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(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
|
|
|
}
|
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(Serialize, Deserialize)]
|
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,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(Serialize, Deserialize)]
|
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
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(Serialize, Deserialize)]
|
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
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
2021-08-19 14:12:49 +00:00
|
|
|
pub struct GetSiteMetadata {
|
|
|
|
pub url: Url,
|
|
|
|
}
|
|
|
|
|
2021-10-19 16:37:01 +00:00
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
2021-08-19 14:12:49 +00:00
|
|
|
pub struct GetSiteMetadataResponse {
|
|
|
|
pub metadata: SiteMetadata,
|
|
|
|
}
|