mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 09:17:44 +00:00
Maintain consistent code style
This commit is contained in:
parent
aa3b7fe1b0
commit
824bdc6089
@ -23,6 +23,7 @@ import org.whispersystems.signalservice.api.messages.multidevice.SentTranscriptM
|
|||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress
|
||||||
import org.whispersystems.signalservice.loki.api.*
|
import org.whispersystems.signalservice.loki.api.*
|
||||||
import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus
|
import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus
|
||||||
|
import org.whispersystems.signalservice.loki.utilities.successBackground
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@ -236,24 +237,22 @@ class LokiPublicChatPoller(private val context: Context, private val group: Loki
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Promise.of(messages)
|
Promise.of(messages)
|
||||||
}.success {
|
}.successBackground {
|
||||||
val newDisplayNameUpdatees = uniqueDevices.mapNotNull {
|
val newDisplayNameUpdatees = uniqueDevices.mapNotNull {
|
||||||
// This will return null if the current device is a master device
|
// This will return null if the current device is a master device
|
||||||
LokiDeviceLinkUtilities.getMasterHexEncodedPublicKey(it).get()
|
LokiDeviceLinkUtilities.getMasterHexEncodedPublicKey(it).get()
|
||||||
}.toSet()
|
}.toSet()
|
||||||
// Fetch the display names of the master devices
|
// Fetch the display names of the master devices
|
||||||
displayNameUpdatees = displayNameUpdatees.union(newDisplayNameUpdatees)
|
displayNameUpdatees = displayNameUpdatees.union(newDisplayNameUpdatees)
|
||||||
}.success { messages ->
|
}.successBackground { messages ->
|
||||||
// Process messages in the background
|
// Process messages in the background
|
||||||
Thread {
|
messages.forEach { message ->
|
||||||
messages.forEach { message ->
|
if (userDevices.contains(message.hexEncodedPublicKey)) {
|
||||||
if (userDevices.contains(message.hexEncodedPublicKey)) {
|
processOutgoingMessage(message)
|
||||||
processOutgoingMessage(message)
|
} else {
|
||||||
} else {
|
processIncomingMessage(message)
|
||||||
processIncomingMessage(message)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}.start()
|
}
|
||||||
}.fail {
|
}.fail {
|
||||||
Log.d("Loki", "Failed to get messages for group chat with ID: ${group.channel} on server: ${group.server}.")
|
Log.d("Loki", "Failed to get messages for group chat with ID: ${group.channel} on server: ${group.server}.")
|
||||||
}
|
}
|
||||||
@ -263,13 +262,11 @@ class LokiPublicChatPoller(private val context: Context, private val group: Loki
|
|||||||
if (displayNameUpdatees.isEmpty()) { return }
|
if (displayNameUpdatees.isEmpty()) { return }
|
||||||
val hexEncodedPublicKeys = displayNameUpdatees
|
val hexEncodedPublicKeys = displayNameUpdatees
|
||||||
displayNameUpdatees = setOf()
|
displayNameUpdatees = setOf()
|
||||||
api.getDisplayNames(hexEncodedPublicKeys, group.server).success { mapping ->
|
api.getDisplayNames(hexEncodedPublicKeys, group.server).successBackground { mapping ->
|
||||||
Thread {
|
for (pair in mapping.entries) {
|
||||||
for (pair in mapping.entries) {
|
val senderDisplayName = "${pair.value} (...${pair.key.takeLast(8)})"
|
||||||
val senderDisplayName = "${pair.value} (...${pair.key.takeLast(8)})"
|
DatabaseFactory.getLokiUserDatabase(context).setServerDisplayName(group.id, pair.key, senderDisplayName)
|
||||||
DatabaseFactory.getLokiUserDatabase(context).setServerDisplayName(group.id, pair.key, senderDisplayName)
|
}
|
||||||
}
|
|
||||||
}.start()
|
|
||||||
}.fail {
|
}.fail {
|
||||||
displayNameUpdatees = displayNameUpdatees.union(hexEncodedPublicKeys)
|
displayNameUpdatees = displayNameUpdatees.union(hexEncodedPublicKeys)
|
||||||
}
|
}
|
||||||
@ -277,16 +274,14 @@ class LokiPublicChatPoller(private val context: Context, private val group: Loki
|
|||||||
|
|
||||||
private fun pollForDeletedMessages() {
|
private fun pollForDeletedMessages() {
|
||||||
api.getDeletedMessageServerIDs(group.channel, group.server).success { deletedMessageServerIDs ->
|
api.getDeletedMessageServerIDs(group.channel, group.server).success { deletedMessageServerIDs ->
|
||||||
Thread {
|
val lokiMessageDatabase = DatabaseFactory.getLokiMessageDatabase(context)
|
||||||
val lokiMessageDatabase = DatabaseFactory.getLokiMessageDatabase(context)
|
val deletedMessageIDs = deletedMessageServerIDs.mapNotNull { lokiMessageDatabase.getMessageID(it) }
|
||||||
val deletedMessageIDs = deletedMessageServerIDs.mapNotNull { lokiMessageDatabase.getMessageID(it) }
|
val smsMessageDatabase = DatabaseFactory.getSmsDatabase(context)
|
||||||
val smsMessageDatabase = DatabaseFactory.getSmsDatabase(context)
|
val mmsMessageDatabase = DatabaseFactory.getMmsDatabase(context)
|
||||||
val mmsMessageDatabase = DatabaseFactory.getMmsDatabase(context)
|
deletedMessageIDs.forEach {
|
||||||
deletedMessageIDs.forEach {
|
smsMessageDatabase.deleteMessage(it)
|
||||||
smsMessageDatabase.deleteMessage(it)
|
mmsMessageDatabase.delete(it)
|
||||||
mmsMessageDatabase.delete(it)
|
}
|
||||||
}
|
|
||||||
}.start()
|
|
||||||
}.fail {
|
}.fail {
|
||||||
Log.d("Loki", "Failed to get deleted messages for group chat with ID: ${group.channel} on server: ${group.server}.")
|
Log.d("Loki", "Failed to get deleted messages for group chat with ID: ${group.channel} on server: ${group.server}.")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user