From fc62cbbc5293b4dfe35b2d7d1bd8db8f4e3d3dc6 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 21 Apr 2018 19:35:25 +0200 Subject: [PATCH] fixed updating of server message id after dedup --- .../java/eu/siacs/conversations/parser/MessageParser.java | 8 ++++++-- .../siacs/conversations/persistance/DatabaseBackend.java | 5 ++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index c84d401e1..8809ba42f 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -520,8 +520,12 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece && duplicate.getServerMsgId() == null && message.getServerMsgId() != null) { duplicate.setServerMsgId(message.getServerMsgId()); - mXmppConnectionService.databaseBackend.updateMessage(message); - serverMsgIdUpdated = true; + if (mXmppConnectionService.databaseBackend.updateMessage(duplicate)) { + serverMsgIdUpdated = true; + } else { + serverMsgIdUpdated = false; + Log.e(Config.LOGTAG,"failed to update message"); + } } else { serverMsgIdUpdated = false; } diff --git a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java index 035a7a8e8..1a169166f 100644 --- a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java @@ -825,11 +825,10 @@ public class DatabaseBackend extends SQLiteOpenHelper { return db; } - public void updateMessage(Message message) { + public boolean updateMessage(Message message) { SQLiteDatabase db = this.getWritableDatabase(); String[] args = {message.getUuid()}; - db.update(Message.TABLENAME, message.getContentValues(), Message.UUID - + "=?", args); + return db.update(Message.TABLENAME, message.getContentValues(), Message.UUID + "=?", args) == 1; } public void updateMessage(Message message, String uuid) {