discourse/app/serializers/user_bookmark_serializer.rb
Martin Brennan e1eb5fb9b3
FEATURE: MVP Bookmarks with reminders user list changes (#8999)
* This PR changes the user activity bookmarks stream to show a new list of bookmarks based on the Bookmark record.
* If a bookmark has a name or reminder it will be shown as metadata above the topic title in the list
* The categories, tags, topic status, and assigned show for each bookmarked post based on the post topic
* Bookmarks can be deleted from the [...] menu in the list
* As well as this, the list of bookmarks from the quick access panel is now drawn from the Bookmarks table for a user:
* All of this new functionality is gated behind the enable_bookmarks_with_reminders site setting
The /bookmarks/ route now redirects directly to /user/:username/activity/bookmarks-with-reminders
* The structure of the Ember for the list of bookmarks is not ideal, this is an MVP PR so we can start testing this functionality internally. There is a little repeated code from topic.js.es6. There is an ongoing effort to start standardizing these lists that will be addressed in future PRs.
* This PR also fixes issues with feature detection for at_desktop bookmark reminders
2020-03-12 15:20:56 +10:00

92 lines
1.4 KiB
Ruby

# 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
def closed
object.topic_closed
end
def archived
object.topic_archived
end
def linked_post_number
object.post.post_number
end
def title
object.topic.title
end
def deleted
object.topic.deleted_at.present? || object.post.deleted_at.present?
end
def hidden
object.post.hidden
end
def category_id
object.topic.category_id
end
def archetype
object.topic.archetype
end
def archived
object.topic.archived
end
def closed
object.topic.closed
end
def highest_post_number
object.topic.highest_post_number
end
def bumped_at
object.topic.bumped_at
end
def raw
object.post.raw
end
def cooked
object.post.cooked
end
def slug
object.topic.slug
end
def username
object.post.user.username
end
end