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 (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/slack-go/slack"
|
||||
@ -13,8 +14,11 @@ import (
|
||||
)
|
||||
|
||||
func HandleSlackPayloadPost(c *fiber.Ctx) error {
|
||||
body := string(c.Body())
|
||||
body = strings.ReplaceAll(body, "\n", "\\n")
|
||||
|
||||
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)
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user