mirror of
https://github.com/discourse/discourse.git
synced 2024-12-14 13:03:45 +08:00
e1e74abd4f
### UI Changes If `SiteSetting.enable_bookmarks_with_reminders` is enabled: * Clicking "Bookmark" on a topic will create a new Bookmark record instead of a post + user action * Clicking "Clear Bookmarks" on a topic will delete all the new Bookmark records on a topic * The topic bookmark buttons control the post bookmark flags correctly and vice-versa Disabled selecting the "reminder type" for bookmarks in the UI because the backend functionality is not done yet (of sending users notifications etc.) ### Other Changes * Added delete bookmark route (but no UI yet) * Added a rake task to sync the old PostAction bookmarks to the new Bookmark table, which can be run as many times as we want for a site (it will not create duplicates).
55 lines
1.5 KiB
Ruby
55 lines
1.5 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class Bookmark < ActiveRecord::Base
|
|
belongs_to :user
|
|
belongs_to :post
|
|
belongs_to :topic
|
|
|
|
validates :reminder_at, presence: {
|
|
message: I18n.t("bookmarks.errors.time_must_be_provided", reminder_type: I18n.t("bookmarks.reminders.at_desktop")),
|
|
if: -> { reminder_type.present? && reminder_type != Bookmark.reminder_types[:at_desktop] }
|
|
}
|
|
|
|
def self.reminder_types
|
|
@reminder_type = Enum.new(
|
|
at_desktop: 0,
|
|
later_today: 1,
|
|
next_business_day: 2,
|
|
tomorrow: 3,
|
|
next_week: 4,
|
|
next_month: 5,
|
|
custom: 6
|
|
)
|
|
end
|
|
end
|
|
|
|
# == Schema Information
|
|
#
|
|
# Table name: bookmarks
|
|
#
|
|
# id :bigint not null, primary key
|
|
# user_id :bigint not null
|
|
# topic_id :bigint not null
|
|
# post_id :bigint not null
|
|
# name :string
|
|
# reminder_type :integer
|
|
# reminder_at :datetime
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
#
|
|
# Indexes
|
|
#
|
|
# index_bookmarks_on_post_id (post_id)
|
|
# index_bookmarks_on_reminder_at (reminder_at)
|
|
# index_bookmarks_on_reminder_type (reminder_type)
|
|
# index_bookmarks_on_topic_id (topic_id)
|
|
# index_bookmarks_on_user_id (user_id)
|
|
# index_bookmarks_on_user_id_and_post_id (user_id,post_id) UNIQUE
|
|
#
|
|
# Foreign Keys
|
|
#
|
|
# fk_rails_... (post_id => posts.id)
|
|
# fk_rails_... (topic_id => topics.id)
|
|
# fk_rails_... (user_id => users.id)
|
|
#
|