diff --git a/src/main/java/eu/siacs/conversations/entities/Reaction.java b/src/main/java/eu/siacs/conversations/entities/Reaction.java index eff7be74b..67d169374 100644 --- a/src/main/java/eu/siacs/conversations/entities/Reaction.java +++ b/src/main/java/eu/siacs/conversations/entities/Reaction.java @@ -82,6 +82,21 @@ public class Reaction { } } + public static Collection append( + final Collection existing, + final Collection reactions, + final boolean received, + final Jid from, + final Jid trueJid, + final String occupantId) { + final ImmutableSet.Builder builder = new ImmutableSet.Builder<>(); + builder.addAll(existing); + builder.addAll( + Collections2.transform( + reactions, r -> new Reaction(r, received, from, trueJid, occupantId))); + return builder.build(); + } + public static Collection withOccupantId( final Collection existing, final Collection reactions, @@ -89,7 +104,7 @@ public class Reaction { final Jid from, final Jid trueJid, final String occupantId) { - final ImmutableList.Builder builder = new ImmutableList.Builder<>(); + final ImmutableSet.Builder builder = new ImmutableSet.Builder<>(); builder.addAll(Collections2.filter(existing, e -> !occupantId.equals(e.occupantId))); builder.addAll( Collections2.transform( @@ -109,12 +124,22 @@ public class Reaction { .toString(); } + public int hashCode() { + return toString().hashCode(); + } + + public boolean equals(Object o) { + if (o == null) return false; + if (!(o instanceof Reaction)) return false; + return toString().equals(o.toString()); + } + public static Collection withFrom( final Collection existing, final Collection reactions, final boolean received, final Jid from) { - final ImmutableList.Builder builder = new ImmutableList.Builder<>(); + final ImmutableSet.Builder builder = new ImmutableSet.Builder<>(); builder.addAll( Collections2.filter(existing, e -> !from.asBareJid().equals(e.from.asBareJid()))); builder.addAll( diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index a27c139b9..d511360b6 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -59,6 +59,7 @@ import eu.siacs.conversations.services.MessageArchiveService; import eu.siacs.conversations.services.QuickConversationsService; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.utils.CryptoHelper; +import eu.siacs.conversations.utils.Emoticons; import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.LocalizedContent; import eu.siacs.conversations.xml.Namespace; @@ -574,7 +575,6 @@ public class MessageParser extends AbstractParser implements Consumer