Skip to content

Commit

Permalink
Fix: リモートから自分のサーバーの絵文字を使ってスタンプをつけられた時、既存の絵文字が消えてしまう場合がある問題
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Oct 16, 2023
1 parent 8a05b85 commit 243f1db
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/lib/activitypub/activity/like.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ def process_emoji(tag)
return if custom_emoji_parser.shortcode.blank? || custom_emoji_parser.image_remote_url.blank?

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

if domain == Rails.configuration.x.local_domain || domain == Rails.configuration.x.web_domain
# Block overwriting remote-but-local data
return CustomEmoji.find_by(shortcode: custom_emoji_parser.shortcode, domain: nil)
end

return if domain.present? && skip_download?(domain)

emoji = CustomEmoji.find_by(shortcode: custom_emoji_parser.shortcode, domain: domain)
Expand Down
4 changes: 4 additions & 0 deletions spec/lib/activitypub/activity/like_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@
}
end

before do
Fabricate(:custom_emoji, domain: nil, 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'
Expand Down

0 comments on commit 243f1db

Please sign in to comment.