mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 12:08:34 +00:00
Skip messages that aren't in the right place.
This commit is contained in:
@@ -79,6 +79,14 @@ object ExportSkips {
|
||||
return log(sentTimestamp, "Identity verified update for ourselves.")
|
||||
}
|
||||
|
||||
fun fromRecipientIsNotAnIndividual(sentTimestamp: Long): String {
|
||||
return log(sentTimestamp, "The fromRecipient does not represent an individual person.")
|
||||
}
|
||||
|
||||
fun oneOnOneMessageInTheWrongChat(sentTimestamp: Long): String {
|
||||
return log(sentTimestamp, "A 1:1 message is located in the wrong chat.")
|
||||
}
|
||||
|
||||
private fun log(sentTimestamp: Long, message: String): String {
|
||||
return "[SKIP][$sentTimestamp] $message"
|
||||
}
|
||||
|
||||
@@ -1523,7 +1523,8 @@ data class ArchivedMediaObject(val mediaId: String, val cdn: Int)
|
||||
class ExportState(val backupTime: Long, val mediaBackupEnabled: Boolean) {
|
||||
val recipientIds: MutableSet<Long> = hashSetOf()
|
||||
val threadIds: MutableSet<Long> = hashSetOf()
|
||||
val localToRemoteCustomChatColors: MutableMap<Long, Int> = hashMapOf()
|
||||
val contactRecipientIds: MutableSet<Long> = hashSetOf()
|
||||
val threadIdToRecipientId: MutableMap<Long, Long> = hashMapOf()
|
||||
}
|
||||
|
||||
class ImportState(val mediaRootBackupKey: MediaRootBackupKey) {
|
||||
|
||||
@@ -427,6 +427,10 @@ private fun simpleUpdate(type: SimpleChatUpdate.Type): ChatUpdateMessage {
|
||||
private fun BackupMessageRecord.toBasicChatItemBuilder(selfRecipientId: RecipientId, isGroupThread: Boolean, groupReceipts: List<GroupReceiptTable.GroupReceiptInfo>?, exportState: ExportState, backupStartTime: Long): ChatItem.Builder? {
|
||||
val record = this
|
||||
|
||||
if (this.threadId !in exportState.threadIds) {
|
||||
return null
|
||||
}
|
||||
|
||||
val direction = when {
|
||||
record.type.isDirectionlessType() && !record.remoteDeleted -> {
|
||||
Direction.DIRECTIONLESS
|
||||
@@ -450,6 +454,17 @@ private fun BackupMessageRecord.toBasicChatItemBuilder(selfRecipientId: Recipien
|
||||
else -> record.fromRecipientId
|
||||
}
|
||||
|
||||
if (!exportState.contactRecipientIds.contains(fromRecipientId)) {
|
||||
Log.w(TAG, ExportSkips.fromRecipientIsNotAnIndividual(this.dateSent))
|
||||
return null
|
||||
}
|
||||
|
||||
val threadRecipientId = exportState.threadIdToRecipientId[record.threadId]!!
|
||||
if (exportState.contactRecipientIds.contains(threadRecipientId) && fromRecipientId != threadRecipientId && fromRecipientId != selfRecipientId.toLong()) {
|
||||
Log.w(TAG, ExportSkips.oneOnOneMessageInTheWrongChat(this.dateSent))
|
||||
return null
|
||||
}
|
||||
|
||||
val builder = ChatItem.Builder().apply {
|
||||
chatId = record.threadId
|
||||
authorId = fromRecipientId
|
||||
|
||||
@@ -32,6 +32,7 @@ object ChatArchiveProcessor {
|
||||
for (chat in reader) {
|
||||
if (exportState.recipientIds.contains(chat.recipientId)) {
|
||||
exportState.threadIds.add(chat.id)
|
||||
exportState.threadIdToRecipientId[chat.id] = chat.recipientId
|
||||
emitter.emit(Frame(chat = chat))
|
||||
} else {
|
||||
Log.w(TAG, "dropping thread for deleted recipient ${chat.recipientId}")
|
||||
|
||||
@@ -38,6 +38,7 @@ object RecipientArchiveProcessor {
|
||||
val releaseChannelId = signalStore.releaseChannelValues.releaseChannelRecipientId
|
||||
if (releaseChannelId != null) {
|
||||
exportState.recipientIds.add(releaseChannelId.toLong())
|
||||
exportState.contactRecipientIds.add(releaseChannelId.toLong())
|
||||
emitter.emit(
|
||||
Frame(
|
||||
recipient = ArchiveRecipient(
|
||||
@@ -54,6 +55,7 @@ object RecipientArchiveProcessor {
|
||||
for (recipient in reader) {
|
||||
if (recipient != null) {
|
||||
exportState.recipientIds.add(recipient.id)
|
||||
exportState.contactRecipientIds.add(recipient.id)
|
||||
emitter.emit(Frame(recipient = recipient))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user