Fix validation error around session switchover events.

This commit is contained in:
Greyson Parrelli
2026-01-06 10:22:18 -05:00
committed by jeffrey-signal
parent e1467480e9
commit 88be84297e
2 changed files with 8 additions and 8 deletions

View File

@@ -163,6 +163,10 @@ object ExportSkips {
return log(0, "Tried to export multiple recipients with RecipientId::$recipientId")
}
fun invalidE164InSessionSwitchover(sentTimestamp: Long): String {
return log(sentTimestamp, "Invalid e164 in sessions switchover event. Exporting an empty event.")
}
private fun log(sentTimestamp: Long, message: String): String {
return "[SKIP][$sentTimestamp] $message"
}
@@ -210,10 +214,6 @@ object ExportOddities {
return log(sentTimestamp, "Quote had no text or attachments. Removing it.")
}
fun invalidE164InSessionSwitchover(sentTimestamp: Long): String {
return log(sentTimestamp, "Invalid e164 in sessions switchover event. Exporting an empty event.")
}
fun undownloadedLongTextAttachment(sentTimestamp: Long): String {
return log(sentTimestamp, "Long text attachment was not yet downloaded. Falling back to the known body with an attachment pointer.")
}

View File

@@ -311,7 +311,7 @@ class ChatItemArchiveExporter(
}
MessageTypes.isSessionSwitchoverType(record.type) -> {
builder.updateMessage = record.toRemoteSessionSwitchoverUpdate(record.dateSent)
builder.updateMessage = record.toRemoteSessionSwitchoverUpdate(record.dateSent) ?: continue
transformTimer.emit("sse")
}
@@ -679,7 +679,7 @@ private fun BackupMessageRecord.toRemoteProfileChangeUpdate(): ChatUpdateMessage
}
}
private fun BackupMessageRecord.toRemoteSessionSwitchoverUpdate(sentTimestamp: Long): ChatUpdateMessage {
private fun BackupMessageRecord.toRemoteSessionSwitchoverUpdate(sentTimestamp: Long): ChatUpdateMessage? {
if (this.body == null) {
return ChatUpdateMessage(sessionSwitchover = SessionSwitchoverChatUpdate())
}
@@ -687,10 +687,10 @@ private fun BackupMessageRecord.toRemoteSessionSwitchoverUpdate(sentTimestamp: L
return ChatUpdateMessage(
sessionSwitchover = try {
val event = SessionSwitchoverEvent.ADAPTER.decode(Base64.decodeOrThrow(this.body))
val e164 = event.e164.e164ToLong() ?: return ChatUpdateMessage(sessionSwitchover = SessionSwitchoverChatUpdate()).logW(TAG, ExportOddities.invalidE164InSessionSwitchover(sentTimestamp))
val e164 = event.e164.e164ToLong() ?: return null.logW(TAG, ExportSkips.invalidE164InSessionSwitchover(sentTimestamp))
SessionSwitchoverChatUpdate(e164)
} catch (e: IOException) {
SessionSwitchoverChatUpdate()
null
}
)
}