Merge pull request #110 from kmycode/kbtopic-82-friend-server-inbox-url

Change: #82 フレンド申請時、自分のサーバーのInbox URLを伝える
This commit is contained in:
KMY(雪あすか) 2023-10-13 19:13:20 +09:00 committed by GitHub
commit 369f3c6e63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 7 deletions

View file

@ -53,7 +53,7 @@ class ActivityPub::Activity::Follow < ActivityPub::Activity
friend.update!(passive_state: :pending, active_state: :idle, passive_follow_activity_id: @json['id'])
else
@friend = FriendDomain.new(domain: @account.domain, passive_state: :pending, passive_follow_activity_id: @json['id'])
@friend.initialize_inbox_url!
@friend.inbox_url = @json['inboxUrl'].presence || @friend.default_inbox_url
@friend.save!
end

View file

@ -93,16 +93,12 @@ class FriendDomain < ApplicationRecord
destroy!
end
def initialize_inbox_url!
self.inbox_url = default_inbox_url
end
private
def default_inbox_url
"https://#{domain}/inbox"
end
private
def delete_for_friend!
activity_id = ActivityPub::TagManager.instance.generate_uri_for(nil)
payload = Oj.dump(delete_follow_activity(activity_id))
@ -118,6 +114,9 @@ class FriendDomain < ApplicationRecord
type: 'Follow',
actor: ActivityPub::TagManager.instance.uri_for(some_local_account),
object: ActivityPub::TagManager::COLLECTIONS[:public],
# Cannot use inbox_url method because this model also has inbox_url column
inboxUrl: "https://#{Rails.configuration.x.web_domain}/inbox",
}
end