Merge pull request #2427 from vector-im/feature/bma/dominaezz_cleanup
Feature/bma/dominaezz cleanup
This commit is contained in:
commit
5b278f704c
|
@ -66,9 +66,9 @@ class FormattedJsonHttpLogger : HttpLoggingInterceptor.Logger {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun logJson(formattedJson: String) {
|
private fun logJson(formattedJson: String) {
|
||||||
val arr = formattedJson.split("\n".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
formattedJson
|
||||||
for (s in arr) {
|
.lines()
|
||||||
Timber.v(s)
|
.dropLastWhile { it.isEmpty() }
|
||||||
}
|
.forEach { Timber.v(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,13 +44,12 @@ object PermalinkParser {
|
||||||
if (fragment.isNullOrEmpty()) {
|
if (fragment.isNullOrEmpty()) {
|
||||||
return PermalinkData.FallbackLink(uri)
|
return PermalinkData.FallbackLink(uri)
|
||||||
}
|
}
|
||||||
val indexOfQuery = fragment.indexOf("?")
|
val safeFragment = fragment.substringBefore('?')
|
||||||
val safeFragment = if (indexOfQuery != -1) fragment.substring(0, indexOfQuery) else fragment
|
|
||||||
val viaQueryParameters = fragment.getViaParameters()
|
val viaQueryParameters = fragment.getViaParameters()
|
||||||
|
|
||||||
// we are limiting to 2 params
|
// we are limiting to 2 params
|
||||||
val params = safeFragment
|
val params = safeFragment
|
||||||
.split(MatrixPatterns.SEP_REGEX.toRegex())
|
.split(MatrixPatterns.SEP_REGEX)
|
||||||
.filter { it.isNotEmpty() }
|
.filter { it.isNotEmpty() }
|
||||||
.take(2)
|
.take(2)
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,6 @@ import org.matrix.android.sdk.internal.task.TaskThread
|
||||||
import org.matrix.android.sdk.internal.task.configureWith
|
import org.matrix.android.sdk.internal.task.configureWith
|
||||||
import org.matrix.android.sdk.internal.util.JsonCanonicalizer
|
import org.matrix.android.sdk.internal.util.JsonCanonicalizer
|
||||||
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
||||||
import org.matrix.android.sdk.internal.util.withoutPrefix
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo
|
import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo
|
||||||
|
@ -444,7 +443,7 @@ internal class DefaultCrossSigningService @Inject constructor(
|
||||||
} else {
|
} else {
|
||||||
// Maybe it's signed by a locally trusted device?
|
// Maybe it's signed by a locally trusted device?
|
||||||
myMasterKey.signatures?.get(userId)?.forEach { (key, value) ->
|
myMasterKey.signatures?.get(userId)?.forEach { (key, value) ->
|
||||||
val potentialDeviceId = key.withoutPrefix("ed25519:")
|
val potentialDeviceId = key.removePrefix("ed25519:")
|
||||||
val potentialDevice = myDevices?.firstOrNull { it.deviceId == potentialDeviceId } // cryptoStore.getUserDevice(userId, potentialDeviceId)
|
val potentialDevice = myDevices?.firstOrNull { it.deviceId == potentialDeviceId } // cryptoStore.getUserDevice(userId, potentialDeviceId)
|
||||||
if (potentialDevice != null && potentialDevice.isVerified) {
|
if (potentialDevice != null && potentialDevice.isVerified) {
|
||||||
// Check signature validity?
|
// Check signature validity?
|
||||||
|
|
|
@ -28,7 +28,6 @@ import org.matrix.android.sdk.internal.crypto.OutgoingGossipingRequestManager
|
||||||
import org.matrix.android.sdk.internal.crypto.actions.SetDeviceVerificationAction
|
import org.matrix.android.sdk.internal.crypto.actions.SetDeviceVerificationAction
|
||||||
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
|
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
|
||||||
import org.matrix.android.sdk.internal.extensions.toUnsignedInt
|
import org.matrix.android.sdk.internal.extensions.toUnsignedInt
|
||||||
import org.matrix.android.sdk.internal.util.withoutPrefix
|
|
||||||
import org.matrix.olm.OlmSAS
|
import org.matrix.olm.OlmSAS
|
||||||
import org.matrix.olm.OlmUtility
|
import org.matrix.olm.OlmUtility
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
@ -250,7 +249,7 @@ internal abstract class SASDefaultVerificationTransaction(
|
||||||
|
|
||||||
// cannot be empty because it has been validated
|
// cannot be empty because it has been validated
|
||||||
theirMacSafe.mac.keys.forEach {
|
theirMacSafe.mac.keys.forEach {
|
||||||
val keyIDNoPrefix = it.withoutPrefix("ed25519:")
|
val keyIDNoPrefix = it.removePrefix("ed25519:")
|
||||||
val otherDeviceKey = otherUserKnownDevices?.get(keyIDNoPrefix)?.fingerprint()
|
val otherDeviceKey = otherUserKnownDevices?.get(keyIDNoPrefix)?.fingerprint()
|
||||||
if (otherDeviceKey == null) {
|
if (otherDeviceKey == null) {
|
||||||
Timber.w("## SAS Verification: Could not find device $keyIDNoPrefix to verify")
|
Timber.w("## SAS Verification: Could not find device $keyIDNoPrefix to verify")
|
||||||
|
@ -273,7 +272,7 @@ internal abstract class SASDefaultVerificationTransaction(
|
||||||
if (otherCrossSigningMasterKeyPublic != null) {
|
if (otherCrossSigningMasterKeyPublic != null) {
|
||||||
// Did the user signed his master key
|
// Did the user signed his master key
|
||||||
theirMacSafe.mac.keys.forEach {
|
theirMacSafe.mac.keys.forEach {
|
||||||
val keyIDNoPrefix = it.withoutPrefix("ed25519:")
|
val keyIDNoPrefix = it.removePrefix("ed25519:")
|
||||||
if (keyIDNoPrefix == otherCrossSigningMasterKeyPublic) {
|
if (keyIDNoPrefix == otherCrossSigningMasterKeyPublic) {
|
||||||
// Check the signature
|
// Check the signature
|
||||||
val mac = macUsingAgreedMethod(otherCrossSigningMasterKeyPublic, baseInfo + it)
|
val mac = macUsingAgreedMethod(otherCrossSigningMasterKeyPublic, baseInfo + it)
|
||||||
|
|
|
@ -50,8 +50,6 @@ fun convertFromUTF8(s: String): String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun String.withoutPrefix(prefix: String) = if (startsWith(prefix)) substringAfter(prefix) else this
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether a string contains an occurrence of another, as a standalone word, regardless of case.
|
* Returns whether a string contains an occurrence of another, as a standalone word, regardless of case.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue