From 74378a88abe663d10ed55d5cb8a1b921cf13d098 Mon Sep 17 00:00:00 2001 From: Ryan ZHAO Date: Thu, 3 Sep 2020 13:14:26 +1000 Subject: [PATCH] fix duplicated sent messages in open groups --- src/org/thoughtcrime/securesms/loki/api/PublicChatPoller.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/org/thoughtcrime/securesms/loki/api/PublicChatPoller.kt b/src/org/thoughtcrime/securesms/loki/api/PublicChatPoller.kt index 80b52c533e..443cc84a59 100644 --- a/src/org/thoughtcrime/securesms/loki/api/PublicChatPoller.kt +++ b/src/org/thoughtcrime/securesms/loki/api/PublicChatPoller.kt @@ -186,6 +186,12 @@ class PublicChatPoller(private val context: Context, private val group: PublicCh } fun processOutgoingMessage(message: PublicChatMessage) { val messageServerID = message.serverID ?: return + val messageID = DatabaseFactory.getLokiMessageDatabase(context).getMessageID(messageServerID) + var isDuplicate = false + if (messageID != null) { + isDuplicate = DatabaseFactory.getMmsDatabase(context).getThreadIdForMessage(messageID) > 0 || DatabaseFactory.getSmsDatabase(context).getThreadIdForMessage(messageID) > 0 + } + if (isDuplicate) { return } if (message.body.isEmpty() && message.attachments.isEmpty() && message.quote == null) { return } val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context) val dataMessage = getDataMessage(message)