From 5a5c1a8d994e0b76618c863f3a5af361978e2470 Mon Sep 17 00:00:00 2001 From: Bat Date: Thu, 21 Jun 2018 11:38:07 +0100 Subject: [PATCH] List all comments --- src/models/comments.rs | 4 ++-- src/routes/comments.rs | 17 +---------------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/src/models/comments.rs b/src/models/comments.rs index ae6bcf35..2829b707 100644 --- a/src/models/comments.rs +++ b/src/models/comments.rs @@ -1,7 +1,7 @@ use activitypub::{ activity::Create, link, - object::{Note, properties::ObjectProperties} + object::{Note} }; use chrono; use diesel::{self, PgConnection, RunQueryDsl, QueryDsl, ExpressionMethods, dsl::any}; @@ -51,7 +51,7 @@ pub struct NewComment { impl Comment { insert!(comments, NewComment); get!(comments); - find_by!(comments, find_by_post, post_id as i32); + list_by!(comments, list_by_post, post_id as i32); find_by!(comments, find_by_ap_url, ap_url as String); pub fn get_author(&self, conn: &PgConnection) -> User { diff --git a/src/routes/comments.rs b/src/routes/comments.rs index 171701a1..a2eddaf9 100644 --- a/src/routes/comments.rs +++ b/src/routes/comments.rs @@ -5,7 +5,7 @@ use rocket::{ use rocket_contrib::Template; use serde_json; -use activity_pub::{broadcast, inbox::Inbox, inbox::Notify}; +use activity_pub::{broadcast, inbox::Inbox}; use db_conn::DbConn; use models::{ blogs::Blog, @@ -55,7 +55,6 @@ fn create_response(blog_name: String, slug: String, query: Option, let blog = Blog::find_by_fqn(&*conn, blog_name.clone()).unwrap(); let post = Post::find_by_slug(&*conn, slug.clone(), blog.id).unwrap(); let form = data.get(); -<<<<<<< HEAD let (new_comment, id) = NewComment::build() .content(form.content.clone()) @@ -68,20 +67,6 @@ fn create_response(blog_name: String, slug: String, query: Option, let instance = Instance::get_local(&*conn).unwrap(); instance.received(&*conn, serde_json::to_value(new_comment.clone()).expect("JSON serialization error")); broadcast(&*conn, &user, new_comment, user.get_followers(&*conn)); -======= - let comment = Comment::insert(&*conn, NewComment { - content: SafeString::new(&form.content.clone()), - in_response_to_id: query.responding_to, - post_id: post.id, - author_id: user.id, - ap_url: None, // TODO: set it - sensitive: false, - spoiler_text: "".to_string() - }); - comment.notify(&*conn); - - broadcast(&*conn, &user, comment.create_activity(&*conn), user.get_followers(&*conn)); ->>>>>>> dbdcbe71049e181c1c7649169c0153b3c9d81ad8 Redirect::to(format!("/~/{}/{}/#comment-{}", blog_name, slug, id)) }