do not include body in simple status updates to not trigger fts update

This commit is contained in:
Daniel Gultsch 2018-05-10 10:47:28 +02:00
parent a8b863ae41
commit 5b41906328
5 changed files with 18 additions and 9 deletions

View file

@ -90,7 +90,7 @@ public class PgpDecryptionService {
message.setEncryption(Message.ENCRYPTION_DECRYPTION_FAILED); message.setEncryption(Message.ENCRYPTION_DECRYPTION_FAILED);
} }
} }
mXmppConnectionService.updateMessage(message); mXmppConnectionService.updateMessage(message, false);
continueDecryption(true); continueDecryption(true);
} }

View file

@ -407,7 +407,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
Message previouslySent = conversation.findSentMessageWithUuid(remoteMsgId); Message previouslySent = conversation.findSentMessageWithUuid(remoteMsgId);
if (previouslySent != null && previouslySent.getServerMsgId() == null && serverMsgId != null) { if (previouslySent != null && previouslySent.getServerMsgId() == null && serverMsgId != null) {
previouslySent.setServerMsgId(serverMsgId); 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..."); 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 && duplicate.getServerMsgId() == null
&& message.getServerMsgId() != null) { && message.getServerMsgId() != null) {
duplicate.setServerMsgId(message.getServerMsgId()); duplicate.setServerMsgId(message.getServerMsgId());
if (mXmppConnectionService.databaseBackend.updateMessage(duplicate)) { if (mXmppConnectionService.databaseBackend.updateMessage(duplicate, false)) {
serverMsgIdUpdated = true; serverMsgIdUpdated = true;
} else { } else {
serverMsgIdUpdated = false; serverMsgIdUpdated = false;
@ -725,7 +725,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
ReadByMarker readByMarker = ReadByMarker.from(counterpart, trueJid); ReadByMarker readByMarker = ReadByMarker.from(counterpart, trueJid);
if (message.addReadByMarker(readByMarker)) { if (message.addReadByMarker(readByMarker)) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": added read by (" + readByMarker.getRealJid() + ") to message '" + message.getBody() + "'"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": added read by (" + readByMarker.getRealJid() + ") to message '" + message.getBody() + "'");
mXmppConnectionService.updateMessage(message); mXmppConnectionService.updateMessage(message, false);
} }
} }
} }

View file

@ -855,9 +855,14 @@ public class DatabaseBackend extends SQLiteOpenHelper {
return db; return db;
} }
public boolean updateMessage(Message message) { public boolean updateMessage(Message message, boolean includeBody) {
SQLiteDatabase db = this.getWritableDatabase(); SQLiteDatabase db = this.getWritableDatabase();
String[] args = {message.getUuid()}; 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; return db.update(Message.TABLENAME, message.getContentValues(), Message.UUID + "=?", args) == 1;
} }

View file

@ -2616,7 +2616,11 @@ public class XmppConnectionService extends Service {
} }
public void updateMessage(Message message) { public void updateMessage(Message message) {
databaseBackend.updateMessage(message); updateMessage(message, true);
}
public void updateMessage(Message message, boolean includeBody) {
databaseBackend.updateMessage(message, includeBody);
updateConversationUi(); updateConversationUi();
} }
@ -3056,7 +3060,7 @@ public class XmppConnectionService extends Service {
} }
message.setErrorMessage(errorMessage); message.setErrorMessage(errorMessage);
message.setStatus(status); message.setStatus(status);
databaseBackend.updateMessage(message); databaseBackend.updateMessage(message, false);
updateConversationUi(); updateConversationUi();
} }
@ -3221,7 +3225,7 @@ public class XmppConnectionService extends Service {
if (readMessages.size() > 0) { if (readMessages.size() > 0) {
Runnable runnable = () -> { Runnable runnable = () -> {
for (Message message : readMessages) { for (Message message : readMessages) {
databaseBackend.updateMessage(message); databaseBackend.updateMessage(message, false);
} }
}; };
mDatabaseWriterExecutor.execute(runnable); mDatabaseWriterExecutor.execute(runnable);

View file

@ -771,7 +771,7 @@ public class JingleConnection implements Transferable {
this.mJingleStatus = JINGLE_STATUS_FINISHED; this.mJingleStatus = JINGLE_STATUS_FINISHED;
this.message.setStatus(Message.STATUS_RECEIVED); this.message.setStatus(Message.STATUS_RECEIVED);
this.message.setTransferable(null); this.message.setTransferable(null);
this.mXmppConnectionService.updateMessage(message); this.mXmppConnectionService.updateMessage(message, false);
this.mJingleConnectionManager.finishConnection(this); this.mJingleConnectionManager.finishConnection(this);
} }