2021-03-18 20:25:21 +00:00
|
|
|
use lemmy_db_schema::{CommunityId, PostId};
|
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,
|
|
|
|
};
|
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
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize, Debug)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct CreatePost {
|
|
|
|
pub name: 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>,
|
|
|
|
pub nsfw: bool,
|
2021-03-18 20:25:21 +00:00
|
|
|
pub community_id: CommunityId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub auth: String,
|
2021-04-16 15:02:23 +00:00
|
|
|
pub language: String,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize, 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
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(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>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize)]
|
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,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize, Debug)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetPosts {
|
|
|
|
pub type_: String,
|
|
|
|
pub sort: String,
|
|
|
|
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-03-22 14:39:54 +00:00
|
|
|
pub saved_only: bool,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub auth: Option<String>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize, Debug)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetPostsResponse {
|
|
|
|
pub posts: Vec<PostView>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(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,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct EditPost {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub post_id: PostId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub name: 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>,
|
|
|
|
pub nsfw: bool,
|
|
|
|
pub auth: String,
|
2021-04-16 15:02:23 +00:00
|
|
|
pub language: String,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(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,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(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,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(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,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(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,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(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
|
|
|
|
2020-10-25 02:59:13 +00:00
|
|
|
#[derive(Serialize, Deserialize)]
|
|
|
|
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,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Clone)]
|
|
|
|
pub struct CreatePostReportResponse {
|
|
|
|
pub success: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub struct ResolvePostReport {
|
|
|
|
pub report_id: i32,
|
|
|
|
pub resolved: bool,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
|
|
|
pub struct ResolvePostReportResponse {
|
|
|
|
pub report_id: i32,
|
|
|
|
pub resolved: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub struct ListPostReports {
|
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
2021-03-18 20:25:21 +00:00
|
|
|
pub community: Option<CommunityId>,
|
2020-10-25 02:59:13 +00:00
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-12-17 03:03:03 +00:00
|
|
|
#[derive(Serialize, Clone, Debug)]
|
2020-10-25 02:59:13 +00:00
|
|
|
pub struct ListPostReportsResponse {
|
|
|
|
pub posts: Vec<PostReportView>,
|
|
|
|
}
|