about summary refs log tree commit diff
path: root/app/models/bookmark.rb
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2018-04-13 16:38:15 -0500
committerGitHub <noreply@github.com>2018-04-13 16:38:15 -0500
commitb7804028c2708c82cbb15037abe569519975ba9d (patch)
treea5cf9f9678172c658a9de4be3e8c31f3dc5bfa8c /app/models/bookmark.rb
parenta817f084eafaf5527445c29ab1d68f42b1a2872f (diff)
parentacb434b0c998353e9e39379ecab27f68df41a100 (diff)
Merge pull request #419 from ThibG/glitch-soc/features/bookmarks
Bookmarks
Diffstat (limited to 'app/models/bookmark.rb')
-rw-r--r--app/models/bookmark.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/app/models/bookmark.rb b/app/models/bookmark.rb
new file mode 100644
index 000000000..01dc48ee7
--- /dev/null
+++ b/app/models/bookmark.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+# == Schema Information
+#
+# Table name: bookmarks
+#
+#  id         :integer          not null, primary key
+#  created_at :datetime         not null
+#  updated_at :datetime         not null
+#  account_id :integer          not null
+#  status_id  :integer          not null
+#
+
+class Bookmark < ApplicationRecord
+  include Paginable
+
+  update_index('statuses#status', :status) if Chewy.enabled?
+
+  belongs_to :account, inverse_of: :bookmarks
+  belongs_to :status,  inverse_of: :bookmarks
+
+  validates :status_id, uniqueness: { scope: :account_id }
+
+  before_validation do
+    self.status = status.reblog if status&.reblog?
+  end
+end