2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-04-11 10:17:05 -04:00
|
|
|
class WebHookFlagSerializer < ApplicationSerializer
|
|
|
|
attributes :id,
|
|
|
|
:post,
|
|
|
|
:flag_type,
|
|
|
|
:created_by,
|
|
|
|
:created_at,
|
|
|
|
:resolved_at,
|
|
|
|
:resolved_by
|
|
|
|
|
|
|
|
def post
|
2018-05-20 23:37:16 -04:00
|
|
|
WebHookPostSerializer.new(object.post, scope: scope, root: false).as_json
|
2018-04-11 10:17:05 -04: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
|
2019-01-03 12:03:01 -05:00
|
|
|
object.disagreed_at || object.agreed_at || object.deferred_at
|
2018-04-11 10:17:05 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def include_resolved_at?
|
2019-01-03 12:03:01 -05:00
|
|
|
resolved_at.present?
|
2018-04-11 10:17:05 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def resolved_by
|
2019-01-03 12:03:01 -05:00
|
|
|
User.find(disposed_by_id).username
|
2018-04-11 10:17:05 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def include_resolved_by?
|
2019-01-03 12:03:01 -05:00
|
|
|
disposed_by_id.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def disposed_by_id
|
|
|
|
object.disagreed_by_id || object.agreed_by_id || object.deferred_by_id
|
2018-04-11 10:17:05 -04:00
|
|
|
end
|
|
|
|
end
|