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::{ use activitypub::{
activity::Create, activity::Create,
link, link,
object::{Note, properties::ObjectProperties} object::{Note}
}; };
use chrono; use chrono;
use diesel::{self, PgConnection, RunQueryDsl, QueryDsl, ExpressionMethods, dsl::any}; use diesel::{self, PgConnection, RunQueryDsl, QueryDsl, ExpressionMethods, dsl::any};
@ -51,7 +51,7 @@ pub struct NewComment {
impl Comment { impl Comment {
insert!(comments, NewComment); insert!(comments, NewComment);
get!(comments); 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); find_by!(comments, find_by_ap_url, ap_url as String);
pub fn get_author(&self, conn: &PgConnection) -> User { pub fn get_author(&self, conn: &PgConnection) -> User {

View File

@ -5,7 +5,7 @@ use rocket::{
use rocket_contrib::Template; use rocket_contrib::Template;
use serde_json; use serde_json;
use activity_pub::{broadcast, inbox::Inbox, inbox::Notify}; use activity_pub::{broadcast, inbox::Inbox};
use db_conn::DbConn; use db_conn::DbConn;
use models::{ use models::{
blogs::Blog, 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 blog = Blog::find_by_fqn(&*conn, blog_name.clone()).unwrap();
let post = Post::find_by_slug(&*conn, slug.clone(), blog.id).unwrap(); let post = Post::find_by_slug(&*conn, slug.clone(), blog.id).unwrap();
let form = data.get(); let form = data.get();
<<<<<<< HEAD
let (new_comment, id) = NewComment::build() let (new_comment, id) = NewComment::build()
.content(form.content.clone()) .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(); let instance = Instance::get_local(&*conn).unwrap();
instance.received(&*conn, serde_json::to_value(new_comment.clone()).expect("JSON serialization error")); instance.received(&*conn, serde_json::to_value(new_comment.clone()).expect("JSON serialization error"));
broadcast(&*conn, &user, new_comment, user.get_followers(&*conn)); 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)) Redirect::to(format!("/~/{}/{}/#comment-{}", blog_name, slug, id))
} }