New pattern for comment creation in code

Use the builder design pattern to build a NewComment

Add a function to transform a NewComment into a Create activity

Virtually send this activity to the shared inbox of the instance
This commit is contained in:
Bat
2018-06-21 11:28:42 +01:00
parent db5ca8f453
commit e6b8943085
6 changed files with 103 additions and 50 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ use safe_string::SafeString;
fn details(blog: String, slug: String, conn: DbConn, user: Option<User>) -> Template {
may_fail!(Blog::find_by_fqn(&*conn, blog), "Couldn't find this blog", |blog| {
may_fail!(Post::find_by_slug(&*conn, slug, blog.id), "Couldn't find this post", |post| {
let comments = Comment::find_by_post(&*conn, post.id);
let comments = Comment::list_by_post(&*conn, post.id);
Template::render("posts/details", json!({
"author": post.get_authors(&*conn)[0].to_json(&*conn),