]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/post_report.rs
Adding typescript generation for API. Fixes #2824 (#2827)
[lemmy.git] / crates / db_schema / src / source / post_report.rs
1 use crate::newtypes::{DbUrl, PersonId, PostId, PostReportId};
2 #[cfg(feature = "full")]
3 use crate::schema::post_report;
4 use serde::{Deserialize, Serialize};
5 use serde_with::skip_serializing_none;
6 #[cfg(feature = "full")]
7 use ts_rs::TS;
8
9 #[skip_serializing_none]
10 #[derive(PartialEq, Eq, Serialize, Deserialize, Debug, Clone)]
11 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations, TS))]
12 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::post::Post)))] // Is this the right assoc?
13 #[cfg_attr(feature = "full", diesel(table_name = post_report))]
14 #[cfg_attr(feature = "full", ts(export))]
15 pub struct PostReport {
16   pub id: PostReportId,
17   pub creator_id: PersonId,
18   pub post_id: PostId,
19   pub original_post_name: String,
20   pub original_post_url: Option<DbUrl>,
21   pub original_post_body: Option<String>,
22   pub reason: String,
23   pub resolved: bool,
24   pub resolver_id: Option<PersonId>,
25   pub published: chrono::NaiveDateTime,
26   pub updated: Option<chrono::NaiveDateTime>,
27 }
28
29 #[derive(Clone)]
30 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
31 #[cfg_attr(feature = "full", diesel(table_name = post_report))]
32 pub struct PostReportForm {
33   pub creator_id: PersonId,
34   pub post_id: PostId,
35   pub original_post_name: String,
36   pub original_post_url: Option<DbUrl>,
37   pub original_post_body: Option<String>,
38   pub reason: String,
39 }