2022-05-03 17:44:13 +00:00
|
|
|
use crate::newtypes::{DbUrl, PersonId, PostId, PostReportId};
|
|
|
|
#[cfg(feature = "full")]
|
|
|
|
use crate::schema::post_report;
|
2023-08-24 15:27:00 +00:00
|
|
|
use chrono::{DateTime, Utc};
|
2022-11-02 19:18:22 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
2023-04-26 04:26:10 +00:00
|
|
|
use serde_with::skip_serializing_none;
|
|
|
|
#[cfg(feature = "full")]
|
|
|
|
use ts_rs::TS;
|
2022-05-03 17:44:13 +00:00
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2022-09-26 14:09:32 +00:00
|
|
|
#[derive(PartialEq, Eq, Serialize, Deserialize, Debug, Clone)]
|
2023-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(
|
|
|
|
feature = "full",
|
|
|
|
derive(Identifiable, Queryable, Selectable, Associations, TS)
|
|
|
|
)]
|
2022-09-26 14:09:32 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::post::Post)))] // Is this the right assoc?
|
|
|
|
#[cfg_attr(feature = "full", diesel(table_name = post_report))]
|
2023-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A post report.
|
2020-12-21 13:38:34 +00:00
|
|
|
pub struct PostReport {
|
2021-09-28 10:36:17 +00:00
|
|
|
pub id: PostReportId,
|
2021-03-18 20:25:21 +00:00
|
|
|
pub creator_id: PersonId,
|
|
|
|
pub post_id: PostId,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The original post title.
|
2020-12-21 13:38:34 +00:00
|
|
|
pub original_post_name: String,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The original post url.
|
2021-03-02 12:41:48 +00:00
|
|
|
pub original_post_url: Option<DbUrl>,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The original post body.
|
2020-12-21 13:38:34 +00:00
|
|
|
pub original_post_body: Option<String>,
|
|
|
|
pub reason: String,
|
|
|
|
pub resolved: bool,
|
2021-03-18 20:25:21 +00:00
|
|
|
pub resolver_id: Option<PersonId>,
|
2023-08-24 15:27:00 +00:00
|
|
|
pub published: DateTime<Utc>,
|
|
|
|
pub updated: Option<DateTime<Utc>>,
|
2020-12-21 13:38:34 +00:00
|
|
|
}
|
|
|
|
|
2023-08-08 15:19:55 +00:00
|
|
|
#[derive(Clone, Default)]
|
2022-05-03 17:44:13 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
2022-09-26 14:09:32 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(table_name = post_report))]
|
2020-12-21 13:38:34 +00:00
|
|
|
pub struct PostReportForm {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub creator_id: PersonId,
|
|
|
|
pub post_id: PostId,
|
2020-12-21 13:38:34 +00:00
|
|
|
pub original_post_name: String,
|
2021-03-02 12:41:48 +00:00
|
|
|
pub original_post_url: Option<DbUrl>,
|
2020-12-21 13:38:34 +00:00
|
|
|
pub original_post_body: Option<String>,
|
|
|
|
pub reason: String,
|
|
|
|
}
|