Don't put reply-reactions in reaction data model

Stephen Paul Weber created

That data model isn't well suited for allowing retractions to pull
things back out of it, so we'll rely on the aggregation approach for
these instead.

Change summary

src/main/java/eu/siacs/conversations/entities/Reaction.java    | 15 -
src/main/java/eu/siacs/conversations/parser/MessageParser.java | 32 ---
2 files changed, 1 insertion(+), 46 deletions(-)

Detailed changes

src/main/java/eu/siacs/conversations/entities/Reaction.java 🔗

@@ -91,21 +91,6 @@ public class Reaction {
         }
     }
 
-    public static Collection<Reaction> append(
-            final Collection<Reaction> existing,
-            final Collection<String> reactions,
-            final boolean received,
-            final Jid from,
-            final Jid trueJid,
-            final String occupantId) {
-        final ImmutableSet.Builder<Reaction> builder = new ImmutableSet.Builder<>();
-        builder.addAll(existing);
-        builder.addAll(
-                Collections2.transform(
-                        reactions, r -> new Reaction(r, null, received, from, trueJid, occupantId)));
-        return builder.build();
-    }
-
     public static Collection<Reaction> withOccupantId(
             final Collection<Reaction> existing,
             final Collection<String> reactions,

src/main/java/eu/siacs/conversations/parser/MessageParser.java 🔗

@@ -502,35 +502,7 @@ public class MessageParser extends AbstractParser implements Consumer<im.convers
         }
         LocalizedContent body = packet.getBody();
 
-        var appendReactions = false;
-        var reactions = packet.getExtension(Reactions.class);
-        final var reply = packet.findChild("reply", "urn:xmpp:reply:0");
-        if (reactions == null && reply != null && reply.getAttribute("id") != null && body != null) {
-            StringBuilder bodyB = new StringBuilder(body.content);
-
-            for (Element el : packet.getChildren()) {
-                if ("fallback".equals(el.getName()) && "urn:xmpp:fallback:0".equals(el.getNamespace()) && "urn:xmpp:reply:0".equals(el.getAttribute("for"))) {
-                    for (final var span : el.getChildren()) {
-                        if (!span.getName().equals("body") && !span.getNamespace().equals("urn:xmpp:fallback:0")) continue;
-                        if (span.getAttribute("start") == null || span.getAttribute("end") == null) {
-                            bodyB.setLength(0);
-                        } else {
-                            try {
-                                bodyB.delete(bodyB.offsetByCodePoints(0, parseInt(span.getAttribute("start"))), bodyB.offsetByCodePoints(0, parseInt(span.getAttribute("end"))));
-                            } catch (final IndexOutOfBoundsException e) { /* bad span */ }
-                        }
-                    }
-                }
-            }
-
-            final var emojiMaybe = bodyB.toString().replaceAll("\\s", "");
-            if (Emoticons.isEmoji(emojiMaybe)) {
-                appendReactions = true;
-                reactions = im.conversations.android.xmpp.model.reactions.Reactions.to(reply.getAttribute("id"));
-                reactions.addExtension(new im.conversations.android.xmpp.model.reactions.Reaction(emojiMaybe));
-            }
-        }
-
+        final var reactions = packet.getExtension(Reactions.class);
         final Element axolotlEncrypted = packet.findChildEnsureSingle(XmppAxolotlMessage.CONTAINERTAG, AxolotlService.PEP_PREFIX);
         int status;
         final Jid counterpart;
@@ -1328,7 +1300,6 @@ public class MessageParser extends AbstractParser implements Consumer<im.convers
                     final boolean isReceived = !mucOptions.isSelf(counterpart);
                     if (occupantId != null && message != null) {
                         final var combinedReactions =
-                            appendReactions ? Reaction.append(message.getReactions(), reactions.getReactions(), isReceived, counterpart, null, occupantId) :
                                 Reaction.withOccupantId(
                                         message.getReactions(),
                                         reactions.getReactions(),
@@ -1355,7 +1326,6 @@ public class MessageParser extends AbstractParser implements Consumer<im.convers
                     packet.fromAccount(account);
                     if (message != null) {
                         final var combinedReactions =
-                            appendReactions ? Reaction.append(message.getReactions(), reactions.getReactions(), isReceived, reactionFrom, null, null) :
                                 Reaction.withFrom(
                                         message.getReactions(),
                                         reactions.getReactions(),