diff --git a/src/cheogram/java/com/cheogram/android/WebxdcPage.java b/src/cheogram/java/com/cheogram/android/WebxdcPage.java index 6174de0ad9f995ef31318adb455ad025a5bb21ff..1ec8bc4690cea9a28f3cc885bc4bd0ca659d2cae 100644 --- a/src/cheogram/java/com/cheogram/android/WebxdcPage.java +++ b/src/cheogram/java/com/cheogram/android/WebxdcPage.java @@ -294,6 +294,7 @@ public class WebxdcPage implements ConversationPage { xmppConnectionService.sendMessage(message); xmppConnectionService.insertWebxdcUpdate(new WebxdcUpdate( (Conversation) message.getConversation(), + message.getUuid(), selfJid(), message.getThread(), params.optString("info", null), diff --git a/src/cheogram/java/com/cheogram/android/WebxdcUpdate.java b/src/cheogram/java/com/cheogram/android/WebxdcUpdate.java index 4e8168f1ed70df52971d3d502c44c9e90347b61f..0e2f8bea19adfc0655d80d560edf0fa3df69f17a 100644 --- a/src/cheogram/java/com/cheogram/android/WebxdcUpdate.java +++ b/src/cheogram/java/com/cheogram/android/WebxdcUpdate.java @@ -14,6 +14,7 @@ public class WebxdcUpdate { protected final Long serial; protected final Long maxSerial; protected final String conversationId; + protected final String messageId; protected final Jid sender; protected final String thread; protected final String threadParent; @@ -22,10 +23,11 @@ public class WebxdcUpdate { protected final String summary; protected final String payload; - public WebxdcUpdate(final Conversation conversation, final Jid sender, final Element thread, final String info, final String document, final String summary, final String payload) { + public WebxdcUpdate(final Conversation conversation, final String messageId, final Jid sender, final Element thread, final String info, final String document, final String summary, final String payload) { this.serial = null; this.maxSerial = null; this.conversationId = conversation.getUuid(); + this.messageId = messageId; this.sender = sender; this.thread = thread.getContent(); this.threadParent = thread.getAttribute("parent"); @@ -39,6 +41,7 @@ public class WebxdcUpdate { this.maxSerial = maxSerial; this.serial = cursor.getLong(cursor.getColumnIndex("serial")); this.conversationId = cursor.getString(cursor.getColumnIndex(Message.CONVERSATION)); + this.messageId = cursor.getString(cursor.getColumnIndex("message_id")); this.sender = Jid.of(cursor.getString(cursor.getColumnIndex("sender"))); this.thread = cursor.getString(cursor.getColumnIndex("thread")); this.threadParent = cursor.getString(cursor.getColumnIndex("threadParent")); @@ -55,6 +58,7 @@ public class WebxdcUpdate { public ContentValues getContentValues() { ContentValues cv = new ContentValues(); cv.put(Message.CONVERSATION, conversationId); + cv.put("message_id", messageId); cv.put("sender", sender.toEscapedString()); cv.put("thread", thread); cv.put("threadParent", threadParent); diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index b077755b0f90721d08d4aff91d4472b8caa16588..640b86f46f70a6c72815122899205e6821825406 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -536,6 +536,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece } mXmppConnectionService.insertWebxdcUpdate(new WebxdcUpdate( conversation, + remoteMsgId, counterpart, packet.findChild("thread"), body == null ? null : body.content, diff --git a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java index fbe560fa71dfcc5d8d220b4d1b7260a6b1f4ac89..6856fe291e081b4f7c009929ee3498a4882c8922 100644 --- a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java @@ -311,6 +311,15 @@ public class DatabaseBackend extends SQLiteOpenHelper { db.execSQL("PRAGMA cheogram.user_version = 8"); } + if(cheogramVersion < 9) { + db.execSQL( + "ALTER TABLE cheogram.webxdc_updates " + + "ADD COLUMN message_id TEXT" + ); + db.execSQL("CREATE UNIQUE INDEX cheogram.webxdc_message_id_index ON webxdc_updates (" + Message.CONVERSATION + ", message_id)"); + db.execSQL("PRAGMA cheogram.user_version = 9"); + } + db.setTransactionSuccessful(); } finally { db.endTransaction(); @@ -854,7 +863,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { public void insertWebxdcUpdate(final WebxdcUpdate update) { SQLiteDatabase db = this.getWritableDatabase(); - db.insert("cheogram.webxdc_updates", null, update.getContentValues()); + db.insertWithOnConflict("cheogram.webxdc_updates", null, update.getContentValues(), SQLiteDatabase.CONFLICT_IGNORE); } public WebxdcUpdate findLastWebxdcUpdate(Message message) {