discourse/app/serializers/pending_post_serializer.rb
Loïc Guitaut a5fbb90df4 FEATURE: Display pending posts on user’s page
Currently when a user creates posts that are moderated (for whatever
reason), a popup is displayed saying the post needs approval and the
total number of the user’s pending posts. But then this piece of
information is kind of lost and there is nowhere for the user to know
what are their pending posts or how many there are.

This patch solves this issue by adding a new “Pending” section to the
user’s activity page when there are some pending posts to display. When
there are none, then the “Pending” section isn’t displayed at all.
2021-11-29 10:26:33 +01:00

28 lines
660 B
Ruby

# 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