mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 20:15:21 +00:00
Clean
This commit is contained in:
parent
5344d6aa64
commit
0818b4c0e2
@ -52,8 +52,9 @@ object SyncMessagesProtocol {
|
|||||||
val allAddresses = ArrayList(DatabaseFactory.getRecipientDatabase(context).allAddresses)
|
val allAddresses = ArrayList(DatabaseFactory.getRecipientDatabase(context).allAddresses)
|
||||||
val result = mutableSetOf<ContactData>()
|
val result = mutableSetOf<ContactData>()
|
||||||
for (address in allAddresses) {
|
for (address in allAddresses) {
|
||||||
if (!shouldSyncContact(context, address)) { continue }
|
if (!shouldSyncContact(context, address.serialize())) { continue }
|
||||||
val threadID = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(Recipient.from(context, address, false))
|
val threadID = DatabaseFactory.getThreadDatabase(context).getThreadIdIfExistsFor(Recipient.from(context, address, false))
|
||||||
|
if (threadID < 0) { continue }
|
||||||
val displayName = DatabaseFactory.getLokiUserDatabase(context).getDisplayName(address.serialize())
|
val displayName = DatabaseFactory.getLokiUserDatabase(context).getDisplayName(address.serialize())
|
||||||
val contactData = ContactData(threadID, displayName)
|
val contactData = ContactData(threadID, displayName)
|
||||||
contactData.numbers.add(NumberData("TextSecure", address.serialize()))
|
contactData.numbers.add(NumberData("TextSecure", address.serialize()))
|
||||||
@ -63,10 +64,11 @@ object SyncMessagesProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun shouldSyncContact(context: Context, address: Address): Boolean {
|
fun shouldSyncContact(context: Context, publicKey: String): Boolean {
|
||||||
if (!PublicKeyValidation.isValid(address.serialize())) { return false }
|
if (!PublicKeyValidation.isValid(publicKey)) { return false }
|
||||||
if (address.serialize() == TextSecurePreferences.getMasterHexEncodedPublicKey(context)) { return false }
|
if (publicKey == TextSecurePreferences.getMasterHexEncodedPublicKey(context)) { return false }
|
||||||
if (address.serialize() == TextSecurePreferences.getLocalNumber(context)) { return false }
|
if (publicKey == TextSecurePreferences.getLocalNumber(context)) { return false }
|
||||||
|
if (MultiDeviceProtocol.shared.getSlaveDevices(publicKey).contains(publicKey)) { return false }
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,6 +102,7 @@ object SyncMessagesProtocol {
|
|||||||
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)
|
DatabaseFactory.getRecipientDatabase(context).setBlocked(recipient(context, contactPublicKey), contact.isBlocked)
|
||||||
|
DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipient(context, contactPublicKey)) // Creates the thread if needed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,9 +125,9 @@ object SyncMessagesProtocol {
|
|||||||
closedGroup.avatar.orNull(),
|
closedGroup.avatar.orNull(),
|
||||||
closedGroup.admins
|
closedGroup.admins
|
||||||
)
|
)
|
||||||
val signalServiceDataMessage = SignalServiceDataMessage(content.timestamp, signalServiceGroup, null, null)
|
val dataMessage = SignalServiceDataMessage(content.timestamp, signalServiceGroup, null, null)
|
||||||
// This establishes sessions internally
|
// This establishes sessions internally
|
||||||
GroupMessageProcessor.process(context, content, signalServiceDataMessage, false)
|
GroupMessageProcessor.process(context, content, dataMessage, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user