diff --git a/app/src/main/java/org/thoughtcrime/securesms/backup/v2/ArchiveErrorCases.kt b/app/src/main/java/org/thoughtcrime/securesms/backup/v2/ArchiveErrorCases.kt index 32d547aa6b..e6ee2eb992 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/backup/v2/ArchiveErrorCases.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/backup/v2/ArchiveErrorCases.kt @@ -143,6 +143,10 @@ object ExportSkips { return log(sentTimestamp, "A chat update that only makes sense for individual chats was found in a different kind of chat.") } + fun groupChatUpdateInWrongTypeOfChat(sentTimestamp: Long): String { + return log(sentTimestamp, "A chat update that only makes sense for group chats was found in a different kind of chat.") + } + fun individualChatUpdateNotAuthoredBySelf(sentTimestamp: Long): String { return log(sentTimestamp, "A chat update that only makes sense to be authored by self has a different author.") } diff --git a/app/src/main/java/org/thoughtcrime/securesms/backup/v2/exporters/ChatItemArchiveExporter.kt b/app/src/main/java/org/thoughtcrime/securesms/backup/v2/exporters/ChatItemArchiveExporter.kt index c30618bcaf..429518b504 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/backup/v2/exporters/ChatItemArchiveExporter.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/backup/v2/exporters/ChatItemArchiveExporter.kt @@ -1667,6 +1667,11 @@ private fun ChatItem.validateChatItem(exportState: ExportState, selfRecipientId: return null } + if (this.updateMessage != null && this.updateMessage.isOnlyForGroupChats() && exportState.threadIdToRecipientId[this.chatId] !in exportState.groupRecipientIds) { + Log.w(TAG, ExportSkips.groupChatUpdateInWrongTypeOfChat(this.dateSent)) + return null + } + if (this.updateMessage != null && this.updateMessage.canOnlyBeAuthoredBySelf() && this.authorId != selfRecipientId.toLong()) { Log.w(TAG, ExportSkips.individualChatUpdateNotAuthoredBySelf(this.dateSent)) return null @@ -1693,6 +1698,10 @@ private fun ChatUpdateMessage.isOnlyForIndividualChats(): Boolean { this.simpleUpdate?.type == SimpleChatUpdate.Type.PAYMENTS_ACTIVATED } +private fun ChatUpdateMessage.isOnlyForGroupChats(): Boolean { + return this.groupChange != null +} + private fun ChatUpdateMessage.canOnlyBeAuthoredBySelf(): Boolean { return this.simpleUpdate?.type == SimpleChatUpdate.Type.REPORTED_SPAM || this.simpleUpdate?.type == SimpleChatUpdate.Type.MESSAGE_REQUEST_ACCEPTED ||