From e947a3f808a994324bb5e6e6f0e7b45565b7df2d Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 6 Mar 2021 12:43:59 +0100 Subject: [PATCH] modify boyy on muc reflection --- .../conversations/parser/MessageParser.java | 10 +++----- .../services/XmppConnectionService.java | 25 ++++++++++++++++--- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index 17e00a975..dae71abda 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -384,7 +384,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece return; } } else if (query != null) { - Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received mam result with invalid from ("+original.getFrom()+") or queryId ("+queryId+")"); + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received mam result with invalid from (" + original.getFrom() + ") or queryId (" + queryId + ")"); return; } else if (original.fromServer(account)) { Pair f; @@ -488,13 +488,11 @@ 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 - //TODO this would be the place to change the body after something like mod_pastebin - if (mXmppConnectionService.markMessage(conversation, remoteMsgId, status, serverMsgId)) { + if (mXmppConnectionService.markMessage(conversation, remoteMsgId, status, serverMsgId, body)) { return; } else if (remoteMsgId == null || Config.IGNORE_ID_REWRITE_IN_MUC) { - LocalizedContent localizedBody = packet.getBody(); - if (localizedBody != null) { - Message message = conversation.findSentMessageWithBody(localizedBody.content); + if (body != null) { + Message message = conversation.findSentMessageWithBody(body.content); if (message != null) { mXmppConnectionService.markMessage(message, status); return; diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index ab718a752..9cd3e2627 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -136,6 +136,7 @@ import eu.siacs.conversations.utils.TorServiceUtils; import eu.siacs.conversations.utils.WakeLockHelper; import eu.siacs.conversations.utils.XmppUri; import eu.siacs.conversations.xml.Element; +import eu.siacs.conversations.xml.LocalizedContent; import eu.siacs.conversations.xml.Namespace; import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.OnBindListener; @@ -3950,16 +3951,28 @@ public class XmppConnectionService extends Service { return null; } - public boolean markMessage(Conversation conversation, String uuid, int status, String serverMessageId) { + public boolean markMessage(final Conversation conversation, final String uuid, final int status, final String serverMessageId) { + return markMessage(conversation, uuid, status, serverMessageId, null); + } + + public boolean markMessage(final Conversation conversation, final String uuid, final int status, final String serverMessageId, final LocalizedContent body) { if (uuid == null) { return false; } else { - Message message = conversation.findSentMessageWithUuid(uuid); + final Message message = conversation.findSentMessageWithUuid(uuid); if (message != null) { if (message.getServerMsgId() == null) { message.setServerMsgId(serverMessageId); } - markMessage(message, status); + if (body != null && body.content != null && !body.content.equals(message.getBody())) { + message.setBody(body.content); + if (body.count > 1) { + message.setBodyLanguage(body.language); + } + markMessage(message, status, null, true); + } else { + markMessage(message, status); + } return true; } else { return false; @@ -3973,6 +3986,10 @@ public class XmppConnectionService extends Service { public void markMessage(final Message message, final int status, final String errorMessage) { + markMessage(message, status, errorMessage, false); + } + + public void markMessage(final Message message, final int status, final String errorMessage, final boolean includeBody) { final int oldStatus = message.getStatus(); if (status == Message.STATUS_SEND_FAILED && (oldStatus == Message.STATUS_SEND_RECEIVED || oldStatus == Message.STATUS_SEND_DISPLAYED)) { return; @@ -3982,7 +3999,7 @@ public class XmppConnectionService extends Service { } message.setErrorMessage(errorMessage); message.setStatus(status); - databaseBackend.updateMessage(message, false); + databaseBackend.updateMessage(message, includeBody); updateConversationUi(); if (oldStatus != status && status == Message.STATUS_SEND_FAILED) { mNotificationService.pushFailedDelivery(message);