2 newtypes::{CommentId, DbUrl, PersonId, PostId},
3 schema::{comment, comment_alias_1, comment_like, comment_saved},
6 use serde::{Deserialize, Serialize};
8 // WITH RECURSIVE MyTree AS (
9 // SELECT * FROM comment WHERE parent_id IS NULL
11 // SELECT m.* FROM comment AS m JOIN MyTree AS t ON m.parent_id = t.id
13 // SELECT * FROM MyTree;
16 Clone, Queryable, Associations, Identifiable, PartialEq, Debug, Serialize, Deserialize,
19 #[table_name = "comment"]
22 pub creator_id: PersonId,
24 pub parent_id: Option<CommentId>,
27 pub read: bool, // Whether the recipient has read the comment or not
28 pub published: chrono::NaiveDateTime,
29 pub updated: Option<chrono::NaiveDateTime>,
36 Clone, Queryable, Associations, Identifiable, PartialEq, Debug, Serialize, Deserialize,
39 #[table_name = "comment_alias_1"]
40 pub struct CommentAlias1 {
42 pub creator_id: PersonId,
44 pub parent_id: Option<CommentId>,
47 pub read: bool, // Whether the recipient has read the comment or not
48 pub published: chrono::NaiveDateTime,
49 pub updated: Option<chrono::NaiveDateTime>,
55 #[derive(Insertable, AsChangeset, Clone, Default)]
56 #[table_name = "comment"]
57 pub struct CommentForm {
58 pub creator_id: PersonId,
61 pub parent_id: Option<CommentId>,
62 pub removed: Option<bool>,
63 pub read: Option<bool>,
64 pub published: Option<chrono::NaiveDateTime>,
65 pub updated: Option<chrono::NaiveDateTime>,
66 pub deleted: Option<bool>,
67 pub ap_id: Option<DbUrl>,
68 pub local: Option<bool>,
71 #[derive(Identifiable, Queryable, Associations, PartialEq, Debug, Clone)]
72 #[belongs_to(Comment)]
73 #[table_name = "comment_like"]
74 pub struct CommentLike {
76 pub person_id: PersonId,
77 pub comment_id: CommentId,
78 pub post_id: PostId, // TODO this is redundant
80 pub published: chrono::NaiveDateTime,
83 #[derive(Insertable, AsChangeset, Clone)]
84 #[table_name = "comment_like"]
85 pub struct CommentLikeForm {
86 pub person_id: PersonId,
87 pub comment_id: CommentId,
88 pub post_id: PostId, // TODO this is redundant
92 #[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
93 #[belongs_to(Comment)]
94 #[table_name = "comment_saved"]
95 pub struct CommentSaved {
97 pub comment_id: CommentId,
98 pub person_id: PersonId,
99 pub published: chrono::NaiveDateTime,
102 #[derive(Insertable, AsChangeset)]
103 #[table_name = "comment_saved"]
104 pub struct CommentSavedForm {
105 pub comment_id: CommentId,
106 pub person_id: PersonId,