Fix emoji reactions with the same name but different domains being misidentified as me

This commit is contained in:
noellabo 2021-06-05 18:53:16 +09:00
parent 60c13a4cb0
commit 82b1d12c99

View file

@ -326,7 +326,7 @@ class Status < ApplicationRecord
if account.nil?
scope.select('name, custom_emoji_id, count(*) as count, false as me')
else
scope.select("name, custom_emoji_id, count(*) as count, exists(select 1 from emoji_reactions r where r.account_id = #{account.id} and r.status_id = emoji_reactions.status_id and r.name = emoji_reactions.name) as me")
scope.select("name, custom_emoji_id, count(*) as count, exists(select 1 from emoji_reactions r where r.account_id = #{account.id} and r.status_id = emoji_reactions.status_id and r.name = emoji_reactions.name and r.custom_emoji_id = emoji_reactions.custom_emoji_id) as me")
end
end
ActiveRecord::Associations::Preloader.new.preload(records, :custom_emoji)