2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-04-10 17:00:50 -04:00
|
|
|
class QueuedPostSerializer < ApplicationSerializer
|
2019-01-03 12:03:01 -05:00
|
|
|
attributes(
|
|
|
|
:id,
|
|
|
|
:queue,
|
|
|
|
:user_id,
|
|
|
|
:state,
|
|
|
|
:topic_id,
|
|
|
|
:approved_by_id,
|
|
|
|
:rejected_by_id,
|
|
|
|
:raw,
|
|
|
|
:post_options,
|
|
|
|
:created_at,
|
|
|
|
:category_id,
|
|
|
|
:can_delete_user,
|
|
|
|
)
|
|
|
|
has_one :created_by, serializer: AdminUserListSerializer, root: :users
|
2015-04-14 14:21:02 -04:00
|
|
|
has_one :topic, serializer: BasicTopicSerializer
|
|
|
|
|
2023-07-17 22:13:40 -04:00
|
|
|
def initialize(object, options = {})
|
|
|
|
Discourse.deprecate("QueuedPostSerializer is deprecated.", drop_from: "3.3.0")
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
2019-01-03 12:03:01 -05:00
|
|
|
def queue
|
|
|
|
"default"
|
2015-04-15 15:29:37 -04:00
|
|
|
end
|
|
|
|
|
2019-01-03 12:03:01 -05:00
|
|
|
def user_id
|
|
|
|
object.created_by_id
|
|
|
|
end
|
|
|
|
|
|
|
|
def state
|
|
|
|
object.status + 1
|
|
|
|
end
|
|
|
|
|
|
|
|
def approved_by_id
|
2021-12-08 12:12:24 -05:00
|
|
|
post_history.approved.last&.created_by_id
|
2019-01-03 12:03:01 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def rejected_by_id
|
2021-12-08 12:12:24 -05:00
|
|
|
post_history.rejected.last&.created_by_id
|
2019-01-03 12:03:01 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def raw
|
|
|
|
object.payload["raw"]
|
|
|
|
end
|
|
|
|
|
|
|
|
def post_options
|
|
|
|
object.payload.except("raw")
|
2015-04-15 15:29:37 -04:00
|
|
|
end
|
|
|
|
|
2015-05-19 12:19:25 -04:00
|
|
|
def can_delete_user
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_can_delete_user?
|
2019-01-03 12:03:01 -05:00
|
|
|
created_by && created_by.trust_level == TrustLevel[0]
|
|
|
|
end
|
|
|
|
|
2021-12-08 12:12:24 -05:00
|
|
|
private
|
2019-01-03 12:03:01 -05:00
|
|
|
|
2021-12-08 12:12:24 -05:00
|
|
|
def post_history
|
2019-01-03 12:03:01 -05:00
|
|
|
object.reviewable_histories.transitioned.order(:created_at)
|
2015-05-19 12:19:25 -04:00
|
|
|
end
|
2015-04-10 17:00:50 -04:00
|
|
|
end
|