This commit is contained in:
parent
780426db31
commit
c73b173f09
2 changed files with 108 additions and 1 deletions
|
@ -34,6 +34,7 @@ class ActivityPub::Activity::Like < ActivityPub::Activity
|
||||||
|
|
||||||
def process_emoji_reaction
|
def process_emoji_reaction
|
||||||
return if !@original_status.account.local? && !Setting.receive_other_servers_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))
|
||||||
|
|
||||||
# custom emoji
|
# custom emoji
|
||||||
emoji = nil
|
emoji = nil
|
||||||
|
@ -125,13 +126,20 @@ class ActivityPub::Activity::Like < ActivityPub::Activity
|
||||||
end
|
end
|
||||||
|
|
||||||
def skip_download?(domain)
|
def skip_download?(domain)
|
||||||
DomainBlock.reject_media?(domain)
|
return true if DomainBlock.reject_media?(domain)
|
||||||
|
return false if @account.domain == domain
|
||||||
|
|
||||||
|
DomainBlock.blocked?(domain) || (DomainBlock.silence?(domain) && !@original_status.account.following?(@account))
|
||||||
end
|
end
|
||||||
|
|
||||||
def block_domain?
|
def block_domain?
|
||||||
DomainBlock.blocked?(@account.domain)
|
DomainBlock.blocked?(@account.domain)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def silence_domain?
|
||||||
|
DomainBlock.silence?(@account.domain)
|
||||||
|
end
|
||||||
|
|
||||||
def misskey_favourite?
|
def misskey_favourite?
|
||||||
misskey_shortcode = @json['_misskey_reaction']&.delete(':')
|
misskey_shortcode = @json['_misskey_reaction']&.delete(':')
|
||||||
|
|
||||||
|
|
|
@ -440,6 +440,105 @@ RSpec.describe ActivityPub::Activity::Like do
|
||||||
expect(subject.count).to eq 1
|
expect(subject.count).to eq 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when my server is silencing sender server' do
|
||||||
|
let(:block_domain) { 'example.com' }
|
||||||
|
let(:follow) { false }
|
||||||
|
|
||||||
|
before do
|
||||||
|
Fabricate(:domain_block, domain: block_domain, severity: :silence)
|
||||||
|
recipient.follow!(sender) if follow
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with unicode emoji' do
|
||||||
|
let(:content) { '😀' }
|
||||||
|
|
||||||
|
it 'does not create emoji reaction' do
|
||||||
|
expect(subject.count).to eq 0
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when following' do
|
||||||
|
let(:follow) { true }
|
||||||
|
|
||||||
|
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
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with custom emoji' do
|
||||||
|
let(:content) { ':tinking:' }
|
||||||
|
let(:tag) do
|
||||||
|
{
|
||||||
|
id: 'https://example.com/aaa',
|
||||||
|
type: 'Emoji',
|
||||||
|
icon: {
|
||||||
|
url: 'http://example.com/emoji.png',
|
||||||
|
},
|
||||||
|
name: 'tinking',
|
||||||
|
license: 'Everyone but Ohagi',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not create emoji reaction' do
|
||||||
|
expect(subject.count).to eq 0
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when following' do
|
||||||
|
let(:follow) { true }
|
||||||
|
|
||||||
|
it 'create emoji reaction' do
|
||||||
|
expect(subject.count).to eq 1
|
||||||
|
expect(subject.first.name).to eq 'tinking'
|
||||||
|
expect(subject.first.account).to eq sender
|
||||||
|
expect(subject.first.custom_emoji).to_not be_nil
|
||||||
|
expect(subject.first.custom_emoji.shortcode).to eq 'tinking'
|
||||||
|
expect(subject.first.custom_emoji.domain).to eq 'example.com'
|
||||||
|
expect(sender.favourited?(status)).to be false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with custom emoji from non-original server account' do
|
||||||
|
let(:content) { ':tinking:' }
|
||||||
|
let(:tag) do
|
||||||
|
{
|
||||||
|
id: 'https://example.com/aaa',
|
||||||
|
type: 'Emoji',
|
||||||
|
icon: {
|
||||||
|
url: 'http://example.com/emoji.png',
|
||||||
|
},
|
||||||
|
name: 'tinking',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
sender.update(domain: 'ohagi.com')
|
||||||
|
Fabricate(:custom_emoji, domain: 'example.com', uri: 'https://example.com/aaa', shortcode: 'tinking')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not create emoji reaction' do
|
||||||
|
expect(subject.count).to eq 0
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when following' do
|
||||||
|
let(:follow) { true }
|
||||||
|
|
||||||
|
it 'create emoji reaction' do
|
||||||
|
expect(subject.count).to eq 1
|
||||||
|
expect(subject.first.name).to eq 'tinking'
|
||||||
|
expect(subject.first.account).to eq sender
|
||||||
|
expect(subject.first.custom_emoji).to_not be_nil
|
||||||
|
expect(subject.first.custom_emoji.shortcode).to eq 'tinking'
|
||||||
|
expect(subject.first.custom_emoji.domain).to eq 'example.com'
|
||||||
|
expect(sender.favourited?(status)).to be false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#perform when rejecting favourite domain block' do
|
describe '#perform when rejecting favourite domain block' do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue