mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-14 23:18:43 +00:00
Fix validation error around session switchover events.
This commit is contained in:
committed by
jeffrey-signal
parent
e1467480e9
commit
88be84297e
@@ -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.")
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user