2021-08-27 00:16:00 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class PendingPostSerializer < ApplicationSerializer
|
|
|
|
attributes :id,
|
|
|
|
:avatar_template,
|
|
|
|
:category_id,
|
|
|
|
:created_at,
|
|
|
|
:created_by_id,
|
|
|
|
:name,
|
|
|
|
:raw_text,
|
|
|
|
:title,
|
|
|
|
:topic_id,
|
|
|
|
:topic_url,
|
|
|
|
:username
|
|
|
|
|
|
|
|
delegate :created_by, :payload, :topic, to: :object, private: true
|
|
|
|
delegate :url, to: :topic, prefix: true, allow_nil: true
|
2023-09-04 06:14:51 +08:00
|
|
|
delegate :avatar_template, :name, :username, to: :target_created_by, allow_nil: true
|
|
|
|
|
|
|
|
def created_by_id
|
|
|
|
object.target_created_by_id
|
|
|
|
end
|
2021-08-27 00:16:00 +08:00
|
|
|
|
|
|
|
def raw_text
|
|
|
|
payload["raw"]
|
|
|
|
end
|
|
|
|
|
|
|
|
def title
|
2023-09-02 00:43:25 +08:00
|
|
|
payload["title"] || topic&.title
|
2021-08-27 00:16:00 +08:00
|
|
|
end
|
2023-09-04 06:14:51 +08:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def target_created_by
|
|
|
|
object.target_created_by
|
|
|
|
end
|
2021-08-27 00:16:00 +08:00
|
|
|
end
|