Skip to content

Commit

Permalink
スペルミスを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Nov 7, 2023
1 parent fffd728 commit 7f1c06a
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion app/lib/activitypub/tag_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions app/models/concerns/account_master_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/services/activitypub/process_account_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand All @@ -333,7 +333,7 @@ def subscribtion_policy(note)

def master_settings(note)
{
'subscribtion_policy' => subscribtion_policy(note),
'subscription_policy' => subscription_policy(note),
}
end

Expand Down
10 changes: 5 additions & 5 deletions app/services/delivery_antenna_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions db/migrate/20231105225839_add_master_settings_to_accounts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/status_reach_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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') }

Expand Down
22 changes: 11 additions & 11 deletions spec/services/activitypub/process_account_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand All @@ -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

Expand All @@ -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
Expand Down
40 changes: 20 additions & 20 deletions spec/services/fan_out_on_write_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 7f1c06a

Please sign in to comment.