Loading app/src/main/java/io/heckel/ntfy/up/BroadcastReceiver.kt +13 −7 Original line number Diff line number Diff line Loading @@ -5,8 +5,8 @@ import android.content.Intent import io.heckel.ntfy.R import io.heckel.ntfy.app.Application import io.heckel.ntfy.db.Subscription import io.heckel.ntfy.util.Log import io.heckel.ntfy.service.SubscriberServiceManager import io.heckel.ntfy.util.Log import io.heckel.ntfy.util.randomString import io.heckel.ntfy.util.topicUrlUp import kotlinx.coroutines.Dispatchers Loading Loading @@ -40,7 +40,7 @@ class BroadcastReceiver : android.content.BroadcastReceiver() { Log.d(TAG, "REGISTER received for app $appId (connectorToken=$connectorToken)") if (appId.isBlank()) { Log.w(TAG, "Refusing registration: Empty application") distributor.sendRegistrationRefused(appId, connectorToken) distributor.sendRegistrationFailed(appId, connectorToken, "Empty application string") return } GlobalScope.launch(Dispatchers.IO) { Loading @@ -52,7 +52,7 @@ class BroadcastReceiver : android.content.BroadcastReceiver() { distributor.sendEndpoint(appId, connectorToken, endpoint) } else { Log.d(TAG, "Subscription with connectorToken $connectorToken exists for a different app. Refusing registration.") distributor.sendRegistrationRefused(appId, connectorToken) distributor.sendRegistrationFailed(appId, connectorToken, "Connector token already exists") } return@launch } Loading @@ -74,11 +74,17 @@ class BroadcastReceiver : android.content.BroadcastReceiver() { 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 repository.addSubscription(subscription) distributor.sendEndpoint(appId, connectorToken, endpoint) // Refresh (and maybe start) foreground service SubscriberServiceManager.refresh(app) } catch (e: Exception) { Log.w(TAG, "Failed to add subscription", e) distributor.sendRegistrationFailed(appId, connectorToken, e.message) } } } Loading app/src/main/java/io/heckel/ntfy/up/Constants.kt +1 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ package io.heckel.ntfy.up */ const val ACTION_NEW_ENDPOINT = "org.unifiedpush.android.connector.NEW_ENDPOINT" const val ACTION_REGISTRATION_REFUSED = "org.unifiedpush.android.connector.REGISTRATION_REFUSED" const val ACTION_REGISTRATION_FAILED = "org.unifiedpush.android.connector.REGISTRATION_FAILED" const val ACTION_UNREGISTERED = "org.unifiedpush.android.connector.UNREGISTERED" const val ACTION_MESSAGE = "org.unifiedpush.android.connector.MESSAGE" Loading app/src/main/java/io/heckel/ntfy/up/Distributor.kt +6 −3 Original line number Diff line number Diff line Loading @@ -39,12 +39,15 @@ class Distributor(val context: Context) { context.sendBroadcast(broadcastIntent) } fun sendRegistrationRefused(app: String, connectorToken: String) { Log.d(TAG, "Sending REGISTRATION_REFUSED to $app (token=$connectorToken)") fun sendRegistrationFailed(app: String, connectorToken: String, message: String?) { Log.d(TAG, "Sending REGISTRATION_FAILED to $app (token=$connectorToken)") val broadcastIntent = Intent() broadcastIntent.`package` = app broadcastIntent.action = ACTION_REGISTRATION_REFUSED broadcastIntent.action = ACTION_REGISTRATION_FAILED broadcastIntent.putExtra(EXTRA_TOKEN, connectorToken) if (message != null) { broadcastIntent.putExtra(EXTRA_MESSAGE, message) } context.sendBroadcast(broadcastIntent) } Loading fastlane/metadata/android/en-US/changelog/25.txt +1 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ Features: Bugs: * IllegalStateException: Failed to build unique file (#177, thanks to @Fallenbagel for reporting) * SQLiteConstraintException: Crash during UP registration (#185) Thanks: * Many thanks to @cmeis, @Fallenbagel, @J117 and @rogeliodh for input on the new attachment logic, and for Loading Loading
app/src/main/java/io/heckel/ntfy/up/BroadcastReceiver.kt +13 −7 Original line number Diff line number Diff line Loading @@ -5,8 +5,8 @@ import android.content.Intent import io.heckel.ntfy.R import io.heckel.ntfy.app.Application import io.heckel.ntfy.db.Subscription import io.heckel.ntfy.util.Log import io.heckel.ntfy.service.SubscriberServiceManager import io.heckel.ntfy.util.Log import io.heckel.ntfy.util.randomString import io.heckel.ntfy.util.topicUrlUp import kotlinx.coroutines.Dispatchers Loading Loading @@ -40,7 +40,7 @@ class BroadcastReceiver : android.content.BroadcastReceiver() { Log.d(TAG, "REGISTER received for app $appId (connectorToken=$connectorToken)") if (appId.isBlank()) { Log.w(TAG, "Refusing registration: Empty application") distributor.sendRegistrationRefused(appId, connectorToken) distributor.sendRegistrationFailed(appId, connectorToken, "Empty application string") return } GlobalScope.launch(Dispatchers.IO) { Loading @@ -52,7 +52,7 @@ class BroadcastReceiver : android.content.BroadcastReceiver() { distributor.sendEndpoint(appId, connectorToken, endpoint) } else { Log.d(TAG, "Subscription with connectorToken $connectorToken exists for a different app. Refusing registration.") distributor.sendRegistrationRefused(appId, connectorToken) distributor.sendRegistrationFailed(appId, connectorToken, "Connector token already exists") } return@launch } Loading @@ -74,11 +74,17 @@ class BroadcastReceiver : android.content.BroadcastReceiver() { 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 repository.addSubscription(subscription) distributor.sendEndpoint(appId, connectorToken, endpoint) // Refresh (and maybe start) foreground service SubscriberServiceManager.refresh(app) } catch (e: Exception) { Log.w(TAG, "Failed to add subscription", e) distributor.sendRegistrationFailed(appId, connectorToken, e.message) } } } Loading
app/src/main/java/io/heckel/ntfy/up/Constants.kt +1 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ package io.heckel.ntfy.up */ const val ACTION_NEW_ENDPOINT = "org.unifiedpush.android.connector.NEW_ENDPOINT" const val ACTION_REGISTRATION_REFUSED = "org.unifiedpush.android.connector.REGISTRATION_REFUSED" const val ACTION_REGISTRATION_FAILED = "org.unifiedpush.android.connector.REGISTRATION_FAILED" const val ACTION_UNREGISTERED = "org.unifiedpush.android.connector.UNREGISTERED" const val ACTION_MESSAGE = "org.unifiedpush.android.connector.MESSAGE" Loading
app/src/main/java/io/heckel/ntfy/up/Distributor.kt +6 −3 Original line number Diff line number Diff line Loading @@ -39,12 +39,15 @@ class Distributor(val context: Context) { context.sendBroadcast(broadcastIntent) } fun sendRegistrationRefused(app: String, connectorToken: String) { Log.d(TAG, "Sending REGISTRATION_REFUSED to $app (token=$connectorToken)") fun sendRegistrationFailed(app: String, connectorToken: String, message: String?) { Log.d(TAG, "Sending REGISTRATION_FAILED to $app (token=$connectorToken)") val broadcastIntent = Intent() broadcastIntent.`package` = app broadcastIntent.action = ACTION_REGISTRATION_REFUSED broadcastIntent.action = ACTION_REGISTRATION_FAILED broadcastIntent.putExtra(EXTRA_TOKEN, connectorToken) if (message != null) { broadcastIntent.putExtra(EXTRA_MESSAGE, message) } context.sendBroadcast(broadcastIntent) } Loading
fastlane/metadata/android/en-US/changelog/25.txt +1 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ Features: Bugs: * IllegalStateException: Failed to build unique file (#177, thanks to @Fallenbagel for reporting) * SQLiteConstraintException: Crash during UP registration (#185) Thanks: * Many thanks to @cmeis, @Fallenbagel, @J117 and @rogeliodh for input on the new attachment logic, and for Loading