From 51b00dd0344c1c4c609b180a484dba91b0bcf725 Mon Sep 17 00:00:00 2001 From: Plastikmensch Date: Mon, 15 May 2023 00:08:18 +0200 Subject: [PATCH] Don't set `me` to true for remote reactions When an account and a remote account reacted with a custom emoji with the same shortcode, the `me` attribute was also true for the remote reaction, despite being a different emoji. This query should probably be optimised, but it works. Signed-off-by: Plastikmensch --- app/models/status.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/status.rb b/app/models/status.rb index a8d600ef1a..8a70fa7322 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -300,7 +300,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 status_reactions r where r.account_id = #{account.id} and r.status_id = status_reactions.status_id and r.name = status_reactions.name) as me") + scope.select("name, custom_emoji_id, count(*) as count, exists(select 1 from status_reactions r where r.account_id = #{account.id} and r.status_id = status_reactions.status_id and r.name = status_reactions.name and (r.custom_emoji_id = status_reactions.custom_emoji_id or r.custom_emoji_id is null and status_reactions.custom_emoji_id is null)) as me") end end