parent
f30b6f55e2
commit
230c621843
4 changed files with 75 additions and 1 deletions
|
@ -34,7 +34,7 @@ class ActivityPub::Activity::Like < ActivityPub::Activity
|
|||
|
||||
def process_emoji_reaction
|
||||
return if !@original_status.account.local? && !Setting.receive_other_servers_emoji_reaction
|
||||
return if silence_domain? && (!@original_status.local? || !@original_status.account.following?(@account))
|
||||
return if (silence_domain? || @account.silenced?) && (!@original_status.local? || !@original_status.account.following?(@account))
|
||||
|
||||
# custom emoji
|
||||
emoji = nil
|
||||
|
|
|
@ -16,6 +16,8 @@ class EmojiReactService < BaseService
|
|||
authorize_with account, status, :emoji_reaction?
|
||||
@status = status
|
||||
|
||||
raise Mastodon::ValidationError, I18n.t('reactions.errors.banned') if account.silenced? && !status.account.following?(account)
|
||||
|
||||
with_redis_lock("emoji_reaction:#{status.id}") do
|
||||
shortcode, domain = name.split('@')
|
||||
domain = nil if TagManager.instance.local_domain?(domain)
|
||||
|
|
|
@ -363,6 +363,47 @@ RSpec.describe ActivityPub::Activity::Like do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when sender is silenced' do
|
||||
let(:content) { '😀' }
|
||||
|
||||
before do
|
||||
sender.silence!
|
||||
end
|
||||
|
||||
it 'does not create emoji reaction' do
|
||||
expect(subject.count).to eq 0
|
||||
end
|
||||
end
|
||||
|
||||
context 'when sender is silenced but following recipient' do
|
||||
let(:content) { '😀' }
|
||||
|
||||
before do
|
||||
recipient.follow!(sender)
|
||||
sender.silence!
|
||||
end
|
||||
|
||||
it 'create emoji reaction' do
|
||||
expect(subject.count).to eq 1
|
||||
expect(subject.first.name).to eq '😀'
|
||||
expect(subject.first.account).to eq sender
|
||||
expect(sender.favourited?(status)).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context 'when sender is silenced but reacted to remote account' do
|
||||
let(:content) { '😀' }
|
||||
let(:recipient) { Fabricate(:account, domain: 'kirakira.com', uri: 'https://kirakira.com/actor') }
|
||||
|
||||
before do
|
||||
sender.silence!
|
||||
end
|
||||
|
||||
it 'does not create emoji reaction' do
|
||||
expect(subject.count).to eq 0
|
||||
end
|
||||
end
|
||||
|
||||
context 'when emoji reaction between other servers is disabled' do
|
||||
let(:recipient) { Fabricate(:account, domain: 'narrow.com', uri: 'https://narrow.com/') }
|
||||
let(:content) { '😀' }
|
||||
|
@ -467,6 +508,14 @@ RSpec.describe ActivityPub::Activity::Like do
|
|||
expect(sender.favourited?(status)).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context 'when recipient is remote user' do
|
||||
let(:recipient) { Fabricate(:account, domain: 'foo.bar', uri: 'https://foo.bar/actor') }
|
||||
|
||||
it 'does not create emoji reaction' do
|
||||
expect(subject.count).to eq 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with custom emoji' do
|
||||
|
|
|
@ -52,6 +52,29 @@ RSpec.describe EmojiReactService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when user is silenced' do
|
||||
before do
|
||||
sender.silence!
|
||||
end
|
||||
|
||||
it 'emoji reaction is not allowed' do
|
||||
expect { subject }.to raise_error Mastodon::ValidationError
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user is silenced but following target' do
|
||||
before do
|
||||
author.follow!(sender)
|
||||
sender.silence!
|
||||
end
|
||||
|
||||
it 'emoji reaction is allowed' do
|
||||
expect(subject.count).to eq 1
|
||||
expect(subject.first.name).to eq '😀'
|
||||
expect(subject.first.custom_emoji_id).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when over limit' do
|
||||
let(:name) { '🚗' }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue