2013-05-26 19:22:37 -05:00
|
|
|
class UserActionSerializer < ApplicationSerializer
|
|
|
|
|
2013-05-28 09:20:19 -05:00
|
|
|
attributes :action_type,
|
|
|
|
:created_at,
|
|
|
|
:excerpt,
|
2017-06-20 13:41:41 -05:00
|
|
|
:truncated,
|
2013-05-28 09:20:19 -05:00
|
|
|
:avatar_template,
|
|
|
|
:acting_avatar_template,
|
|
|
|
:slug,
|
|
|
|
:topic_id,
|
|
|
|
:target_user_id,
|
|
|
|
:target_name,
|
|
|
|
:target_username,
|
|
|
|
:post_number,
|
2014-06-04 10:41:11 -05:00
|
|
|
:post_id,
|
2013-05-28 09:20:19 -05:00
|
|
|
:reply_to_post_number,
|
|
|
|
:username,
|
|
|
|
:name,
|
|
|
|
:user_id,
|
|
|
|
:acting_username,
|
|
|
|
:acting_name,
|
|
|
|
:acting_user_id,
|
2013-06-11 20:14:08 -05:00
|
|
|
:title,
|
|
|
|
:deleted,
|
2013-07-18 16:24:51 -05:00
|
|
|
:hidden,
|
2015-07-31 13:22:28 -05:00
|
|
|
:post_type,
|
|
|
|
:action_code,
|
2014-05-26 12:49:57 -05:00
|
|
|
:edit_reason,
|
2014-05-22 02:37:02 -05:00
|
|
|
:category_id,
|
2015-05-11 11:51:16 -05:00
|
|
|
:closed,
|
2015-09-11 03:14:34 -05:00
|
|
|
:archived
|
2013-05-26 19:22:37 -05:00
|
|
|
|
2017-06-20 13:41:41 -05:00
|
|
|
def cooked
|
|
|
|
@cooked ||= object.cooked || PrettyText.cook(object.raw)
|
|
|
|
end
|
|
|
|
|
2013-05-26 19:22:37 -05:00
|
|
|
def excerpt
|
2017-06-20 13:41:41 -05:00
|
|
|
return nil unless cooked
|
|
|
|
@excerpt ||= PrettyText.excerpt(cooked, 300, keep_emoji_images: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
def truncated
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_truncated?
|
2017-06-20 14:45:26 -05:00
|
|
|
cooked.length > 300
|
2013-05-26 19:22:37 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def avatar_template
|
2014-05-22 02:37:02 -05:00
|
|
|
User.avatar_template(object.username, object.uploaded_avatar_id)
|
2013-05-26 19:22:37 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def acting_avatar_template
|
2014-05-22 02:37:02 -05:00
|
|
|
User.avatar_template(object.acting_username, object.acting_uploaded_avatar_id)
|
2013-05-26 19:22:37 -05:00
|
|
|
end
|
|
|
|
|
2015-04-21 13:36:46 -05:00
|
|
|
def include_acting_avatar_template?
|
|
|
|
object.acting_username.present?
|
|
|
|
end
|
|
|
|
|
2013-12-08 08:01:25 -06: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 19:22:37 -05:00
|
|
|
def slug
|
|
|
|
Slug.for(object.title)
|
|
|
|
end
|
|
|
|
|
2015-04-21 13:36:46 -05:00
|
|
|
def include_slug?
|
|
|
|
object.title.present?
|
|
|
|
end
|
|
|
|
|
2014-05-09 10:49:39 -05: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 09:59:50 -06:00
|
|
|
end
|
|
|
|
|
2015-05-11 11:51:16 -05:00
|
|
|
def closed
|
|
|
|
object.topic_closed
|
|
|
|
end
|
|
|
|
|
|
|
|
def archived
|
|
|
|
object.topic_archived
|
|
|
|
end
|
|
|
|
|
2013-05-26 19:22:37 -05:00
|
|
|
end
|