Fix validation errors around group chat updates.

This commit is contained in:
Greyson Parrelli
2026-01-06 11:26:45 -05:00
committed by jeffrey-signal
parent 1da75018eb
commit e7bfefa027
2 changed files with 13 additions and 0 deletions

View File

@@ -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.")
}

View File

@@ -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 ||