use super::post::Post;
use crate::{
naive_now,
- schema::{comment, comment_like, comment_saved},
+ schema::{comment, comment_alias_1, comment_like, comment_saved},
ApubObject,
Crud,
Likeable,
Saveable,
};
use diesel::{dsl::*, result::Error, *};
+use serde::Serialize;
use url::{ParseError, Url};
// WITH RECURSIVE MyTree AS (
// )
// SELECT * FROM MyTree;
-#[derive(Clone, Queryable, Associations, Identifiable, PartialEq, Debug)]
+#[derive(Clone, Queryable, Associations, Identifiable, PartialEq, Debug, Serialize)]
#[belongs_to(Post)]
#[table_name = "comment"]
pub struct Comment {
pub local: bool,
}
+#[derive(Clone, Queryable, Associations, Identifiable, PartialEq, Debug, Serialize)]
+#[belongs_to(Post)]
+#[table_name = "comment_alias_1"]
+pub struct CommentAlias1 {
+ pub id: i32,
+ pub creator_id: i32,
+ pub post_id: i32,
+ pub parent_id: Option<i32>,
+ pub content: String,
+ pub removed: bool,
+ pub read: bool, // Whether the recipient has read the comment or not
+ pub published: chrono::NaiveDateTime,
+ pub updated: Option<chrono::NaiveDateTime>,
+ pub deleted: bool,
+ pub ap_id: String,
+ pub local: bool,
+}
+
#[derive(Insertable, AsChangeset, Clone)]
#[table_name = "comment"]
pub struct CommentForm {
pub id: i32,
pub user_id: i32,
pub comment_id: i32,
- pub post_id: i32,
+ pub post_id: i32, // TODO this is redundant
pub score: i16,
pub published: chrono::NaiveDateTime,
}
pub struct CommentLikeForm {
pub user_id: i32,
pub comment_id: i32,
- pub post_id: i32,
+ pub post_id: i32, // TODO this is redundant
pub score: i16,
}
#[cfg(test)]
mod tests {
use crate::{
- comment::*,
- community::*,
- post::*,
+ source::{comment::*, community::*, post::*, user::*},
tests::establish_unpooled_connection,
- user::*,
Crud,
ListingType,
SortType,