Make the PUSHER_APP_ID configurable at build time.

This commit is contained in:
Benoit Marty
2026-08-19 14:20:31 +02:00
parent 7341feeed8
commit 7adbd3941a
7 changed files with 40 additions and 26 deletions
@@ -1,16 +0,0 @@
/*
* Copyright (c) 2025 Element Creations Ltd.
* Copyright 2023-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.appconfig
object PushConfig {
/**
* Note: pusher_app_id cannot exceed 64 chars.
*/
const val PUSHER_APP_ID: String = "im.vector.app.android"
}
+29
View File
@@ -1,3 +1,5 @@
import config.BuildTimeConfig
import extension.buildConfigFieldStr
import extension.setupDependencyInjection
import extension.testCommonDependencies
@@ -17,6 +19,33 @@ plugins {
android {
namespace = "io.element.android.libraries.push.impl"
buildFeatures {
buildConfig = true
}
buildTypes {
val defaultPusherAppId = "im.vector.app.android"
getByName("release") {
buildConfigFieldStr(
name = "PUSHER_APP_ID",
value = BuildTimeConfig.PUSHER_APP_ID_RELEASE ?: defaultPusherAppId,
)
}
getByName("debug") {
buildConfigFieldStr(
name = "PUSHER_APP_ID",
value = BuildTimeConfig.PUSHER_APP_ID_DEBUG ?: defaultPusherAppId,
)
}
register("nightly") {
matchingFallbacks += listOf("release")
buildConfigFieldStr(
name = "PUSHER_APP_ID",
value = BuildTimeConfig.PUSHER_APP_ID_NIGHTLY ?: defaultPusherAppId,
)
}
}
testOptions {
unitTests {
isIncludeAndroidResources = true
@@ -10,7 +10,6 @@ package io.element.android.libraries.push.impl
import dev.zacsweers.metro.AppScope
import dev.zacsweers.metro.ContributesBinding
import io.element.android.appconfig.PushConfig
import io.element.android.libraries.core.extensions.mapFailure
import io.element.android.libraries.core.log.logger.LoggerTag
import io.element.android.libraries.core.meta.BuildMeta
@@ -74,7 +73,7 @@ class DefaultPusherSubscriber(
): SetHttpPusherData =
SetHttpPusherData(
pushKey = pushKey,
appId = PushConfig.PUSHER_APP_ID,
appId = BuildConfig.PUSHER_APP_ID,
// TODO + abs(activeSessionHolder.getActiveSession().myUserId.hashCode())
profileTag = DEFAULT_PUSHER_FILE_TAG + "_",
// TODO localeProvider.current().language
@@ -104,7 +103,7 @@ class DefaultPusherSubscriber(
.unsetHttpPusher(
unsetHttpPusherData = UnsetHttpPusherData(
pushKey = pushKey,
appId = PushConfig.PUSHER_APP_ID
appId = BuildConfig.PUSHER_APP_ID
)
)
.onSuccess {
@@ -10,9 +10,9 @@ package io.element.android.libraries.push.impl.test
import dev.zacsweers.metro.AppScope
import dev.zacsweers.metro.ContributesBinding
import io.element.android.appconfig.PushConfig
import io.element.android.libraries.matrix.api.core.EventId
import io.element.android.libraries.matrix.api.core.RoomId
import io.element.android.libraries.push.impl.BuildConfig
import io.element.android.libraries.push.impl.pushgateway.PushGatewayNotifyRequest
import io.element.android.libraries.pushproviders.api.Config
@@ -28,7 +28,7 @@ class DefaultTestPush(
pushGatewayNotifyRequest.execute(
PushGatewayNotifyRequest.Params(
url = config.url,
appId = PushConfig.PUSHER_APP_ID,
appId = BuildConfig.PUSHER_APP_ID,
pushKey = config.pushKey,
eventId = TEST_EVENT_ID,
roomId = TEST_ROOM_ID,
@@ -9,7 +9,6 @@
package io.element.android.libraries.push.impl
import com.google.common.truth.Truth.assertThat
import io.element.android.appconfig.PushConfig
import io.element.android.libraries.core.meta.BuildMeta
import io.element.android.libraries.matrix.api.pusher.SetHttpPusherData
import io.element.android.libraries.matrix.api.pusher.UnsetHttpPusherData
@@ -96,7 +95,7 @@ class DefaultPusherSubscriberTest {
value(
SetHttpPusherData(
pushKey = "aPushKey",
appId = PushConfig.PUSHER_APP_ID,
appId = BuildConfig.PUSHER_APP_ID,
url = "aGateway",
appDisplayName = "MyApp",
deviceDisplayName = "MyDevice",
@@ -163,7 +162,7 @@ class DefaultPusherSubscriberTest {
value(
UnsetHttpPusherData(
pushKey = "aPushKey",
appId = PushConfig.PUSHER_APP_ID,
appId = BuildConfig.PUSHER_APP_ID,
),
)
)
@@ -8,7 +8,7 @@
package io.element.android.libraries.push.impl.test
import io.element.android.appconfig.PushConfig
import io.element.android.libraries.push.impl.BuildConfig
import io.element.android.libraries.push.impl.pushgateway.PushGatewayNotifyRequest
import io.element.android.libraries.pushproviders.test.aSessionPushConfig
import io.element.android.tests.testutils.lambda.lambdaRecorder
@@ -33,7 +33,7 @@ class DefaultTestPushTest {
value(
PushGatewayNotifyRequest.Params(
url = aConfig.url,
appId = PushConfig.PUSHER_APP_ID,
appId = BuildConfig.PUSHER_APP_ID,
pushKey = aConfig.pushKey,
eventId = DefaultTestPush.TEST_EVENT_ID,
roomId = DefaultTestPush.TEST_ROOM_ID,
@@ -31,4 +31,7 @@ object BuildTimeConfig {
val BUG_REPORT_APP_NAME: String? = null
const val PUSH_CONFIG_INCLUDE_FIREBASE: Boolean = true
const val PUSH_CONFIG_INCLUDE_UNIFIED_PUSH: Boolean = true
val PUSHER_APP_ID_RELEASE: String? = null
val PUSHER_APP_ID_DEBUG: String? = null
val PUSHER_APP_ID_NIGHTLY: String? = null
}