diff --git a/app/lib/activitypub/tag_manager.rb b/app/lib/activitypub/tag_manager.rb index dc3c681bdaca31..ef3bb8310d010a 100644 --- a/app/lib/activitypub/tag_manager.rb +++ b/app/lib/activitypub/tag_manager.rb @@ -236,7 +236,7 @@ def limited_scope(status) end def subscribable_by(account) - case account.subscribtion_policy + case account.subscription_policy when :allow [COLLECTIONS[:public]] when :followers_only diff --git a/app/models/concerns/account_master_settings.rb b/app/models/concerns/account_master_settings.rb index 6356f5415f55bf..a107da594e708b 100644 --- a/app/models/concerns/account_master_settings.rb +++ b/app/models/concerns/account_master_settings.rb @@ -4,20 +4,20 @@ module AccountMasterSettings extend ActiveSupport::Concern included do - def subscribtion_policy - return master_settings['subscribtion_policy']&.to_sym || :allow if master_settings.present? + def subscription_policy + return master_settings['subscription_policy']&.to_sym || :allow if master_settings.present? # allow, followers_only, block :allow end def all_subscribable? - subscribtion_policy == :allow + subscription_policy == :allow end def public_master_settings { - 'subscribtion_policy' => subscribtion_policy, + 'subscription_policy' => subscription_policy, } end end diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb index 3244c6d941389d..a2cab3db9f0ca6 100644 --- a/app/services/activitypub/process_account_service.rb +++ b/app/services/activitypub/process_account_service.rb @@ -319,7 +319,7 @@ def subscribable_by @subscribable_by = as_array(@json['subscribableBy']).map { |x| value_or_id(x) } end - def subscribtion_policy(note) + def subscription_policy(note) if subscribable_by.nil? note.include?('[subscribable:no]') ? :block : :allow elsif subscribable_by.any? { |uri| ActivityPub::TagManager.instance.public_collection?(uri) } @@ -333,7 +333,7 @@ def subscribtion_policy(note) def master_settings(note) { - 'subscribtion_policy' => subscribtion_policy(note), + 'subscription_policy' => subscription_policy(note), } end diff --git a/app/services/delivery_antenna_service.rb b/app/services/delivery_antenna_service.rb index a0ebf1866012ea..d0491b2a36f9e3 100644 --- a/app/services/delivery_antenna_service.rb +++ b/app/services/delivery_antenna_service.rb @@ -23,10 +23,10 @@ def call(status, update, **options) private def delivery! - subscribtion_policy = @account.subscribtion_policy + subscription_policy = @account.subscription_policy dtl_post = @status.dtl? && dtl_enabled? - return if subscribtion_policy == :block && (!dtl_post || !@account.user&.setting_dtl_force_subscribable) + return if subscription_policy == :block && (!dtl_post || !@account.user&.setting_dtl_force_subscribable) tag_ids = @status.tags.pluck(:id) domain = @account.domain @@ -40,7 +40,7 @@ def delivery! antennas = antennas.left_joins(:antenna_accounts).where(any_accounts: true).or(Antenna.left_joins(:antenna_accounts).where(antenna_accounts: { account: @account })) antennas = Antenna.where(id: antennas.select(:id)) - if subscribtion_policy == :block + if subscription_policy == :block dtl_tag = Tag.find_or_create_by_names(dtl_tag_name).first return if !dtl_tag || tag_ids.exclude?(dtl_tag.id) @@ -127,9 +127,9 @@ def delivery_ltl! def followers_only? case @status.visibility.to_sym when :public, :public_unlisted, :login, :limited - @status.account.subscribtion_policy == :followers_only + @status.account.subscription_policy == :followers_only when :unlisted - @status.compute_searchability != 'public' || @status.account.subscribtion_policy == :followers_only + @status.compute_searchability != 'public' || @status.account.subscription_policy == :followers_only else true end diff --git a/db/migrate/20231105225839_add_master_settings_to_accounts.rb b/db/migrate/20231105225839_add_master_settings_to_accounts.rb index 162f441fe787a4..7adbdf5493f12c 100644 --- a/db/migrate/20231105225839_add_master_settings_to_accounts.rb +++ b/db/migrate/20231105225839_add_master_settings_to_accounts.rb @@ -16,7 +16,7 @@ def up Account.transaction do Account.find_in_batches do |accounts| accounts.each do |account| - account.update(master_settings: { 'subscribtion_policy' => account.dissubscribable ? 'block' : 'allow' }) + account.update(master_settings: { 'subscription_policy' => account.dissubscribable ? 'block' : 'allow' }) end end end @@ -32,7 +32,7 @@ def down Account.transaction do Account.find_in_batches do |accounts| accounts.each do |account| - account.update(dissubscribable: account.master_settings.present? && account.master_settings['subscribtion_policy'] != 'allow') + account.update(dissubscribable: account.master_settings.present? && account.master_settings['subscription_policy'] != 'allow') end end end diff --git a/spec/lib/status_reach_finder_spec.rb b/spec/lib/status_reach_finder_spec.rb index edaff5561b4e44..d176483490b2d6 100644 --- a/spec/lib/status_reach_finder_spec.rb +++ b/spec/lib/status_reach_finder_spec.rb @@ -381,7 +381,7 @@ let(:dissubscribable) { false } let(:spoiler_text) { '' } let(:status) { Fabricate(:status, account: alice, visibility: visibility, searchability: searchability, spoiler_text: spoiler_text) } - let(:alice) { Fabricate(:account, username: 'alice', master_settings: { subscribtion_policy: dissubscribable ? 'block' : 'allow' }) } + let(:alice) { Fabricate(:account, username: 'alice', master_settings: { subscription_policy: dissubscribable ? 'block' : 'allow' }) } let(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com', protocol: :activitypub, uri: 'https://example.com/', inbox_url: 'https://example.com/inbox') } let(:tom) { Fabricate(:account, username: 'tom', domain: 'tom.com', protocol: :activitypub, uri: 'https://tom.com/', inbox_url: 'https://tom.com/inbox') } diff --git a/spec/services/activitypub/process_account_service_spec.rb b/spec/services/activitypub/process_account_service_spec.rb index cecb6be35b91cf..40644db5091ac7 100644 --- a/spec/services/activitypub/process_account_service_spec.rb +++ b/spec/services/activitypub/process_account_service_spec.rb @@ -156,7 +156,7 @@ end end - context 'with subscribtion policy' do + context 'with subscription policy' do subject { described_class.new.call('alice', 'example.com', payload) } let(:subscribable_by) { 'https://www.w3.org/ns/activitystreams#Public' } @@ -179,32 +179,32 @@ end context 'when public' do - it 'subscribtion policy is allow' do - expect(subject.subscribtion_policy.to_s).to eq 'allow' + it 'subscription policy is allow' do + expect(subject.subscription_policy.to_s).to eq 'allow' end end context 'when private' do let(:subscribable_by) { 'https://example.com/followers' } - it 'subscribtion policy is followers_only' do - expect(subject.subscribtion_policy.to_s).to eq 'followers_only' + it 'subscription policy is followers_only' do + expect(subject.subscription_policy.to_s).to eq 'followers_only' end end context 'when empty' do let(:subscribable_by) { '' } - it 'subscribtion policy is block' do - expect(subject.subscribtion_policy.to_s).to eq 'block' + it 'subscription policy is block' do + expect(subject.subscription_policy.to_s).to eq 'block' end end context 'when default value' do let(:subscribable_by) { nil } - it 'subscribtion policy is allow' do - expect(subject.subscribtion_policy.to_s).to eq 'allow' + it 'subscription policy is allow' do + expect(subject.subscription_policy.to_s).to eq 'allow' end end @@ -214,8 +214,8 @@ context 'with no-subscribe' do let(:sender_bio) { '[subscribable:no]' } - it 'subscribtion policy is block' do - expect(subject.subscribtion_policy.to_s).to eq 'block' + it 'subscription policy is block' do + expect(subject.subscription_policy.to_s).to eq 'block' end end end diff --git a/spec/services/fan_out_on_write_service_spec.rb b/spec/services/fan_out_on_write_service_spec.rb index 370a08e98bdb75..9bcc67292f4ebc 100644 --- a/spec/services/fan_out_on_write_service_spec.rb +++ b/spec/services/fan_out_on_write_service_spec.rb @@ -10,10 +10,10 @@ let(:last_active_at) { Time.now.utc } let(:visibility) { 'public' } let(:searchability) { 'public' } - let(:subscribtion_policy) { :allow } + let(:subscription_policy) { :allow } let(:status) { Fabricate(:status, account: alice, visibility: visibility, searchability: searchability, text: 'Hello @bob #hoge') } - let!(:alice) { Fabricate(:user, current_sign_in_at: last_active_at, account_attributes: { master_settings: { subscribtion_policy: subscribtion_policy } }).account } + let!(:alice) { Fabricate(:user, current_sign_in_at: last_active_at, account_attributes: { master_settings: { subscription_policy: subscription_policy } }).account } let!(:bob) { Fabricate(:user, current_sign_in_at: last_active_at, account_attributes: { username: 'bob' }).account } let!(:tom) { Fabricate(:user, current_sign_in_at: last_active_at).account } let!(:ohagi) { Fabricate(:user, current_sign_in_at: last_active_at).account } @@ -130,16 +130,16 @@ def antenna_with_options(owner, **options) expect(antenna_feed_of(empty_antenna)).to_not include status.id end - context 'when subscribtion is blocked' do - let(:subscribtion_policy) { :block } + context 'when subscription is blocked' do + let(:subscription_policy) { :block } it 'is not added to the antenna feed' do expect(antenna_feed_of(antenna)).to_not include status.id end end - context 'when subscribtion is allowed followers only' do - let(:subscribtion_policy) { :followers_only } + context 'when subscription is allowed followers only' do + let(:subscription_policy) { :followers_only } let!(:antenna) { antenna_with_account(ohagi, alice) } it 'is not added to the antenna feed' do @@ -170,16 +170,16 @@ def antenna_with_options(owner, **options) end end - context 'with listening tag but sender is limiting subscribtion' do - let(:subscribtion_policy) { :block } + context 'with listening tag but sender is limiting subscription' do + let(:subscription_policy) { :block } it 'does not add to the antenna feed' do expect(antenna_feed_of(antenna)).to_not include status.id end end - context 'with listening tag but sender is limiting subscribtion but permit dtl only' do - let(:subscribtion_policy) { :block } + context 'with listening tag but sender is limiting subscription but permit dtl only' do + let(:subscription_policy) { :block } let(:custom_before) { true } before do @@ -204,8 +204,8 @@ def antenna_with_options(owner, **options) expect(antenna_feed_of(empty_antenna)).to_not include status.id end - context 'when subscribtion is blocked' do - let(:subscribtion_policy) { :block } + context 'when subscription is blocked' do + let(:subscription_policy) { :block } it 'is added to the antenna feed' do expect(antenna_feed_of(antenna)).to include status.id @@ -231,8 +231,8 @@ def antenna_with_options(owner, **options) expect(antenna_feed_of(empty_antenna)).to_not include status.id end - context 'when subscribtion is blocked' do - let(:subscribtion_policy) { :block } + context 'when subscription is blocked' do + let(:subscription_policy) { :block } it 'is added to the antenna feed' do expect(antenna_feed_of(antenna)).to include status.id @@ -433,8 +433,8 @@ def antenna_with_options(owner, **options) expect(antenna_feed_of(empty_antenna)).to_not include status.id end - context 'when subscribtion is blocked' do - let(:subscribtion_policy) { :block } + context 'when subscription is blocked' do + let(:subscription_policy) { :block } it 'is not added to the antenna feed' do expect(antenna_feed_of(antenna)).to_not include status.id @@ -451,8 +451,8 @@ def antenna_with_options(owner, **options) expect(antenna_feed_of(empty_antenna)).to_not include status.id end - context 'when subscribtion is blocked' do - let(:subscribtion_policy) { :block } + context 'when subscription is blocked' do + let(:subscription_policy) { :block } it 'is added to the antenna feed' do expect(antenna_feed_of(antenna)).to include status.id @@ -478,8 +478,8 @@ def antenna_with_options(owner, **options) expect(antenna_feed_of(empty_antenna)).to_not include status.id end - context 'when subscribtion is blocked' do - let(:subscribtion_policy) { :block } + context 'when subscription is blocked' do + let(:subscription_policy) { :block } it 'is added to the antenna feed' do expect(antenna_feed_of(antenna)).to include status.id