Loading app/src/main/java/io/heckel/ntfy/ui/MainActivity.kt +2 −1 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import io.heckel.ntfy.msg.DownloadType import io.heckel.ntfy.msg.NotificationDispatcher import io.heckel.ntfy.service.SubscriberService import io.heckel.ntfy.service.SubscriberServiceManager import io.heckel.ntfy.up.TOPIC_MURENA import io.heckel.ntfy.util.* import io.heckel.ntfy.work.DeleteWorker import io.heckel.ntfy.work.PollWorker Loading Loading @@ -203,7 +204,7 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc lifecycleScope.launch(Dispatchers.IO) { val subscriptions = repository.getSubscriptions() val defaultTopic = "murena_notification" val defaultTopic = TOPIC_MURENA val hasTestTopic = subscriptions.any { it.topic == defaultTopic } if (hasTestTopic) { return@launch Loading app/src/main/java/io/heckel/ntfy/up/BroadcastReceiver.kt +15 −5 Original line number Diff line number Diff line Loading @@ -69,12 +69,17 @@ class BroadcastReceiver : android.content.BroadcastReceiver() { // Add subscription val baseUrl = repository.getDefaultBaseUrl() ?: context.getString(R.string.app_base_url) var topic = UP_PREFIX + randomString(TOPIC_RANDOM_ID_LENGTH) if (appId == "foundation.e.unifiedpoc") { topic = "murena_notification" if (appId == PACKAGE_MURENA_UNIFIED_PUSH) { topic = TOPIC_MURENA } val endpoint = topicUrlUp(baseUrl, topic) val subscriptionId = appId.takeIf { it == PACKAGE_MURENA_UNIFIED_PUSH }?.run { repository.getSubscriptions() .find { it.baseUrl == baseUrl && it.topic == topic }?.id } ?: randomSubscriptionId() val subscription = Subscription( id = randomSubscriptionId(), id = subscriptionId, baseUrl = baseUrl, topic = topic, instant = true, // No Firebase, always instant! Loading @@ -92,10 +97,15 @@ class BroadcastReceiver : android.content.BroadcastReceiver() { newCount = 0, lastActive = Date().time/1000 ) Log.d(TAG, "Adding subscription with for app $appId (connectorToken $connectorToken): $subscription") try { // Note, this may fail due to a SQL constraint exception, see https://github.com/binwiederhier/ntfy/issues/185 if (appId == PACKAGE_MURENA_UNIFIED_PUSH) { Log.d(TAG, "Updating subscription with for app $appId (connectorToken $connectorToken): $subscription") repository.updateSubscription(subscription) } else { Log.d(TAG, "Adding subscription with for app $appId (connectorToken $connectorToken): $subscription") repository.addSubscription(subscription) } distributor.sendEndpoint(appId, connectorToken, endpoint) // Refresh (and maybe start) foreground service Loading app/src/main/java/io/heckel/ntfy/up/Constants.kt +3 −0 Original line number Diff line number Diff line Loading @@ -20,3 +20,6 @@ const val EXTRA_TOKEN = "token" const val EXTRA_ENDPOINT = "endpoint" const val EXTRA_MESSAGE = "message" const val EXTRA_BYTES_MESSAGE = "bytesMessage" const val PACKAGE_MURENA_UNIFIED_PUSH = "foundation.e.unifiedpoc" const val TOPIC_MURENA = "murena_notification" Loading
app/src/main/java/io/heckel/ntfy/ui/MainActivity.kt +2 −1 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import io.heckel.ntfy.msg.DownloadType import io.heckel.ntfy.msg.NotificationDispatcher import io.heckel.ntfy.service.SubscriberService import io.heckel.ntfy.service.SubscriberServiceManager import io.heckel.ntfy.up.TOPIC_MURENA import io.heckel.ntfy.util.* import io.heckel.ntfy.work.DeleteWorker import io.heckel.ntfy.work.PollWorker Loading Loading @@ -203,7 +204,7 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc lifecycleScope.launch(Dispatchers.IO) { val subscriptions = repository.getSubscriptions() val defaultTopic = "murena_notification" val defaultTopic = TOPIC_MURENA val hasTestTopic = subscriptions.any { it.topic == defaultTopic } if (hasTestTopic) { return@launch Loading
app/src/main/java/io/heckel/ntfy/up/BroadcastReceiver.kt +15 −5 Original line number Diff line number Diff line Loading @@ -69,12 +69,17 @@ class BroadcastReceiver : android.content.BroadcastReceiver() { // Add subscription val baseUrl = repository.getDefaultBaseUrl() ?: context.getString(R.string.app_base_url) var topic = UP_PREFIX + randomString(TOPIC_RANDOM_ID_LENGTH) if (appId == "foundation.e.unifiedpoc") { topic = "murena_notification" if (appId == PACKAGE_MURENA_UNIFIED_PUSH) { topic = TOPIC_MURENA } val endpoint = topicUrlUp(baseUrl, topic) val subscriptionId = appId.takeIf { it == PACKAGE_MURENA_UNIFIED_PUSH }?.run { repository.getSubscriptions() .find { it.baseUrl == baseUrl && it.topic == topic }?.id } ?: randomSubscriptionId() val subscription = Subscription( id = randomSubscriptionId(), id = subscriptionId, baseUrl = baseUrl, topic = topic, instant = true, // No Firebase, always instant! Loading @@ -92,10 +97,15 @@ class BroadcastReceiver : android.content.BroadcastReceiver() { newCount = 0, lastActive = Date().time/1000 ) Log.d(TAG, "Adding subscription with for app $appId (connectorToken $connectorToken): $subscription") try { // Note, this may fail due to a SQL constraint exception, see https://github.com/binwiederhier/ntfy/issues/185 if (appId == PACKAGE_MURENA_UNIFIED_PUSH) { Log.d(TAG, "Updating subscription with for app $appId (connectorToken $connectorToken): $subscription") repository.updateSubscription(subscription) } else { Log.d(TAG, "Adding subscription with for app $appId (connectorToken $connectorToken): $subscription") repository.addSubscription(subscription) } distributor.sendEndpoint(appId, connectorToken, endpoint) // Refresh (and maybe start) foreground service Loading
app/src/main/java/io/heckel/ntfy/up/Constants.kt +3 −0 Original line number Diff line number Diff line Loading @@ -20,3 +20,6 @@ const val EXTRA_TOKEN = "token" const val EXTRA_ENDPOINT = "endpoint" const val EXTRA_MESSAGE = "message" const val EXTRA_BYTES_MESSAGE = "bytesMessage" const val PACKAGE_MURENA_UNIFIED_PUSH = "foundation.e.unifiedpoc" const val TOPIC_MURENA = "murena_notification"