about summary refs log tree commit diff
path: root/app/models/follow.rb
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2018-05-04 14:16:30 -0500
committerDavid Yip <yipdw@member.fsf.org>2018-05-04 14:16:30 -0500
commit7600067a300b650a6f30da19a469c913243f3a13 (patch)
tree8b84acffba4bd167b8e7c6d332c48013b68e7079 /app/models/follow.rb
parentcb62935c0b00f41ff5d4ab77a8cc38174b05d186 (diff)
parent6793bec4c67e695100cb4d8551f0bda0b7e87b12 (diff)
Merge remote-tracking branch 'origin/master' into gs-master
  Conflicts:
 	app/controllers/follower_accounts_controller.rb
 	app/controllers/following_accounts_controller.rb
    	db/schema.rb
Diffstat (limited to 'app/models/follow.rb')
-rw-r--r--app/models/follow.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/follow.rb b/app/models/follow.rb
index 2ca42ff70..eaf8445f3 100644
--- a/app/models/follow.rb
+++ b/app/models/follow.rb
@@ -9,6 +9,7 @@
 #  account_id        :bigint(8)        not null
 #  target_account_id :bigint(8)        not null
 #  show_reblogs      :boolean          default(TRUE), not null
+#  uri               :string
 #
 
 class Follow < ApplicationRecord
@@ -26,4 +27,16 @@ class Follow < ApplicationRecord
   validates :account_id, uniqueness: { scope: :target_account_id }
 
   scope :recent, -> { reorder(id: :desc) }
+
+  def local?
+    false # Force uri_for to use uri attribute
+  end
+
+  before_validation :set_uri, only: :create
+
+  private
+
+  def set_uri
+    self.uri = ActivityPub::TagManager.instance.generate_uri_for(self) if uri.nil?
+  end
 end