about summary refs log tree commit diff
path: root/app/models/account_pin.rb
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2018-08-11 15:28:06 +0200
committerGitHub <noreply@github.com>2018-08-11 15:28:06 +0200
commitd787bcdeb1570e4d8d67f326dadaf321a6854e06 (patch)
treefa23a187b16bf07635312a7791013aacfc2c4474 /app/models/account_pin.rb
parent03afc365d530e6d57754ae9dbbdbd0c56431ee02 (diff)
parent7067b64de33f9cd491e97329df266fde5fb49e42 (diff)
Merge pull request #630 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/models/account_pin.rb')
-rw-r--r--app/models/account_pin.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/app/models/account_pin.rb b/app/models/account_pin.rb
new file mode 100644
index 000000000..9a21c3405
--- /dev/null
+++ b/app/models/account_pin.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+# == Schema Information
+#
+# Table name: account_pins
+#
+#  id                :bigint(8)        not null, primary key
+#  account_id        :bigint(8)
+#  target_account_id :bigint(8)
+#  created_at        :datetime         not null
+#  updated_at        :datetime         not null
+#
+
+class AccountPin < ApplicationRecord
+  include RelationshipCacheable
+
+  belongs_to :account
+  belongs_to :target_account, class_name: 'Account'
+
+  validate :validate_follow_relationship
+
+  private
+
+  def validate_follow_relationship
+    errors.add(:base, I18n.t('accounts.pin_errors.following')) unless account.following?(target_account)
+  end
+end