From 841a0ed9091cbb78e3123bab8bd3992f5d73df6f Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Fri, 4 Oct 2024 21:24:27 -0500 Subject: [PATCH] Loosen requirement to have occupant id to send reaction (cherry picked from commit d35ebbae226b99a239e3da7f4a70685cfaad6c43) --- .../siacs/conversations/entities/Reaction.java | 16 ++++++++++++++++ .../services/XmppConnectionService.java | 6 +----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Reaction.java b/src/main/java/eu/siacs/conversations/entities/Reaction.java index abf93462b..4f1252f58 100644 --- a/src/main/java/eu/siacs/conversations/entities/Reaction.java +++ b/src/main/java/eu/siacs/conversations/entities/Reaction.java @@ -92,6 +92,22 @@ public class Reaction { } } + public static Collection withMine( + final Collection existing, + final Collection reactions, + final boolean received, + final Jid from, + final Jid trueJid, + final String occupantId, + final String envelopeId) { + final ImmutableSet.Builder builder = new ImmutableSet.Builder<>(); + builder.addAll(Collections2.filter(existing, e -> e.received)); + builder.addAll( + Collections2.transform( + reactions, r -> new Reaction(r, null, received, from, trueJid, occupantId, envelopeId))); + return builder.build(); + } + public static Collection withOccupantId( final Collection existing, final Collection reactions, diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 4dba3ecc7..b34973e45 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -5381,13 +5381,9 @@ public class XmppConnectionService extends Service { if (conversation.getMode() == Conversational.MODE_MULTI) { final var self = conversation.getMucOptions().getSelf(); final String occupantId = self.getOccupantId(); - if (Strings.isNullOrEmpty(occupantId)) { - Log.d(Config.LOGTAG, "occupant id not found for reaction in MUC"); - return false; - } reactToId = message.getServerMsgId(); combinedReactions = - Reaction.withOccupantId( + Reaction.withMine( message.getReactions(), reactions, false,