Merge branch 'develop' into feature/fga/join_space

This commit is contained in:
Benoit Marty 2025-09-24 11:20:17 +02:00 committed by GitHub
commit f3f19ec476
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
319 changed files with 2828 additions and 1838 deletions

View file

@ -44,7 +44,7 @@ class CurrentPushProviderTest(
} else {
delegate.updateState(
description = stringProvider.getString(R.string.troubleshoot_notifications_test_current_push_provider_failure),
status = NotificationTroubleshootTestState.Status.Failure(false)
status = NotificationTroubleshootTestState.Status.Failure()
)
}
}

View file

@ -0,0 +1,69 @@
/*
* Copyright 2025 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
* Please see LICENSE files in the repository root for full details.
*/
package io.element.android.libraries.push.impl.troubleshoot
import dev.zacsweers.metro.ContributesIntoSet
import dev.zacsweers.metro.Inject
import io.element.android.libraries.di.SessionScope
import io.element.android.libraries.matrix.api.MatrixClient
import io.element.android.libraries.push.impl.R
import io.element.android.libraries.troubleshoot.api.test.NotificationTroubleshootNavigator
import io.element.android.libraries.troubleshoot.api.test.NotificationTroubleshootTest
import io.element.android.libraries.troubleshoot.api.test.NotificationTroubleshootTestDelegate
import io.element.android.libraries.troubleshoot.api.test.NotificationTroubleshootTestState
import io.element.android.services.toolbox.api.strings.StringProvider
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.StateFlow
@ContributesIntoSet(SessionScope::class)
@Inject
class IgnoredUsersTest(
private val matrixClient: MatrixClient,
private val stringProvider: StringProvider,
) : NotificationTroubleshootTest {
override val order = 80
private val delegate = NotificationTroubleshootTestDelegate(
defaultName = stringProvider.getString(R.string.troubleshoot_notifications_test_blocked_users_title),
defaultDescription = stringProvider.getString(R.string.troubleshoot_notifications_test_blocked_users_description),
fakeDelay = NotificationTroubleshootTestDelegate.SHORT_DELAY,
)
override val state: StateFlow<NotificationTroubleshootTestState> = delegate.state
override suspend fun run(coroutineScope: CoroutineScope) {
delegate.start()
val ignorerUsers = matrixClient.ignoredUsersFlow.value
if (ignorerUsers.isEmpty()) {
delegate.updateState(
description = stringProvider.getString(R.string.troubleshoot_notifications_test_blocked_users_result_none),
status = NotificationTroubleshootTestState.Status.Success,
)
} else {
delegate.updateState(
description = stringProvider.getQuantityString(
R.plurals.troubleshoot_notifications_test_blocked_users_result_some,
ignorerUsers.size,
ignorerUsers.size
),
status = NotificationTroubleshootTestState.Status.Failure(
hasQuickFix = true,
isCritical = false,
quickFixButtonString = stringProvider.getString(R.string.troubleshoot_notifications_test_blocked_users_quick_fix),
),
)
}
}
override suspend fun quickFix(
coroutineScope: CoroutineScope,
navigator: NotificationTroubleshootNavigator,
) {
navigator.openIgnoredUsers()
}
override suspend fun reset() = delegate.reset()
}

View file

@ -54,7 +54,7 @@ class NotificationTest(
} else {
delegate.updateState(
description = stringProvider.getString(R.string.troubleshoot_notifications_test_display_notification_permission_failure),
status = NotificationTroubleshootTestState.Status.Failure(false)
status = NotificationTroubleshootTestState.Status.Failure()
)
}
}
@ -81,7 +81,7 @@ class NotificationTest(
notificationDisplayer.dismissDiagnosticNotification()
delegate.updateState(
description = stringProvider.getString(R.string.troubleshoot_notifications_test_display_notification_failure),
status = NotificationTroubleshootTestState.Status.Failure(false)
status = NotificationTroubleshootTestState.Status.Failure()
)
}
)

View file

