0
0
Fork 0

Store URIs of follows, follow requests and blocks for ActivityPub (#7160)

Same URI passed between follow request and follow, since they are
the same thing in ActivityPub. Local URIs are generated during
creation using UUIDs and are passed to serializers.
This commit is contained in:
Eugen Rochko 2018-05-04 21:14:34 +02:00 committed by GitHub
parent d1aef17f9a
commit 6793bec4c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 64 additions and 13 deletions

View file

@ -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 FollowRequest < ApplicationRecord
@ -23,11 +24,22 @@ class FollowRequest < ApplicationRecord
validates :account_id, uniqueness: { scope: :target_account_id }
def authorize!
account.follow!(target_account, reblogs: show_reblogs)
account.follow!(target_account, reblogs: show_reblogs, uri: uri)
MergeWorker.perform_async(target_account.id, account.id)
destroy!
end
alias reject! destroy!
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