2020-03-12 01:20:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require_relative 'post_item_excerpt'
|
|
|
|
|
|
|
|
class UserBookmarkSerializer < ApplicationSerializer
|
|
|
|
include PostItemExcerpt
|
|
|
|
include TopicTagsMixin
|
|
|
|
|
|
|
|
attributes :id,
|
|
|
|
:created_at,
|
2020-05-01 02:14:20 -04:00
|
|
|
:updated_at,
|
2020-03-12 01:20:56 -04:00
|
|
|
:topic_id,
|
|
|
|
:linked_post_number,
|
|
|
|
:post_id,
|
|
|
|
:name,
|
|
|
|
:reminder_at,
|
2021-03-21 19:50:22 -04:00
|
|
|
:pinned,
|
2020-03-12 01:20:56 -04:00
|
|
|
:title,
|
|
|
|
:deleted,
|
|
|
|
:hidden,
|
|
|
|
:category_id,
|
|
|
|
:closed,
|
|
|
|
:archived,
|
|
|
|
:archetype,
|
|
|
|
:highest_post_number,
|
|
|
|
:bumped_at,
|
|
|
|
:slug,
|
2020-05-13 00:03:24 -04:00
|
|
|
:post_user_username,
|
|
|
|
:post_user_avatar_template,
|
|
|
|
:post_user_name
|
2020-03-12 01:20:56 -04:00
|
|
|
|
2020-03-12 20:44:39 -04:00
|
|
|
def topic
|
|
|
|
@topic ||= object.topic || Topic.unscoped.find(object.topic_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def post
|
|
|
|
@post ||= object.post || Post.unscoped.find(object.post_id)
|
|
|
|
end
|
|
|
|
|
2020-03-12 01:20:56 -04:00
|
|
|
def closed
|
2020-03-12 20:44:39 -04:00
|
|
|
topic.closed
|
2020-03-12 01:20:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def archived
|
2020-03-12 20:44:39 -04:00
|
|
|
topic.archived
|
2020-03-12 01:20:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def linked_post_number
|
2020-03-12 20:44:39 -04:00
|
|
|
post.post_number
|
2020-03-12 01:20:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def title
|
2020-03-12 20:44:39 -04:00
|
|
|
topic.title
|
2020-03-12 01:20:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def deleted
|
2020-03-12 20:44:39 -04:00
|
|
|
topic.deleted_at.present? || post.deleted_at.present?
|
2020-03-12 01:20:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def hidden
|
2020-03-12 20:44:39 -04:00
|
|
|
post.hidden
|
2020-03-12 01:20:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def category_id
|
2020-03-12 20:44:39 -04:00
|
|
|
topic.category_id
|
2020-03-12 01:20:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def archetype
|
2020-03-12 20:44:39 -04:00
|
|
|
topic.archetype
|
2020-03-12 01:20:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def archived
|
2020-03-12 20:44:39 -04:00
|
|
|
topic.archived
|
2020-03-12 01:20:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def closed
|
2020-03-12 20:44:39 -04:00
|
|
|
topic.closed
|
2020-03-12 01:20:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def highest_post_number
|
2020-03-12 20:44:39 -04:00
|
|
|
topic.highest_post_number
|
2020-03-12 01:20:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def bumped_at
|
2020-03-12 20:44:39 -04:00
|
|
|
topic.bumped_at
|
2020-03-12 01:20:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def raw
|
2020-03-12 20:44:39 -04:00
|
|
|
post.raw
|
2020-03-12 01:20:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def cooked
|
2020-03-12 20:44:39 -04:00
|
|
|
post.cooked
|
2020-03-12 01:20:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def slug
|
2020-03-12 20:44:39 -04:00
|
|
|
topic.slug
|
2020-03-12 01:20:56 -04:00
|
|
|
end
|
|
|
|
|
2020-05-13 00:03:24 -04:00
|
|
|
def post_user
|
|
|
|
@post_user ||= post.user
|
|
|
|
end
|
|
|
|
|
|
|
|
def post_user_username
|
|
|
|
post_user.username
|
|
|
|
end
|
|
|
|
|
|
|
|
def post_user_avatar_template
|
|
|
|
post_user.avatar_template
|
|
|
|
end
|
|
|
|
|
|
|
|
def post_user_name
|
|
|
|
post_user.name
|
2020-03-12 01:20:56 -04:00
|
|
|
end
|
|
|
|
end
|