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