diff --git a/app/src/main/java/org/unifiedpush/distributor/nextpush/distributor/Distributor.kt b/app/src/main/java/org/unifiedpush/distributor/nextpush/distributor/Distributor.kt index d3e7618..165baad 100644 --- a/app/src/main/java/org/unifiedpush/distributor/nextpush/distributor/Distributor.kt +++ b/app/src/main/java/org/unifiedpush/distributor/nextpush/distributor/Distributor.kt @@ -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) } } } diff --git a/app/src/main/java/org/unifiedpush/distributor/nextpush/services/SSEListener.kt b/app/src/main/java/org/unifiedpush/distributor/nextpush/services/SSEListener.kt index 73731af..1b59160 100644 --- a/app/src/main/java/org/unifiedpush/distributor/nextpush/services/SSEListener.kt +++ b/app/src/main/java/org/unifiedpush/distributor/nextpush/services/SSEListener.kt @@ -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 {