From 47b06e45bbc0d9f397be7bd2613b1f50c8a8448d Mon Sep 17 00:00:00 2001 From: KjellBerlin Date: Fri, 9 Aug 2024 14:55:52 +0200 Subject: [PATCH 1/2] Fix slack payload --- .../core/delivery/SlackDeliveryWebhookController.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/carbonara/core/delivery/SlackDeliveryWebhookController.kt b/src/main/kotlin/com/carbonara/core/delivery/SlackDeliveryWebhookController.kt index f22c8b1..cc65141 100644 --- a/src/main/kotlin/com/carbonara/core/delivery/SlackDeliveryWebhookController.kt +++ b/src/main/kotlin/com/carbonara/core/delivery/SlackDeliveryWebhookController.kt @@ -13,10 +13,10 @@ class SlackDeliveryWebhookController( // Potential dos attack endpoint, introduce rate limiting - @PostMapping("/slack-delivery-status") - suspend fun handleSlackWebhook(@RequestParam("payload") payload: String) { + @PostMapping("/slack-delivery-status", "application/x-www-form-urlencoded") + suspend fun handleSlackWebhook(payload: SlackWebhookRequestBody) { log.info("--Start Slack--") - log.info(payload) + log.info(payload.payload) log.info("--End Slack--") } @@ -24,3 +24,7 @@ class SlackDeliveryWebhookController( private val log = KotlinLogging.logger {} } } + +data class SlackWebhookRequestBody( + val payload: String +) From 9b27ba8c3b5a11d2d33391a4886fc28ec0ca3256 Mon Sep 17 00:00:00 2001 From: KjellBerlin Date: Fri, 9 Aug 2024 14:56:05 +0200 Subject: [PATCH 2/2] Remove request param --- .../carbonara/core/delivery/SlackDeliveryWebhookController.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/kotlin/com/carbonara/core/delivery/SlackDeliveryWebhookController.kt b/src/main/kotlin/com/carbonara/core/delivery/SlackDeliveryWebhookController.kt index cc65141..d39d40b 100644 --- a/src/main/kotlin/com/carbonara/core/delivery/SlackDeliveryWebhookController.kt +++ b/src/main/kotlin/com/carbonara/core/delivery/SlackDeliveryWebhookController.kt @@ -3,7 +3,6 @@ package com.carbonara.core.delivery import com.carbonara.core.order.OrderService import mu.KotlinLogging import org.springframework.web.bind.annotation.PostMapping -import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.RestController @RestController