diff --git a/app/lib/activitypub/activity/like.rb b/app/lib/activitypub/activity/like.rb index 5e34cc9dc547c2..298a81b2928656 100644 --- a/app/lib/activitypub/activity/like.rb +++ b/app/lib/activitypub/activity/like.rb @@ -93,15 +93,17 @@ def process_emoji(tag) return if custom_emoji_parser.shortcode.blank? || custom_emoji_parser.image_remote_url.blank? - emoji = CustomEmoji.find_by(shortcode: custom_emoji_parser.shortcode, domain: @account.domain) - - return unless emoji.nil? || custom_emoji_parser.image_remote_url != emoji.image_remote_url || (custom_emoji_parser.updated_at && custom_emoji_parser.updated_at >= emoji.updated_at) - - domain = emoji_tag['domain'] || URI.split(custom_emoji_parser.uri)[2] || @account.domain + domain = tag['domain'] || URI.split(custom_emoji_parser.uri)[2] || @account.domain domain = nil if domain == Rails.configuration.x.local_domain || domain == Rails.configuration.x.web_domain - return if domain.present? && skip_download?(domain) + emoji = CustomEmoji.find_by(shortcode: custom_emoji_parser.shortcode, domain: domain) + + return emoji unless emoji.nil? || + custom_emoji_parser.image_remote_url != emoji.image_remote_url || + (custom_emoji_parser.updated_at && custom_emoji_parser.updated_at >= emoji.updated_at) || + custom_emoji_parser.license != emoji.license + begin emoji ||= CustomEmoji.new( domain: domain, diff --git a/spec/lib/activitypub/activity/like_spec.rb b/spec/lib/activitypub/activity/like_spec.rb index bdeda34f12ed22..9991ba37dc8a82 100644 --- a/spec/lib/activitypub/activity/like_spec.rb +++ b/spec/lib/activitypub/activity/like_spec.rb @@ -93,6 +93,35 @@ end end + context 'with custom emoji but that is existing on local server' 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 + + before do + Fabricate(:custom_emoji, domain: 'example.com', uri: 'https://example.com/aaa', image_remote_url: 'http://example.com/emoji.png', shortcode: 'tinking', license: 'Everyone but Ohagi') + end + + 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 + context 'with custom emoji and custom domain' do let(:content) { ':tinking:' } let(:tag) do