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")]
27 #[derive(Clone, Default)]
28 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
29 #[cfg_attr(feature = "full", table_name = "comment")]
30 pub struct CommentForm {
31 pub creator_id: PersonId,
34 pub removed: Option<bool>,
35 pub published: Option<chrono::NaiveDateTime>,
36 pub updated: Option<chrono::NaiveDateTime>,
37 pub deleted: Option<bool>,
38 pub ap_id: Option<DbUrl>,
39 pub local: Option<bool>,
42 #[derive(PartialEq, Debug, Clone)]
43 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
44 #[cfg_attr(feature = "full", belongs_to(Comment))]
45 #[cfg_attr(feature = "full", table_name = "comment_like")]
46 pub struct CommentLike {
48 pub person_id: PersonId,
49 pub comment_id: CommentId,
50 pub post_id: PostId, // TODO this is redundant
52 pub published: chrono::NaiveDateTime,
56 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
57 #[cfg_attr(feature = "full", table_name = "comment_like")]
58 pub struct CommentLikeForm {
59 pub person_id: PersonId,
60 pub comment_id: CommentId,
61 pub post_id: PostId, // TODO this is redundant
65 #[derive(PartialEq, Debug)]
66 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
67 #[cfg_attr(feature = "full", belongs_to(Comment))]
68 #[cfg_attr(feature = "full", table_name = "comment_saved")]
69 pub struct CommentSaved {
71 pub comment_id: CommentId,
72 pub person_id: PersonId,
73 pub published: chrono::NaiveDateTime,
76 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
77 #[cfg_attr(feature = "full", table_name = "comment_saved")]
78 pub struct CommentSavedForm {
79 pub comment_id: CommentId,
80 pub person_id: PersonId,