Handle syncing of blocked contacts

This commit is contained in:
nielsandriesse 2020-07-16 13:49:46 +10:00
parent 662d9c7c63
commit 5344d6aa64

View File

@ -93,11 +93,13 @@ object SyncMessagesProtocol {
if (!allUserDevices.contains(content.sender)) { return } if (!allUserDevices.contains(content.sender)) { return }
Log.d("Loki", "Received a contact sync message.") Log.d("Loki", "Received a contact sync message.")
val contactsInputStream = DeviceContactsInputStream(message.contactsStream.asStream().inputStream) val contactsInputStream = DeviceContactsInputStream(message.contactsStream.asStream().inputStream)
val contactPublicKeys = contactsInputStream.readAll().map { it.number } val contacts = contactsInputStream.readAll()
for (contactPublicKey in contactPublicKeys) { for (contact in contacts) {
val contactPublicKey = contact.number
if (contactPublicKey == userPublicKey || !PublicKeyValidation.isValid(contactPublicKey)) { return } if (contactPublicKey == userPublicKey || !PublicKeyValidation.isValid(contactPublicKey)) { return }
val applicationContext = context.applicationContext as ApplicationContext val applicationContext = context.applicationContext as ApplicationContext
applicationContext.sendSessionRequestIfNeeded(contactPublicKey) applicationContext.sendSessionRequestIfNeeded(contactPublicKey)
DatabaseFactory.getRecipientDatabase(context).setBlocked(recipient(context, contactPublicKey), contact.isBlocked)
} }
} }