1 use crate::newtypes::{CommentId, DbUrl, 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, Debug, Serialize, Deserialize)]
9 #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
10 #[cfg_attr(feature = "full", belongs_to(crate::source::post::Post))]
11 #[cfg_attr(feature = "full", 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,
28 #[derive(Clone, Default)]
29 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
30 #[cfg_attr(feature = "full", table_name = "comment")]
31 pub struct CommentForm {
32 pub creator_id: PersonId,
35 pub removed: Option<bool>,
36 pub published: Option<chrono::NaiveDateTime>,
37 pub updated: Option<chrono::NaiveDateTime>,
38 pub deleted: Option<bool>,
39 pub ap_id: Option<DbUrl>,
40 pub local: Option<bool>,
41 pub distinguished: Option<bool>,
44 #[derive(PartialEq, Debug, Clone)]
45 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
46 #[cfg_attr(feature = "full", belongs_to(Comment))]
47 #[cfg_attr(feature = "full", table_name = "comment_like")]
48 pub struct CommentLike {
50 pub person_id: PersonId,
51 pub comment_id: CommentId,
52 pub post_id: PostId, // TODO this is redundant
54 pub published: chrono::NaiveDateTime,
58 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
59 #[cfg_attr(feature = "full", table_name = "comment_like")]
60 pub struct CommentLikeForm {
61 pub person_id: PersonId,
62 pub comment_id: CommentId,
63 pub post_id: PostId, // TODO this is redundant
67 #[derive(PartialEq, Debug)]
68 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
69 #[cfg_attr(feature = "full", belongs_to(Comment))]
70 #[cfg_attr(feature = "full", table_name = "comment_saved")]
71 pub struct CommentSaved {
73 pub comment_id: CommentId,
74 pub person_id: PersonId,
75 pub published: chrono::NaiveDateTime,
78 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
79 #[cfg_attr(feature = "full", table_name = "comment_saved")]
80 pub struct CommentSavedForm {
81 pub comment_id: CommentId,
82 pub person_id: PersonId,