Fix: すでに同じカスタム絵文字が存在する場合、スタンプを受け入れない問題
This commit is contained in:
parent
f0fac9be8f
commit
09020c6b21
2 changed files with 37 additions and 6 deletions
|
@ -93,15 +93,17 @@ class ActivityPub::Activity::Like < ActivityPub::Activity
|
|||
|
||||
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,
|
||||
|
|
|
@ -93,6 +93,35 @@ RSpec.describe ActivityPub::Activity::Like do
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue