Loading notificationsreceiver-domain/src/main/java/foundation/e/notificationsreceiver/domain/bridges/androidinterfaces/DeviceConfiguration.kt +1 −0 Original line number Diff line number Diff line Loading @@ -22,5 +22,6 @@ interface DeviceConfiguration { val device: String val androidVersion: String suspend fun getLang(): String suspend fun isConnectedToMurenaIO(): Boolean suspend fun getMurenaWorkspaceGroups(): List<String> } notificationsreceiver-domain/src/main/java/foundation/e/notificationsreceiver/domain/procedures/RegisterToEosNotifications.kt +5 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ class RegisterToEosNotifications @Inject constructor( companion object { const val EOS_BROADCAST_TOPIC_PREFIX = "eOS" private const val ALL_DEVICES_TOPIC_BASE = "all" private const val MURENA_IO_TOPIC_BASE = "Murena_io" private const val DEFAULT_LANG = "en" private val SUPPORTED_LANGUAGES = setOf("de", "en", "es", "fr", "it") } Loading Loading @@ -79,6 +80,10 @@ class RegisterToEosNotifications @Inject constructor( .takeIf { it in SUPPORTED_LANGUAGES } ?: DEFAULT_LANG, ) if (deviceConfiguration.isConnectedToMurenaIO()) { topics.add(MURENA_IO_TOPIC_BASE) } deviceConfiguration.getMurenaWorkspaceGroups().forEach { topics.add(it) } Loading notificationsreceiver-domain/src/test/java/foundation/e/notificationsreceiver/domain/procedures/RegisterToEOSBroadcastProcedureTest.kt +28 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ class RegisterToEOSBroadcastProcedureTest { every { deviceConfiguration.androidVersion } returns "13" every { deviceConfiguration.device } returns "FP3" coEvery { deviceConfiguration.getMurenaWorkspaceGroups() } returns emptyList() coEvery { deviceConfiguration.isConnectedToMurenaIO() } returns false coEvery { deviceConfiguration.getLang() } returns "en" Loading Loading @@ -213,6 +214,33 @@ class RegisterToEOSBroadcastProcedureTest { } } @Test fun register_should_collect_murena_io() = runTest(testScheduler) { coEvery { subscriptionRepository.getSubscriptions() } returns emptyList() coEvery { deviceConfiguration.isConnectedToMurenaIO() } returns true // When useCase.updateRegistration() // Then listOf( "eOS-all-en", "eOS-FP3-en", "eOS-2_9-en", "eOS-FP3-2_9-en", "eOS-Murena_io-en", ).forEach { topic -> coVerify { subscriptionRepository.createSubscription( withArg<Topic> { assertEquals(baseUrlFixture, it.baseUrl) assertEquals(topic, it.topic) }, ) } } } @Test fun register_should_collect_workspace_groups() = runTest(testScheduler) { coEvery { subscriptionRepository.getSubscriptions() } returns emptyList() Loading notificationsreceiver/src/main/java/foundation/e/notificationsreceiver/bridges/androidinterfaces/DeviceConfigurationImpl.kt +22 −2 Original line number Diff line number Diff line Loading @@ -22,8 +22,11 @@ import android.content.Context import android.os.Build import dagger.hilt.android.qualifiers.ApplicationContext import foundation.e.notificationsreceiver.domain.bridges.androidinterfaces.DeviceConfiguration import foundation.e.notificationsreceiver.domain.utils.e import foundation.e.notificationsreceiver.domain.utils.w import foundation.e.userinfoservice.lib.UserInfoProvider import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import javax.inject.Inject import javax.inject.Singleton Loading @@ -40,8 +43,25 @@ class DeviceConfigurationImpl @Inject constructor( return runCatching { appContext.resources.configuration.locales.get(0).language }.getOrNull() ?: "en" } override suspend fun getMurenaWorkspaceGroups(): List<String> { return UserInfoProvider.fetch(appContext).groups override suspend fun isConnectedToMurenaIO(): Boolean = withContext(Dispatchers.IO) { try { UserInfoProvider.fetch(appContext).let { it.id.isNotBlank() || it.email.isNotBlank() } } catch(e: IllegalStateException) { e("Can't fetch UserInfo", e) false } } override suspend fun getMurenaWorkspaceGroups(): List<String> = withContext(Dispatchers.IO) { try { UserInfoProvider.fetch(appContext).groups } catch(e: IllegalStateException) { e("Can't fetch UserInfo", e) emptyList() } } private fun getVersionThroughReflection(): String? { Loading Loading
notificationsreceiver-domain/src/main/java/foundation/e/notificationsreceiver/domain/bridges/androidinterfaces/DeviceConfiguration.kt +1 −0 Original line number Diff line number Diff line Loading @@ -22,5 +22,6 @@ interface DeviceConfiguration { val device: String val androidVersion: String suspend fun getLang(): String suspend fun isConnectedToMurenaIO(): Boolean suspend fun getMurenaWorkspaceGroups(): List<String> }
notificationsreceiver-domain/src/main/java/foundation/e/notificationsreceiver/domain/procedures/RegisterToEosNotifications.kt +5 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ class RegisterToEosNotifications @Inject constructor( companion object { const val EOS_BROADCAST_TOPIC_PREFIX = "eOS" private const val ALL_DEVICES_TOPIC_BASE = "all" private const val MURENA_IO_TOPIC_BASE = "Murena_io" private const val DEFAULT_LANG = "en" private val SUPPORTED_LANGUAGES = setOf("de", "en", "es", "fr", "it") } Loading Loading @@ -79,6 +80,10 @@ class RegisterToEosNotifications @Inject constructor( .takeIf { it in SUPPORTED_LANGUAGES } ?: DEFAULT_LANG, ) if (deviceConfiguration.isConnectedToMurenaIO()) { topics.add(MURENA_IO_TOPIC_BASE) } deviceConfiguration.getMurenaWorkspaceGroups().forEach { topics.add(it) } Loading
notificationsreceiver-domain/src/test/java/foundation/e/notificationsreceiver/domain/procedures/RegisterToEOSBroadcastProcedureTest.kt +28 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ class RegisterToEOSBroadcastProcedureTest { every { deviceConfiguration.androidVersion } returns "13" every { deviceConfiguration.device } returns "FP3" coEvery { deviceConfiguration.getMurenaWorkspaceGroups() } returns emptyList() coEvery { deviceConfiguration.isConnectedToMurenaIO() } returns false coEvery { deviceConfiguration.getLang() } returns "en" Loading Loading @@ -213,6 +214,33 @@ class RegisterToEOSBroadcastProcedureTest { } } @Test fun register_should_collect_murena_io() = runTest(testScheduler) { coEvery { subscriptionRepository.getSubscriptions() } returns emptyList() coEvery { deviceConfiguration.isConnectedToMurenaIO() } returns true // When useCase.updateRegistration() // Then listOf( "eOS-all-en", "eOS-FP3-en", "eOS-2_9-en", "eOS-FP3-2_9-en", "eOS-Murena_io-en", ).forEach { topic -> coVerify { subscriptionRepository.createSubscription( withArg<Topic> { assertEquals(baseUrlFixture, it.baseUrl) assertEquals(topic, it.topic) }, ) } } } @Test fun register_should_collect_workspace_groups() = runTest(testScheduler) { coEvery { subscriptionRepository.getSubscriptions() } returns emptyList() Loading
notificationsreceiver/src/main/java/foundation/e/notificationsreceiver/bridges/androidinterfaces/DeviceConfigurationImpl.kt +22 −2 Original line number Diff line number Diff line Loading @@ -22,8 +22,11 @@ import android.content.Context import android.os.Build import dagger.hilt.android.qualifiers.ApplicationContext import foundation.e.notificationsreceiver.domain.bridges.androidinterfaces.DeviceConfiguration import foundation.e.notificationsreceiver.domain.utils.e import foundation.e.notificationsreceiver.domain.utils.w import foundation.e.userinfoservice.lib.UserInfoProvider import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import javax.inject.Inject import javax.inject.Singleton Loading @@ -40,8 +43,25 @@ class DeviceConfigurationImpl @Inject constructor( return runCatching { appContext.resources.configuration.locales.get(0).language }.getOrNull() ?: "en" } override suspend fun getMurenaWorkspaceGroups(): List<String> { return UserInfoProvider.fetch(appContext).groups override suspend fun isConnectedToMurenaIO(): Boolean = withContext(Dispatchers.IO) { try { UserInfoProvider.fetch(appContext).let { it.id.isNotBlank() || it.email.isNotBlank() } } catch(e: IllegalStateException) { e("Can't fetch UserInfo", e) false } } override suspend fun getMurenaWorkspaceGroups(): List<String> = withContext(Dispatchers.IO) { try { UserInfoProvider.fetch(appContext).groups } catch(e: IllegalStateException) { e("Can't fetch UserInfo", e) emptyList() } } private fun getVersionThroughReflection(): String? { Loading