mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-24 10:57:18 +00:00
feat: incorporate hashes from library, more wrapper for user groups and serialization from c++
This commit is contained in:
@@ -57,6 +57,15 @@ data class ConfigurationSyncJob(val destination: Destination): Job {
|
||||
// don't run anything if we don't need to push anything
|
||||
if (configsRequiringPush.isEmpty()) return delegate.handleJobSucceeded(this, dispatcherName)
|
||||
|
||||
// need to get the current hashes before we call `push()`
|
||||
val toDeleteRequest = configsRequiringPush.map { base ->
|
||||
// accumulate by adding together
|
||||
base.currentHashes()
|
||||
}.reduce(List<String>::plus).let { toDeleteFromAllNamespaces ->
|
||||
if (toDeleteFromAllNamespaces.isEmpty()) null
|
||||
else SnodeAPI.buildAuthenticatedDeleteBatchInfo(destination.destinationPublicKey(), toDeleteFromAllNamespaces)
|
||||
}
|
||||
|
||||
// allow null results here so the list index matches configsRequiringPush
|
||||
val batchObjects: List<Pair<SharedConfigurationMessage, SnodeAPI.SnodeBatchRequestInfo>?> = configsRequiringPush.map { config ->
|
||||
val (data, seqNo) = config.push()
|
||||
@@ -72,14 +81,6 @@ data class ConfigurationSyncJob(val destination: Destination): Job {
|
||||
message to authenticated // to keep track of seqNo for calling confirmPushed later
|
||||
}
|
||||
|
||||
val toDeleteRequest = configsRequiringPush.map { base ->
|
||||
base.obsoleteHashes()
|
||||
// accumulate by adding together
|
||||
}.reduce(List<String>::plus).let { toDeleteFromAllNamespaces ->
|
||||
if (toDeleteFromAllNamespaces.isEmpty()) null
|
||||
else SnodeAPI.buildAuthenticatedDeleteBatchInfo(destination.destinationPublicKey(), toDeleteFromAllNamespaces)
|
||||
}
|
||||
|
||||
if (batchObjects.any { it == null }) {
|
||||
// stop running here, something like a signing error occurred
|
||||
return delegate.handleJobFailedPermanently(this, dispatcherName, NullPointerException("One or more requests had a null batch request info"))
|
||||
@@ -137,8 +138,6 @@ data class ConfigurationSyncJob(val destination: Destination): Job {
|
||||
// confirm pushed seqno
|
||||
val thisSeqNo = toPushMessage.seqNo
|
||||
config.confirmPushed(thisSeqNo, insertHash)
|
||||
// wipe any of the existing hashes which we deleted (they may or may not be in this namespace)
|
||||
config.removeObsoleteHashes(deletedHashes.toTypedArray())
|
||||
Log.d(TAG, "Successfully removed the deleted hashes from ${config.javaClass.simpleName}")
|
||||
// dump and write config after successful
|
||||
if (config.needsDump()) { // usually this will be true?
|
||||
|
||||
@@ -137,7 +137,7 @@ class Poller(private val configFactory: ConfigFactoryProtocol, debounceTimer: Ti
|
||||
namespace,
|
||||
updateLatestHash = false,
|
||||
updateStoredHashes = false,
|
||||
).filter { (_, hash) -> !forConfigObject.obsoleteHashes().contains(hash) }
|
||||
).filter { (_, hash) -> !forConfigObject.currentHashes().contains(hash) }
|
||||
|
||||
if (messages.isEmpty()) {
|
||||
// no new messages to process
|
||||
|
||||
Reference in New Issue
Block a user