Commit cc0ef24e by Rocky Duan

return username for display

parent 3ce012bb
...@@ -47,6 +47,7 @@ class Comment < Content ...@@ -47,6 +47,7 @@ class Comment < Content
as_document.slice(*%w[body course_id endorsed anonymous created_at updated_at at_position_list]) as_document.slice(*%w[body course_id endorsed anonymous created_at updated_at at_position_list])
.merge("id" => _id) .merge("id" => _id)
.merge("user_id" => author.id) .merge("user_id" => author.id)
.merge("username" => author.username)
.merge("depth" => depth) .merge("depth" => depth)
.merge("thread_id" => comment_thread.id) .merge("thread_id" => comment_thread.id)
.merge("votes" => votes.slice(*%w[count up_count down_count point])) .merge("votes" => votes.slice(*%w[count up_count down_count point]))
......
...@@ -80,6 +80,7 @@ class CommentThread < Content ...@@ -80,6 +80,7 @@ class CommentThread < Content
doc = as_document.slice(*%w[title body course_id anonymous commentable_id created_at updated_at at_position_list]) doc = as_document.slice(*%w[title body course_id anonymous commentable_id created_at updated_at at_position_list])
.merge("id" => _id) .merge("id" => _id)
.merge("user_id" => author.id) .merge("user_id" => author.id)
.merge("username" => author.username)
.merge("votes" => votes.slice(*%w[count up_count down_count point])) .merge("votes" => votes.slice(*%w[count up_count down_count point]))
.merge("tags" => tags_array) .merge("tags" => tags_array)
......
...@@ -30,6 +30,7 @@ class AtUserObserver < Mongoid::Observer ...@@ -30,6 +30,7 @@ class AtUserObserver < Mongoid::Observer
content_id: content.id, content_id: content.id,
content_type: content_type, content_type: content_type,
thread_title: content_type == :thread ? content.title : content.comment_thread.title, thread_title: content_type == :thread ? content.title : content.comment_thread.title,
actor_username: (content.author.username if not content.anonymous),
} }
) )
notification.actor = content.author if not content.anonymous notification.actor = content.author if not content.anonymous
......
...@@ -14,6 +14,7 @@ class PostReplyObserver < Mongoid::Observer ...@@ -14,6 +14,7 @@ class PostReplyObserver < Mongoid::Observer
thread_title: comment.comment_thread.title, thread_title: comment.comment_thread.title,
comment_id: comment.id, comment_id: comment.id,
commentable_id: comment.comment_thread.commentable_id, commentable_id: comment.comment_thread.commentable_id,
actor_username: (comment.author.username if not comment.anonymous),
}, },
) )
notification.actor = comment.author if not comment.anonymous notification.actor = comment.author if not comment.anonymous
......
...@@ -14,6 +14,7 @@ class PostTopicObserver < Mongoid::Observer ...@@ -14,6 +14,7 @@ class PostTopicObserver < Mongoid::Observer
#commentable_type: commentable.commentable_type, #commentable_type: commentable.commentable_type,
thread_id: comment_thread.id, thread_id: comment_thread.id,
thread_title: comment_thread.title, thread_title: comment_thread.title,
actor_username: (comment_thread.author.username if not comment_thread.anonymous),
}, },
) )
notification.actor = comment_thread.author if not comment_thread.anonymous notification.actor = comment_thread.author if not comment_thread.anonymous
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment