diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index 6928e35c9..da07f0eb0 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Date; +import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Locale; @@ -28,6 +29,7 @@ import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.function.Consumer; +import java.util.stream.Collectors; import eu.siacs.conversations.crypto.OtrService; import eu.siacs.conversations.entities.Presence; @@ -1432,6 +1434,8 @@ public class MessageParser extends AbstractParser implements Consumer(reactions.getReactions()); + newReactions.removeAll(message.getReactions().stream().filter(r -> occupantId.equals(r.occupantId)).map(r -> r.reaction).collect(Collectors.toList())); final var combinedReactions = Reaction.withOccupantId( message.getReactions(), @@ -1443,6 +1447,7 @@ public class MessageParser extends AbstractParser implements Consumer(reactions.getReactions()); + newReactions.removeAll(message.getReactions().stream().filter(r -> reactionFrom.equals(r.from)).map(r -> r.reaction).collect(Collectors.toList())); final var combinedReactions = Reaction.withFrom( message.getReactions(), @@ -1468,6 +1475,7 @@ public class MessageParser extends AbstractParser implements Consumer newReactions) { + if (newReactions.isEmpty()) return; + + final var message = reactingTo.reply(); + message.appendBody(String.join(" ", newReactions)); + message.setCounterpart(counterpart); + message.setOccupantId(occupantId); + message.setStatus(Message.STATUS_RECEIVED); + synchronized (CATCHUP_LOCK) { + final XmppConnection connection = + message.getConversation().getAccount().getXmppConnection(); + if (connection != null && connection.isWaitingForSmCatchup()) { + connection.incrementSmCatchupMessageCounter(); + pushFromBacklog(message); + } else { + pushNow(message); + } + } + } + public void pushFailedDelivery(final Message message) { final Conversation conversation = (Conversation) message.getConversation(); final boolean isScreenLocked = !mXmppConnectionService.isScreenLocked();