@ -13,6 +13,7 @@ import dev.zacsweers.metro.Inject
import io.element.android.libraries.push.api.PushService
import io.element.android.libraries.push.api.gateway.PushGatewayFailure
import io.element.android.libraries.push.impl.R
import io.element.android.libraries.troubleshoot.api.test.NotificationTroubleshootNavigator
import io.element.android.libraries.troubleshoot.api.test.NotificationTroubleshootTest
import io.element.android.libraries.troubleshoot.api.test.NotificationTroubleshootTestDelegate
import io.element.android.libraries.troubleshoot.api.test.NotificationTroubleshootTestState
@ -56,7 +57,7 @@ class PushLoopbackTest(
val hasQuickFix = pushService.getCurrentPushProvider()?.canRotateToken() == true
delegate.updateState(
description = stringProvider.getString(R.string.troubleshoot_notifications_test_push_loop_back_failure_1),
status = NotificationTroubleshootTestState.Status.Failure(hasQuickFix)
status = NotificationTroubleshootTestState.Status.Failure(hasQuickFix = hasQuickFix)
)
job.cancel()
return
@ -64,7 +65,7 @@ class PushLoopbackTest(
Timber.e(e, "Failed to test push")
delegate.updateState(
description = stringProvider.getString(R.string.troubleshoot_notifications_test_push_loop_back_failure_2, e.message),
status = NotificationTroubleshootTestState.Status.Failure(false)
status = NotificationTroubleshootTestState.Status.Failure()
)
job.cancel()
return
@ -72,7 +73,7 @@ class PushLoopbackTest(
if (!testPushResult) {
delegate.updateState(
description = stringProvider.getString(R.string.troubleshoot_notifications_test_push_loop_back_failure_3),
status = NotificationTroubleshootTestState.Status.Failure(false)
status = NotificationTroubleshootTestState.Status.Failure()
)
job.cancel()
return
@ -93,13 +94,16 @@ class PushLoopbackTest(
job.cancel()
delegate.updateState(
description = stringProvider.getString(R.string.troubleshoot_notifications_test_push_loop_back_failure_4),
status = NotificationTroubleshootTestState.Status.Failure(false)
status = NotificationTroubleshootTestState.Status.Failure()
)
}
)
}
override suspend fun quickFix(coroutineScope: CoroutineScope) {
override suspend fun quickFix(
coroutineScope: CoroutineScope,
navigator: NotificationTroubleshootNavigator,
) {
delegate.start()
pushService.getCurrentPushProvider()?.rotateToken()
run(coroutineScope)

View file

@ -48,7 +48,7 @@ class PushProvidersTest(
} else {
delegate.updateState(
description = stringProvider.getString(R.string.troubleshoot_notifications_test_detect_push_provider_failure),
status = NotificationTroubleshootTestState.Status.Failure(false)
status = NotificationTroubleshootTestState.Status.Failure()
)
}
}

View file

@ -54,6 +54,14 @@
<string name="push_distributor_background_sync_android">"Background synchronization"</string>
<string name="push_distributor_firebase_android">"Google Services"</string>
<string name="push_no_valid_google_play_services_apk_android">"No valid Google Play Services found. Notifications may not work properly."</string>
<string name="troubleshoot_notifications_test_blocked_users_description">"Checking blocked users"</string>
<string name="troubleshoot_notifications_test_blocked_users_quick_fix">"View blocked users"</string>
<string name="troubleshoot_notifications_test_blocked_users_result_none">"No users are blocked."</string>
<plurals name="troubleshoot_notifications_test_blocked_users_result_some">
<item quantity="one">"You blocked %1$d user. You will not receive notifications for this user."</item>
<item quantity="other">"You blocked %1$d users. You will not receive notifications for these users."</item>
</plurals>
<string name="troubleshoot_notifications_test_blocked_users_title">"Blocked users"</string>
<string name="troubleshoot_notifications_test_current_push_provider_description">"Get the name of the current provider."</string>
<string name="troubleshoot_notifications_test_current_push_provider_failure">"No push providers selected."</string>
<string name="troubleshoot_notifications_test_current_push_provider_success">"Current push provider: %1$s."</string>