Fix read calls being shown as unread in backups.

This commit is contained in:
Michelle Tang
2025-06-05 13:07:44 -04:00
committed by Greyson Parrelli
parent bf0c9ec1c7
commit cc7b26d342
5 changed files with 21 additions and 13 deletions

View File

@@ -747,7 +747,7 @@ private fun CallTable.Call.toRemoteCallUpdate(exportState: ExportState, messageR
}
},
startedCallTimestamp = this.timestamp.clampToValidBackupRange(),
read = messageRecord.read
read = this.read
)
)
}

View File

@@ -263,7 +263,7 @@ class ChatItemArchiveImporter(
}
),
CallTable.TIMESTAMP to updateMessage.individualCall.startedCallTimestamp,
CallTable.READ to CallTable.ReadState.serialize(CallTable.ReadState.UNREAD)
CallTable.READ to updateMessage.individualCall.read
)
db.insert(CallTable.TABLE_NAME, SQLiteDatabase.CONFLICT_IGNORE, values)
}
@@ -292,7 +292,7 @@ class ChatItemArchiveImporter(
}
),
CallTable.TIMESTAMP to updateMessage.groupCall.startedCallTimestamp,
CallTable.READ to CallTable.ReadState.serialize(CallTable.ReadState.UNREAD)
CallTable.READ to CallTable.ReadState.serialize(CallTable.ReadState.READ)
)
db.insert(CallTable.TABLE_NAME, SQLiteDatabase.CONFLICT_IGNORE, values)
}
@@ -741,7 +741,7 @@ class ChatItemArchiveImporter(
}
}
}
this.put(MessageTable.READ, updateMessage.individualCall.read.toInt())
this.put(MessageTable.READ, 1)
}
updateMessage.groupCall != null -> {
val startedCallRecipientId = if (updateMessage.groupCall.startedCallRecipientId != null) {

View File

@@ -21,6 +21,7 @@ import org.signal.core.util.requireBlob
import org.signal.core.util.requireBoolean
import org.signal.core.util.requireInt
import org.signal.core.util.requireLong
import org.signal.core.util.requireObject
import org.signal.core.util.requireString
import org.signal.storageservice.protos.groups.Member
import org.signal.storageservice.protos.groups.local.DecryptedGroup
@@ -145,8 +146,8 @@ class CallEventCache(
private fun canUserBeginCall(peer: Recipient, decryptedGroup: ByteArray?): Boolean {
return if (peer.isGroup && decryptedGroup != null) {
val proto = DecryptedGroup.ADAPTER.decode(decryptedGroup)
return proto.isAnnouncementGroup != EnabledState.ENABLED || proto.members
.firstOrNull() { it.aciBytes == SignalStore.account.aci?.toByteString() }?.role == Member.Role.ADMINISTRATOR
return proto.isAnnouncementGroup != EnabledState.ENABLED ||
proto.members.firstOrNull() { it.aciBytes == SignalStore.account.aci?.toByteString() }?.role == Member.Role.ADMINISTRATOR
} else {
true
}
@@ -180,7 +181,8 @@ class CallEventCache(
messageId = parent.messageId.takeIf { it > 0 },
ringerRecipient = parent.ringerRecipient.takeIf { it > 0 }?.let { RecipientId.from(it) },
isGroupCallActive = parent.isGroupCallActive,
didLocalUserJoin = parent.didLocalUserJoin
didLocalUserJoin = parent.didLocalUserJoin,
read = parent.read
),
date = parent.timestamp,
peer = peer,
@@ -214,7 +216,8 @@ class CallEventCache(
didLocalUserJoin = this.requireBoolean(CallTable.LOCAL_JOINED),
messageId = this.requireLong(CallTable.MESSAGE_ID),
body = this.requireString(MessageTable.BODY),
decryptedGroupBytes = this.requireBlob(GroupTable.V2_DECRYPTED_GROUP)
decryptedGroupBytes = this.requireBlob(GroupTable.V2_DECRYPTED_GROUP),
read = this.requireObject(CallTable.READ, CallTable.ReadState.Serializer) == CallTable.ReadState.READ
)
}
}
@@ -314,6 +317,7 @@ class CallEventCache(
val isGroupCallActive: Boolean,
val didLocalUserJoin: Boolean,
val body: String?,
val decryptedGroupBytes: ByteArray?
val decryptedGroupBytes: ByteArray?,
val read: Boolean
)
}

View File

@@ -1313,7 +1313,8 @@ class CallTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTabl
val timestamp: Long,
val ringerRecipient: RecipientId?,
val isGroupCallActive: Boolean,
val didLocalUserJoin: Boolean
val didLocalUserJoin: Boolean,
val read: Boolean
) {
val messageType: Long = getMessageType(type, direction, event)
@@ -1360,7 +1361,8 @@ class CallTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTabl
}
},
isGroupCallActive = data.requireBoolean(GROUP_CALL_ACTIVE),
didLocalUserJoin = data.requireBoolean(LOCAL_JOINED)
didLocalUserJoin = data.requireBoolean(LOCAL_JOINED),
read = data.requireObject(READ, ReadState.Serializer) == ReadState.READ
)
}
}