From 5b419063281b11ef6ae8dc84be4b802c9847dfa2 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 10 May 2018 10:47:28 +0200 Subject: [PATCH] do not include body in simple status updates to not trigger fts update --- .../conversations/crypto/PgpDecryptionService.java | 2 +- .../eu/siacs/conversations/parser/MessageParser.java | 6 +++--- .../conversations/persistance/DatabaseBackend.java | 7 ++++++- .../conversations/services/XmppConnectionService.java | 10 +++++++--- .../conversations/xmpp/jingle/JingleConnection.java | 2 +- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/crypto/PgpDecryptionService.java b/src/main/java/eu/siacs/conversations/crypto/PgpDecryptionService.java index 10deacfe4..d565f85a3 100644 --- a/src/main/java/eu/siacs/conversations/crypto/PgpDecryptionService.java +++ b/src/main/java/eu/siacs/conversations/crypto/PgpDecryptionService.java @@ -90,7 +90,7 @@ public class PgpDecryptionService { message.setEncryption(Message.ENCRYPTION_DECRYPTION_FAILED); } } - mXmppConnectionService.updateMessage(message); + mXmppConnectionService.updateMessage(message, false); continueDecryption(true); } diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index 37daec5a4..9e3ed29fb 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -407,7 +407,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece Message previouslySent = conversation.findSentMessageWithUuid(remoteMsgId); if (previouslySent != null && previouslySent.getServerMsgId() == null && serverMsgId != null) { previouslySent.setServerMsgId(serverMsgId); - mXmppConnectionService.databaseBackend.updateMessage(previouslySent); + mXmppConnectionService.databaseBackend.updateMessage(previouslySent, false); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": encountered previously sent OMEMO message without serverId. updating..."); } } @@ -529,7 +529,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece && duplicate.getServerMsgId() == null && message.getServerMsgId() != null) { duplicate.setServerMsgId(message.getServerMsgId()); - if (mXmppConnectionService.databaseBackend.updateMessage(duplicate)) { + if (mXmppConnectionService.databaseBackend.updateMessage(duplicate, false)) { serverMsgIdUpdated = true; } else { serverMsgIdUpdated = false; @@ -725,7 +725,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece ReadByMarker readByMarker = ReadByMarker.from(counterpart, trueJid); if (message.addReadByMarker(readByMarker)) { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": added read by (" + readByMarker.getRealJid() + ") to message '" + message.getBody() + "'"); - mXmppConnectionService.updateMessage(message); + mXmppConnectionService.updateMessage(message, false); } } } diff --git a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java index 55cf52027..713908c4f 100644 --- a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java @@ -855,9 +855,14 @@ public class DatabaseBackend extends SQLiteOpenHelper { return db; } - public boolean updateMessage(Message message) { + public boolean updateMessage(Message message, boolean includeBody) { SQLiteDatabase db = this.getWritableDatabase(); String[] args = {message.getUuid()}; + ContentValues contentValues = message.getContentValues(); + contentValues.remove(Message.UUID); + if (!includeBody) { + contentValues.remove(Message.BODY); + } return db.update(Message.TABLENAME, message.getContentValues(), Message.UUID + "=?", args) == 1; } diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 13e9ed193..2739bb5ad 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -2616,7 +2616,11 @@ public class XmppConnectionService extends Service { } public void updateMessage(Message message) { - databaseBackend.updateMessage(message); + updateMessage(message, true); + } + + public void updateMessage(Message message, boolean includeBody) { + databaseBackend.updateMessage(message, includeBody); updateConversationUi(); } @@ -3056,7 +3060,7 @@ public class XmppConnectionService extends Service { } message.setErrorMessage(errorMessage); message.setStatus(status); - databaseBackend.updateMessage(message); + databaseBackend.updateMessage(message, false); updateConversationUi(); } @@ -3221,7 +3225,7 @@ public class XmppConnectionService extends Service { if (readMessages.size() > 0) { Runnable runnable = () -> { for (Message message : readMessages) { - databaseBackend.updateMessage(message); + databaseBackend.updateMessage(message, false); } }; mDatabaseWriterExecutor.execute(runnable); diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java index b50072a8c..c12afeefd 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java @@ -771,7 +771,7 @@ public class JingleConnection implements Transferable { this.mJingleStatus = JINGLE_STATUS_FINISHED; this.message.setStatus(Message.STATUS_RECEIVED); this.message.setTransferable(null); - this.mXmppConnectionService.updateMessage(message); + this.mXmppConnectionService.updateMessage(message, false); this.mJingleConnectionManager.finishConnection(this); }