Strip newlines from Slack payload
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
parent
801574a245
commit
1d26f341c7
6
slack.go
6
slack.go
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/slack-go/slack"
|
"github.com/slack-go/slack"
|
||||||
@ -13,8 +14,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func HandleSlackPayloadPost(c *fiber.Ctx) error {
|
func HandleSlackPayloadPost(c *fiber.Ctx) error {
|
||||||
|
body := string(c.Body())
|
||||||
|
body = strings.ReplaceAll(body, "\n", "\\n")
|
||||||
|
|
||||||
payload := slack.WebhookMessage{}
|
payload := slack.WebhookMessage{}
|
||||||
if err := c.BodyParser(&payload); err != nil {
|
if err := json.Unmarshal([]byte(body), &payload); err != nil {
|
||||||
fmt.Println("Failed to parse payload", string(c.Body()), err)
|
fmt.Println("Failed to parse payload", string(c.Body()), err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user