diff --git a/app/src/main/java/me/capcom/smsgateway/modules/webhooks/workers/SendWebhookWorker.kt b/app/src/main/java/me/capcom/smsgateway/modules/webhooks/workers/SendWebhookWorker.kt index 7c386ca..e5f25f3 100644 --- a/app/src/main/java/me/capcom/smsgateway/modules/webhooks/workers/SendWebhookWorker.kt +++ b/app/src/main/java/me/capcom/smsgateway/modules/webhooks/workers/SendWebhookWorker.kt @@ -40,6 +40,10 @@ class SendWebhookWorker(appContext: Context, params: WorkerParameters) : override suspend fun doWork(): Result { try { + if (runAttemptCount >= MAX_RETRIES) { + return Result.failure() + } + val url = inputData.getString(INPUT_URL) ?: return Result.failure() val deviceId = inputData.getString(INPUT_DEVICE_ID) ?: return Result.failure() val event = inputData.getString(INPUT_EVENT)?.let { WebHookEvent.valueOf(it) } @@ -65,10 +69,7 @@ class SendWebhookWorker(appContext: Context, params: WorkerParameters) : return Result.failure() } catch (e: Throwable) { e.printStackTrace() - return when (runAttemptCount >= MAX_RETRIES) { - false -> Result.retry() - else -> Result.failure() - } + return Result.retry() } finally { client.close() }