From 9a8293f58d0317e3917b855483a5b2958226f2fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?KMY=EF=BC=88=E9=9B=AA=E3=81=82=E3=81=99=E3=81=8B=EF=BC=89?= Date: Thu, 25 Jan 2024 19:37:09 +0900 Subject: [PATCH] Fix process of receiving posts with bearcaps is not working (#26527) --- app/lib/activitypub/activity/create.rb | 2 +- app/lib/activitypub/parser/status_parser.rb | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index 62c35d4dd3..85195f4c39 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -108,7 +108,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity end def process_status_params - @status_parser = ActivityPub::Parser::StatusParser.new(@json, followers_collection: @account.followers_url) + @status_parser = ActivityPub::Parser::StatusParser.new(@json, followers_collection: @account.followers_url, object: @object) attachment_ids = process_attachments.take(4).map(&:id) diff --git a/app/lib/activitypub/parser/status_parser.rb b/app/lib/activitypub/parser/status_parser.rb index 45f5fc5bf2..cfc2b8788b 100644 --- a/app/lib/activitypub/parser/status_parser.rb +++ b/app/lib/activitypub/parser/status_parser.rb @@ -4,12 +4,13 @@ class ActivityPub::Parser::StatusParser include JsonLdHelper # @param [Hash] json - # @param [Hash] magic_values - # @option magic_values [String] :followers_collection - def initialize(json, magic_values = {}) - @json = json - @object = json['object'] || json - @magic_values = magic_values + # @param [Hash] options + # @option options [String] :followers_collection + # @option options [Hash] :object + def initialize(json, **options) + @json = json + @object = options[:object] || json['object'] || json + @options = options end def uri @@ -78,7 +79,7 @@ class ActivityPub::Parser::StatusParser :public elsif audience_cc.any? { |cc| ActivityPub::TagManager.instance.public_collection?(cc) } :unlisted - elsif audience_to.include?(@magic_values[:followers_collection]) + elsif audience_to.include?(@options[:followers_collection]) :private else :direct