2018-04-11 22:17:05 +08:00
|
|
|
class WebHookFlagSerializer < ApplicationSerializer
|
|
|
|
attributes :id,
|
|
|
|
:post,
|
|
|
|
:flag_type,
|
|
|
|
:created_by,
|
|
|
|
:created_at,
|
|
|
|
:resolved_at,
|
|
|
|
:resolved_by
|
|
|
|
|
|
|
|
def post
|
2018-05-21 11:37:16 +08:00
|
|
|
WebHookPostSerializer.new(object.post, scope: scope, root: false).as_json
|
2018-04-11 22:17:05 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def flag_type
|
|
|
|
object.post_action_type_key
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_post?
|
|
|
|
object.post.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def created_by
|
|
|
|
object.user && object.user.username
|
|
|
|
end
|
|
|
|
|
|
|
|
def resolved_at
|
|
|
|
object.disposed_at
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_resolved_at?
|
|
|
|
object.disposed_at.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def resolved_by
|
2018-05-21 11:37:16 +08:00
|
|
|
User.find(object.disposed_by_id).username
|
2018-04-11 22:17:05 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def include_resolved_by?
|
|
|
|
object.disposed_by_id.present?
|
|
|
|
end
|
|
|
|
end
|