ok everything works now

This commit is contained in:
Karmanyaah Malhotra 2023-12-16 23:06:43 -06:00
parent 235f354089
commit c7d0fb1ad7
2 changed files with 4 additions and 5 deletions

View file

@ -257,10 +257,9 @@ class SubscriberService : Service() {
GlobalScope.launch(Dispatchers.IO) { GlobalScope.launch(Dispatchers.IO) {
for (topic in connectionId.topicsToSubscriptionIds.keys) { for (topic in connectionId.topicsToSubscriptionIds.keys) {
if (connectionId.topicIsUnifiedPush[topic] == true) { if (connectionId.topicIsUnifiedPush[topic] == true) {
io.heckel.ntfy.up.BroadcastReceiver.sendRegistration(baseContext, connectionId.baseUrl, topic)
// TODO is that the right context
// looks like it works???
Log.d(TAG, "Attempting to re-register ${connectionId.baseUrl}/$topic") Log.d(TAG, "Attempting to re-register ${connectionId.baseUrl}/$topic")
io.heckel.ntfy.up.BroadcastReceiver.sendRegistration(baseContext, connectionId.baseUrl, topic)
// TODO is that the right context - looks like it works???
} }
} }
} }

View file

@ -97,7 +97,8 @@ class BroadcastReceiver : android.content.BroadcastReceiver() {
registering with the push server. This avoids a race condition where the application server registering with the push server. This avoids a race condition where the application server
is rejected before ntfy even establishes that this topic exists. is rejected before ntfy even establishes that this topic exists.
This is fine from an application perspective, because other distributors can't even register This is fine from an application perspective, because other distributors can't even register
without a connection to the push server. */ without a connection to the push server.
Unless the app sends registration twice. Then it'll get the endpoint.*/
//Refresh (and maybe start) foreground service //Refresh (and maybe start) foreground service
SubscriberServiceManager.refresh(app) SubscriberServiceManager.refresh(app)
@ -164,7 +165,6 @@ class BroadcastReceiver : android.content.BroadcastReceiver() {
val appId = existingSubscription.upAppId ?: return@launch val appId = existingSubscription.upAppId ?: return@launch
val connectorToken = existingSubscription.upConnectorToken ?: return@launch val connectorToken = existingSubscription.upConnectorToken ?: return@launch
val endpoint = topicUrlUp(existingSubscription.baseUrl, existingSubscription.topic) val endpoint = topicUrlUp(existingSubscription.baseUrl, existingSubscription.topic)
Log.d(TAG, "Sending endpoint $endpoint to ${existingSubscription.upAppId}")
distributor.sendEndpoint(appId, connectorToken, endpoint) distributor.sendEndpoint(appId, connectorToken, endpoint)
} }
} }