Fix deleteApp loop

This commit is contained in:
sim 2023-02-24 16:41:14 +01:00
parent 342f701afd
commit 857444415e
2 changed files with 7 additions and 5 deletions

View File

@ -139,9 +139,11 @@ object Distributor {
}
}
fun deleteAppFromAppToken(context: Context, appToken: String) {
getDb(context).getConnectorToken(appToken)?.let {
deleteApp(context, it) {}
fun deleteAppFromSSE(context: Context, appToken: String) {
val db = getDb(context)
db.getConnectorToken(appToken)?.let { connectorToken ->
sendUnregistered(context, connectorToken)
db.unregisterApp(connectorToken)
}
}
}

View File

@ -8,7 +8,7 @@ import okhttp3.Response
import okhttp3.sse.EventSource
import okhttp3.sse.EventSourceListener
import org.unifiedpush.distributor.nextpush.api.response.SSEResponse
import org.unifiedpush.distributor.nextpush.distributor.Distributor.deleteAppFromAppToken
import org.unifiedpush.distributor.nextpush.distributor.Distributor.deleteAppFromSSE
import org.unifiedpush.distributor.nextpush.distributor.Distributor.sendMessage
import org.unifiedpush.distributor.nextpush.utils.TAG
import java.lang.Exception
@ -56,7 +56,7 @@ class SSEListener(val context: Context) : EventSourceListener() {
}
"deleteApp" -> {
val message = Gson().fromJson(data, SSEResponse::class.java)
deleteAppFromAppToken(context, message.token)
deleteAppFromSSE(context, message.token)
}
}
StartService.wakeLock?.let {