List all comments

This commit is contained in:
Bat 2018-06-21 11:38:07 +01:00
parent b0e70a42a9
commit 5a5c1a8d99
2 changed files with 3 additions and 18 deletions

View file

@ -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 {

View file

@ -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<CommentQuery>,
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<CommentQuery>,
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))
}