* Fix: #959 NGルールで絵文字リアクションを拒否した場合、自分のサーバーのカスタム絵文字は常に拒否される * Fix test * Fix test
This commit is contained in:
parent
d2e3f7f0f4
commit
bfa1700909
2 changed files with 35 additions and 3 deletions
|
@ -62,9 +62,11 @@ class Admin::NgRule
|
||||||
return false if @ng_rule.reaction_allow_follower && (recipient.id == @account.id || (!recipient.local? && !@account.local?) || recipient.following?(@account))
|
return false if @ng_rule.reaction_allow_follower && (recipient.id == @account.id || (!recipient.local? && !@account.local?) || recipient.following?(@account))
|
||||||
|
|
||||||
if @options[:reaction_type] == 'emoji_reaction'
|
if @options[:reaction_type] == 'emoji_reaction'
|
||||||
enum_match?(:reaction_type, @options[:reaction_type], @ng_rule.reaction_type) &&
|
result = enum_match?(:reaction_type, @options[:reaction_type], @ng_rule.reaction_type) &&
|
||||||
text_match?(:emoji_reaction_name, @options[:emoji_reaction_name], @ng_rule.emoji_reaction_name) &&
|
text_match?(:emoji_reaction_name, @options[:emoji_reaction_name], @ng_rule.emoji_reaction_name)
|
||||||
text_match?(:emoji_reaction_origin_domain, @options[:emoji_reaction_origin_domain], @ng_rule.emoji_reaction_origin_domain)
|
|
||||||
|
emoji_reaction_origin_domain = @options[:emoji_reaction_origin_domain] || Rails.configuration.x.local_domain
|
||||||
|
result && text_match?(:emoji_reaction_origin_domain, emoji_reaction_origin_domain, @ng_rule.emoji_reaction_origin_domain)
|
||||||
else
|
else
|
||||||
enum_match?(:reaction_type, @options[:reaction_type], @ng_rule.reaction_type)
|
enum_match?(:reaction_type, @options[:reaction_type], @ng_rule.reaction_type)
|
||||||
end
|
end
|
||||||
|
|
|
@ -278,5 +278,35 @@ RSpec.describe Admin::NgRule do
|
||||||
|
|
||||||
it_behaves_like 'matches rule', 'reaction'
|
it_behaves_like 'matches rule', 'reaction'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with emoji reaction origin domain' do
|
||||||
|
let(:account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/actor') }
|
||||||
|
let(:ng_rule) { Fabricate(:ng_rule, reaction_type: ['emoji_reaction'], emoji_reaction_origin_domain: 'ohagi.com') }
|
||||||
|
|
||||||
|
context 'when remote emoji matches domain' do
|
||||||
|
let(:options) { { uri: uri, recipient: Fabricate(:account), reaction_type: 'emoji_reaction', emoji_reaction_origin_domain: 'ohagi.com' } }
|
||||||
|
|
||||||
|
it_behaves_like 'matches rule', 'reaction'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when remote emoji does not match domain' do
|
||||||
|
let(:options) { { uri: uri, recipient: Fabricate(:account), reaction_type: 'emoji_reaction', emoji_reaction_origin_domain: 'test.com' } }
|
||||||
|
|
||||||
|
it_behaves_like 'does not match rule'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when local emoji' do
|
||||||
|
let(:options) { { uri: uri, recipient: Fabricate(:account), reaction_type: 'emoji_reaction', emoji_reaction_origin_domain: nil } }
|
||||||
|
|
||||||
|
it_behaves_like 'does not match rule'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when local emoji but all options match' do
|
||||||
|
let(:ng_rule) { Fabricate(:ng_rule, reaction_type: ['emoji_reaction']) }
|
||||||
|
let(:options) { { uri: uri, recipient: Fabricate(:account), reaction_type: 'emoji_reaction', emoji_reaction_origin_domain: nil } }
|
||||||
|
|
||||||
|
it_behaves_like 'matches rule', 'reaction'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue