Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,26 @@ android {
val appId: String? = System.getenv(datadogAppIdKey) ?: project.getLocalProperty(datadogAppIdKey, null)
buildConfigField("String", datadogAppIdKey, appId?.let { "\"$it\"" } ?: "null")

// DOMAIN_REMOVAL_KEYS_FOR_REPAIR json format {"domain": "some hex string key"}
// DOMAIN_REMOVAL_KEYS_FOR_REPAIR json format {"domain": ["some hex string key"]}
val domainRemovalKeysForRepair = "DOMAIN_REMOVAL_KEYS_FOR_REPAIR"
val domainKeysJson: String? =
System.getenv(domainRemovalKeysForRepair) ?: project.getLocalProperty(domainRemovalKeysForRepair, null)
val domainKeysJson: String? = System.getenv(domainRemovalKeysForRepair) ?: project.getLocalProperty(domainRemovalKeysForRepair, null)
val domainKeysHashMap = if (domainKeysJson != null) {
try {
val jsonMap = groovy.json.JsonSlurper().parseText(domainKeysJson) as Map<String, String>
val javaMapEntries = jsonMap.entries.joinToString("") { "put(\"${it.key}\", \"${it.value}\");" }
"new java.util.HashMap<String, String>(){{$javaMapEntries}}"
val jsonMap = groovy.json.JsonSlurper().parseText(domainKeysJson) as Map<String, List<String>>
val javaMapEntries = jsonMap.entries.joinToString("; ") { (domain, keys) ->
val keysList = keys.joinToString("\", \"", "\"", "\"")
"put(\"$domain\", java.util.Arrays.asList($keysList))"
}
"new java.util.HashMap<String, java.util.List<String>>(){{$javaMapEntries;}}"
} catch (e: Exception) {
println("Error parsing domain removal keys: ${e.message}")
"new java.util.HashMap<String, String>()"
"new java.util.HashMap<String, java.util.List<String>>()"
}
} else {
"new java.util.HashMap<String, String>()"
"new java.util.HashMap<String, java.util.List<String>>()"
}
buildConfigField(
"java.util.Map<String, String>",
"java.util.Map<String, java.util.List<String>>",
domainRemovalKeysForRepair,
domainKeysHashMap
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class KaliumConfigsModule {
maxRemoteSearchResultCount = BuildConfig.MAX_REMOTE_SEARCH_RESULT_COUNT,
limitTeamMembersFetchDuringSlowSync = BuildConfig.LIMIT_TEAM_MEMBERS_FETCH_DURING_SLOW_SYNC,
isMlsResetEnabled = BuildConfig.IS_MLS_RESET_ENABLED,
domainWithFaultyKeysMap = BuildConfig.DOMAIN_REMOVAL_KEYS_FOR_REPAIR
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
override fun repairFaultRemovalKeys() {
viewModelScope.launch {
state = state.copy(mlsInfoState = state.mlsInfoState.copy(isLoadingRepair = true))
val (domain, faultyKey) = DOMAIN_REMOVAL_KEYS_FOR_REPAIR.entries.firstOrNull()
val (domain, faultyKey) = DOMAIN_REMOVAL_KEYS_FOR_REPAIR.entries.firstOrNull { it.key == currentAccount.domain }
?: run {
appLogger.w("No faulty removal keys configured for repair")
_infoMessage.emit(UIText.DynamicString("No faulty removal keys configured for repair"))
Expand All @@ -264,16 +264,16 @@
val result = repairFaultyRemovalKeys(
param = TargetedRepairParam(
domain = domain,
faultyKey = faultyKey
faultyKeys = faultyKey

Check warning on line 267 in app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsViewModel.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsViewModel.kt#L267

Added line #L267 was not covered by tests
)
)
when (result) {
RepairResult.Error -> appLogger.e("Error occurred during repair of faulty removal keys")
RepairResult.NoConversationsToRepair -> appLogger.i("No conversations to repair")
RepairResult.RepairNotNeeded -> appLogger.i("Repair not needed")
is RepairResult.RepairPerformed -> {
_infoMessage.emit(UIText.DynamicString("Repair finalized"))
appLogger.i("Repair performed: $result")
_infoMessage.emit(UIText.DynamicString("Reset finalized"))
appLogger.i("Repair performed: ${result.toLogString()}")

Check warning on line 276 in app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsViewModel.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsViewModel.kt#L275-L276

Added lines #L275 - L276 were not covered by tests
}
}
state = state.copy(mlsInfoState = state.mlsInfoState.copy(isLoadingRepair = false))
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,7 @@ In group conversations, the group admin can overwrite this setting.</string>
<string name="label_client_device_id">Proteus ID</string>
<string name="label_key_packages_count">Key-packages count</string>
<string name="label_mls_client_id">MLS Client ID</string>
<string name="label_mls_repair_faulty_keys">Repair faulty removal keys</string>
<string name="label_mls_repair_faulty_keys" translatable="false">Initiate reset of affected MLS groups</string>
<string name="conversation_empty_list_description">Connect with others or create a new group to start collaborating!</string>
<string name="favorites_empty_list_description">Select your favorite conversations, and you’ll find them here</string>
<string name="group_empty_list_description">You are not part of any group conversation yet.\nStart a new conversation!</string>
Expand Down Expand Up @@ -1795,7 +1795,7 @@ In group conversations, the group admin can overwrite this setting.</string>
<string name="debug_settings_force_api_versioning_update" translatable="false">Force API versioning update</string>
<string name="debug_settings_break_session" translatable="false">⚠️ Break Session</string>
<string name="debug_settings_force_api_versioning_update_button_text" translatable="false">Update</string>
<string name="debug_settings_force_repair_faulty_keys" translatable="false">Repair</string>
<string name="debug_settings_force_repair_faulty_keys" translatable="false">Reset</string>
<string name="debug_settings_feature_flags" translatable="false">Feature Flags</string>

<!-- Personal to team migration screen-->
Expand Down