Reset html when resetting body (on MUC reflection)

Stephen Paul Weber created

Change summary

src/main/java/eu/siacs/conversations/entities/Message.java               | 6 
src/main/java/eu/siacs/conversations/parser/MessageParser.java           | 2 
src/main/java/eu/siacs/conversations/services/XmppConnectionService.java | 5 
3 files changed, 10 insertions(+), 3 deletions(-)

Detailed changes

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

@@ -563,6 +563,12 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
         }
     }
 
+    public synchronized void setHtml(Element html) {
+        final Element oldHtml = getHtml(true);
+        if (oldHtml != null) this.payloads.remove(oldHtml);
+        if (html != null) addPayload(html);
+    }
+
     public synchronized void setBody(String body) {
         this.body = body;
         this.isGeoUri = null;

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

@@ -587,7 +587,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
                 if (conversation.getMucOptions().isSelf(counterpart)) {
                     status = Message.STATUS_SEND_RECEIVED;
                     isCarbon = true; //not really carbon but received from another resource
-                    if (mXmppConnectionService.markMessage(conversation, remoteMsgId, status, serverMsgId, body)) {
+                    if (mXmppConnectionService.markMessage(conversation, remoteMsgId, status, serverMsgId, body, html)) {
                         return;
                     } else if (remoteMsgId == null || Config.IGNORE_ID_REWRITE_IN_MUC) {
                         if (body != null) {

src/main/java/eu/siacs/conversations/services/XmppConnectionService.java 🔗

@@ -4517,10 +4517,10 @@ public class XmppConnectionService extends Service {
     }
 
     public boolean markMessage(final Conversation conversation, final String uuid, final int status, final String serverMessageId) {
-        return markMessage(conversation, uuid, status, serverMessageId, null);
+        return markMessage(conversation, uuid, status, serverMessageId, null, null);
     }
 
-    public boolean markMessage(final Conversation conversation, final String uuid, final int status, final String serverMessageId, final LocalizedContent body) {
+    public boolean markMessage(final Conversation conversation, final String uuid, final int status, final String serverMessageId, final LocalizedContent body, final Element html) {
         if (uuid == null) {
             return false;
         } else {
@@ -4533,6 +4533,7 @@ public class XmppConnectionService extends Service {
                         && message.isTypeText()
                         && isBodyModified(message, body)) {
                     message.setBody(body.content);
+                    message.setHtml(html);
                     if (body.count > 1) {
                         message.setBodyLanguage(body.language);
                     }