]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/post_report.rs
Automatically resolve report when post/comment is removed (#3850)
[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 /// A post report.
16 pub struct PostReport {
17   pub id: PostReportId,
18   pub creator_id: PersonId,
19   pub post_id: PostId,
20   /// The original post title.
21   pub original_post_name: String,
22   /// The original post url.
23   pub original_post_url: Option<DbUrl>,
24   /// The original post body.
25   pub original_post_body: Option<String>,
26   pub reason: String,
27   pub resolved: bool,
28   pub resolver_id: Option<PersonId>,
29   pub published: chrono::NaiveDateTime,
30   pub updated: Option<chrono::NaiveDateTime>,
31 }
32
33 #[derive(Clone, Default)]
34 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
35 #[cfg_attr(feature = "full", diesel(table_name = post_report))]
36 pub struct PostReportForm {
37   pub creator_id: PersonId,
38   pub post_id: PostId,
39   pub original_post_name: String,
40   pub original_post_url: Option<DbUrl>,
41   pub original_post_body: Option<String>,
42   pub reason: String,
43 }