From aaac8296b324e422711e3c5fb315ab8ee81841b0 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 19 Mar 2021 19:51:13 +0100 Subject: [PATCH] only overwrite body in text messages --- src/main/java/eu/siacs/conversations/entities/Message.java | 5 +++++ .../eu/siacs/conversations/http/HttpDownloadConnection.java | 1 + .../conversations/services/ChannelDiscoveryService.java | 2 +- .../siacs/conversations/services/XmppConnectionService.java | 4 +++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java index 258e9ba46..b2304a768 100644 --- a/src/main/java/eu/siacs/conversations/entities/Message.java +++ b/src/main/java/eu/siacs/conversations/entities/Message.java @@ -890,6 +890,11 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable return type == TYPE_FILE || type == TYPE_IMAGE || type == TYPE_PRIVATE_FILE; } + + public boolean isTypeText() { + return type == TYPE_TEXT || type == TYPE_PRIVATE; + } + public boolean hasFileOnRemoteHost() { return isFileOrImage() && getFileParams().url != null; } diff --git a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java index 240d5dba7..91f8a167f 100644 --- a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java +++ b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java @@ -363,6 +363,7 @@ public class HttpDownloadConnection implements Transferable { changeStatus(STATUS_OFFER); } catch (final Exception e) { Log.d(Config.LOGTAG,"problem downloading",e); + //TODO do not show toast for cancelled stuff if (interactive) { showToastForException(e); } else { diff --git a/src/main/java/eu/siacs/conversations/services/ChannelDiscoveryService.java b/src/main/java/eu/siacs/conversations/services/ChannelDiscoveryService.java index 4c73e04dc..3d33eefa5 100644 --- a/src/main/java/eu/siacs/conversations/services/ChannelDiscoveryService.java +++ b/src/main/java/eu/siacs/conversations/services/ChannelDiscoveryService.java @@ -68,7 +68,7 @@ public class ChannelDiscoveryService { } void discover(@NonNull final String query, Method method, OnChannelSearchResultsFound onChannelSearchResultsFound) { - List result = cache.getIfPresent(key(method, query)); + final List result = cache.getIfPresent(key(method, query)); if (result != null) { onChannelSearchResultsFound.onChannelSearchResultsFound(result); return; diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 6611a52be..fe6bf561f 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -3961,7 +3961,9 @@ public class XmppConnectionService extends Service { if (message.getServerMsgId() == null) { message.setServerMsgId(serverMessageId); } - if (message.getEncryption() == Message.ENCRYPTION_NONE && isBodyModified(message, body)) { + if (message.getEncryption() == Message.ENCRYPTION_NONE + && message.isTypeText() + && isBodyModified(message, body)) { message.setBody(body.content); if (body.count > 1) { message.setBodyLanguage(body.language);