0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-09 21:45:25 +08:00
discourse/app/serializers/pending_post_serializer.rb
jbrw 909620db18
FIX: Allow pending posts to have empty titles (#23366)
It's possible for a pending post to have a nil title. The PendingPostSerializer should not throw an error when this is encountered.
2023-09-01 12:43:25 -04:00

27 lines
661 B
Ruby
Vendored

# 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
delegate :avatar_template, :name, :username, to: :created_by, allow_nil: true
def raw_text
payload["raw"]
end
def title
payload["title"] || topic&.title
end
end