2017-06-21 12:56:38 -04:00
|
|
|
require_relative 'post_item_excerpt'
|
|
|
|
|
2013-05-26 20:22:37 -04:00
|
|
|
class UserActionSerializer < ApplicationSerializer
|
2017-06-21 12:56:38 -04:00
|
|
|
include PostItemExcerpt
|
2013-05-26 20:22:37 -04:00
|
|
|
|
2013-05-28 10:20:19 -04:00
|
|
|
attributes :action_type,
|
|
|
|
:created_at,
|
|
|
|
:avatar_template,
|
|
|
|
:acting_avatar_template,
|
|
|
|
:slug,
|
|
|
|
:topic_id,
|
|
|
|
:target_user_id,
|
|
|
|
:target_name,
|
|
|
|
:target_username,
|
|
|
|
:post_number,
|
2014-06-04 11:41:11 -04:00
|
|
|
:post_id,
|
2013-05-28 10:20:19 -04:00
|
|
|
:reply_to_post_number,
|
|
|
|
:username,
|
|
|
|
:name,
|
|
|
|
:user_id,
|
|
|
|
:acting_username,
|
|
|
|
:acting_name,
|
|
|
|
:acting_user_id,
|
2013-06-11 21:14:08 -04:00
|
|
|
:title,
|
|
|
|
:deleted,
|
2013-07-18 17:24:51 -04:00
|
|
|
:hidden,
|
2015-07-31 14:22:28 -04:00
|
|
|
:post_type,
|
|
|
|
:action_code,
|
2018-05-17 23:28:13 -04:00
|
|
|
:action_code_who,
|
2014-05-26 13:49:57 -04:00
|
|
|
:edit_reason,
|
2014-05-22 03:37:02 -04:00
|
|
|
:category_id,
|
2015-05-11 12:51:16 -04:00
|
|
|
:closed,
|
2015-09-11 04:14:34 -04:00
|
|
|
:archived
|
2013-05-26 20:22:37 -04:00
|
|
|
|
|
|
|
def avatar_template
|
2014-05-22 03:37:02 -04:00
|
|
|
User.avatar_template(object.username, object.uploaded_avatar_id)
|
2013-05-26 20:22:37 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def acting_avatar_template
|
2014-05-22 03:37:02 -04:00
|
|
|
User.avatar_template(object.acting_username, object.acting_uploaded_avatar_id)
|
2013-05-26 20:22:37 -04:00
|
|
|
end
|
|
|
|
|
2015-04-21 14:36:46 -04:00
|
|
|
def include_acting_avatar_template?
|
|
|
|
object.acting_username.present?
|
|
|
|
end
|
|
|
|
|
2013-12-08 09:01:25 -05:00
|
|
|
def include_name?
|
|
|
|
SiteSetting.enable_names?
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_target_name?
|
|
|
|
include_name?
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_acting_name?
|
|
|
|
include_name?
|
|
|
|
end
|
|
|
|
|
2013-05-26 20:22:37 -04:00
|
|
|
def slug
|
|
|
|
Slug.for(object.title)
|
|
|
|
end
|
|
|
|
|
2015-04-21 14:36:46 -04:00
|
|
|
def include_slug?
|
|
|
|
object.title.present?
|
|
|
|
end
|
|
|
|
|
2014-05-09 11:49:39 -04:00
|
|
|
def include_reply_to_post_number?
|
|
|
|
object.action_type == UserAction::REPLY
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_edit_reason?
|
|
|
|
object.action_type == UserAction::EDIT
|
2013-12-27 10:59:50 -05:00
|
|
|
end
|
|
|
|
|
2015-05-11 12:51:16 -04:00
|
|
|
def closed
|
|
|
|
object.topic_closed
|
|
|
|
end
|
|
|
|
|
|
|
|
def archived
|
|
|
|
object.topic_archived
|
|
|
|
end
|
|
|
|
|
2018-05-17 23:28:13 -04:00
|
|
|
def include_action_code_who?
|
|
|
|
action_code_who.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def action_code_who
|
|
|
|
object.action_code_who
|
|
|
|
end
|
|
|
|
|
2013-05-26 20:22:37 -04:00
|
|
|
end
|