1 use crate::newtypes::{CommentId, DbUrl, LanguageId, LtreeDef, PersonId, PostId};
2 use diesel_ltree::Ltree;
3 use serde::{Deserialize, Serialize};
5 #[cfg(feature = "full")]
6 use crate::schema::{comment, comment_like, comment_saved};
8 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
9 #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
10 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::post::Post)))]
11 #[cfg_attr(feature = "full", diesel(table_name = comment))]
14 pub creator_id: PersonId,
18 pub published: chrono::NaiveDateTime,
19 pub updated: Option<chrono::NaiveDateTime>,
23 #[serde(with = "LtreeDef")]
25 pub distinguished: bool,
26 pub language_id: LanguageId,
29 #[derive(Clone, Default)]
30 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
31 #[cfg_attr(feature = "full", diesel(table_name = comment))]
32 pub struct CommentForm {
33 pub creator_id: PersonId,
36 pub removed: Option<bool>,
37 pub published: Option<chrono::NaiveDateTime>,
38 pub updated: Option<chrono::NaiveDateTime>,
39 pub deleted: Option<bool>,
40 pub ap_id: Option<DbUrl>,
41 pub local: Option<bool>,
42 pub distinguished: Option<bool>,
43 pub language_id: Option<LanguageId>,
46 #[derive(PartialEq, Eq, Debug, Clone)]
47 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
48 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::comment::Comment)))]
49 #[cfg_attr(feature = "full", diesel(table_name = comment_like))]
50 pub struct CommentLike {
52 pub person_id: PersonId,
53 pub comment_id: CommentId,
54 pub post_id: PostId, // TODO this is redundant
56 pub published: chrono::NaiveDateTime,
60 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
61 #[cfg_attr(feature = "full", diesel(table_name = comment_like))]
62 pub struct CommentLikeForm {
63 pub person_id: PersonId,
64 pub comment_id: CommentId,
65 pub post_id: PostId, // TODO this is redundant
69 #[derive(PartialEq, Eq, Debug)]
70 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
71 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::comment::Comment)))]
72 #[cfg_attr(feature = "full", diesel(table_name = comment_saved))]
73 pub struct CommentSaved {
75 pub comment_id: CommentId,
76 pub person_id: PersonId,
77 pub published: chrono::NaiveDateTime,
80 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
81 #[cfg_attr(feature = "full", diesel(table_name = comment_saved))]
82 pub struct CommentSavedForm {
83 pub comment_id: CommentId,
84 pub person_id: PersonId,