mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 20:18:36 +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.")
|
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 {
|
private fun log(sentTimestamp: Long, message: String): String {
|
||||||
return "[SKIP][$sentTimestamp] $message"
|
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) {
|
class ExportState(val backupTime: Long, val mediaBackupEnabled: Boolean) {
|
||||||
val recipientIds: MutableSet<Long> = hashSetOf()
|
val recipientIds: MutableSet<Long> = hashSetOf()
|
||||||
val threadIds: 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) {
|
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? {
|
private fun BackupMessageRecord.toBasicChatItemBuilder(selfRecipientId: RecipientId, isGroupThread: Boolean, groupReceipts: List<GroupReceiptTable.GroupReceiptInfo>?, exportState: ExportState, backupStartTime: Long): ChatItem.Builder? {
|
||||||
val record = this
|
val record = this
|
||||||
|
|
||||||
|
if (this.threadId !in exportState.threadIds) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
val direction = when {
|
val direction = when {
|
||||||
record.type.isDirectionlessType() && !record.remoteDeleted -> {
|
record.type.isDirectionlessType() && !record.remoteDeleted -> {
|
||||||
Direction.DIRECTIONLESS
|
Direction.DIRECTIONLESS
|
||||||
@@ -450,6 +454,17 @@ private fun BackupMessageRecord.toBasicChatItemBuilder(selfRecipientId: Recipien
|
|||||||
else -> record.fromRecipientId
|
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 {
|
val builder = ChatItem.Builder().apply {
|
||||||
chatId = record.threadId
|
chatId = record.threadId
|
||||||
authorId = fromRecipientId
|
authorId = fromRecipientId
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ object ChatArchiveProcessor {
|
|||||||
for (chat in reader) {
|
for (chat in reader) {
|
||||||
if (exportState.recipientIds.contains(chat.recipientId)) {
|
if (exportState.recipientIds.contains(chat.recipientId)) {
|
||||||
exportState.threadIds.add(chat.id)
|
exportState.threadIds.add(chat.id)
|
||||||
|
exportState.threadIdToRecipientId[chat.id] = chat.recipientId
|
||||||
emitter.emit(Frame(chat = chat))
|
emitter.emit(Frame(chat = chat))
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "dropping thread for deleted recipient ${chat.recipientId}")
|
Log.w(TAG, "dropping thread for deleted recipient ${chat.recipientId}")
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ object RecipientArchiveProcessor {
|
|||||||
val releaseChannelId = signalStore.releaseChannelValues.releaseChannelRecipientId
|
val releaseChannelId = signalStore.releaseChannelValues.releaseChannelRecipientId
|
||||||
if (releaseChannelId != null) {
|
if (releaseChannelId != null) {
|
||||||
exportState.recipientIds.add(releaseChannelId.toLong())
|
exportState.recipientIds.add(releaseChannelId.toLong())
|
||||||
|
exportState.contactRecipientIds.add(releaseChannelId.toLong())
|
||||||
emitter.emit(
|
emitter.emit(
|
||||||
Frame(
|
Frame(
|
||||||
recipient = ArchiveRecipient(
|
recipient = ArchiveRecipient(
|
||||||
@@ -54,6 +55,7 @@ object RecipientArchiveProcessor {
|
|||||||
for (recipient in reader) {
|
for (recipient in reader) {
|
||||||
if (recipient != null) {
|
if (recipient != null) {
|
||||||
exportState.recipientIds.add(recipient.id)
|
exportState.recipientIds.add(recipient.id)
|
||||||
|
exportState.contactRecipientIds.add(recipient.id)
|
||||||
emitter.emit(Frame(recipient = recipient))
|
emitter.emit(Frame(recipient = recipient))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user