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,
|
|
|
|
:topic_id,
|
|
|
|
:linked_post_number,
|
|
|
|
:post_id,
|
|
|
|
:name,
|
|
|
|
:reminder_at,
|
|
|
|
:title,
|
|
|
|
:deleted,
|
|
|
|
:hidden,
|
|
|
|
:category_id,
|
|
|
|
:closed,
|
|
|
|
:archived,
|
|
|
|
:archetype,
|
|
|
|
:highest_post_number,
|
|
|
|
:bumped_at,
|
|
|
|
:slug,
|
|
|
|
:username
|
|
|
|
|
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
|
|
|
|
|
|
|
|
def username
|
2020-03-12 20:44:39 -04:00
|
|
|
post.user.username
|
2020-03-12 01:20:56 -04:00
|
|
|
end
|
|
|
|
end
|