fix: resolve review issues for Slack target type
All checks were successful
check / check (push) Successful in 1m53s
All checks were successful
check / check (push) Successful in 1m53s
- Fix duplicate name="url" form fields by adding :disabled binding to each URL input so only the active target type's field submits - Fix message formatting to use Slack mrkdwn (*bold*) instead of Markdown (**bold**) and remove language hint from code blocks - Fix README line exceeding 80-column hard wrap
This commit is contained in:
@@ -1080,11 +1080,11 @@ func (e *Engine) parseSlackConfig(configJSON string) (*SlackTargetConfig, error)
|
||||
func FormatSlackMessage(event *database.Event) string {
|
||||
var b strings.Builder
|
||||
|
||||
b.WriteString("**Webhook Event Received**\n")
|
||||
b.WriteString(fmt.Sprintf("**Method:** `%s`\n", event.Method))
|
||||
b.WriteString(fmt.Sprintf("**Content-Type:** `%s`\n", event.ContentType))
|
||||
b.WriteString(fmt.Sprintf("**Timestamp:** `%s`\n", event.CreatedAt.UTC().Format(time.RFC3339)))
|
||||
b.WriteString(fmt.Sprintf("**Body Size:** %d bytes\n", len(event.Body)))
|
||||
b.WriteString("*Webhook Event Received*\n")
|
||||
b.WriteString(fmt.Sprintf("*Method:* `%s`\n", event.Method))
|
||||
b.WriteString(fmt.Sprintf("*Content-Type:* `%s`\n", event.ContentType))
|
||||
b.WriteString(fmt.Sprintf("*Timestamp:* `%s`\n", event.CreatedAt.UTC().Format(time.RFC3339)))
|
||||
b.WriteString(fmt.Sprintf("*Body Size:* %d bytes\n", len(event.Body)))
|
||||
|
||||
if event.Body == "" {
|
||||
b.WriteString("\n_(empty body)_\n")
|
||||
@@ -1096,7 +1096,7 @@ func FormatSlackMessage(event *database.Event) string {
|
||||
if json.Unmarshal([]byte(event.Body), &parsed) == nil {
|
||||
var pretty bytes.Buffer
|
||||
if json.Indent(&pretty, parsed, "", " ") == nil {
|
||||
b.WriteString("\n```json\n")
|
||||
b.WriteString("\n```\n")
|
||||
prettyStr := pretty.String()
|
||||
// Truncate very large payloads to keep Slack messages reasonable
|
||||
const maxPayloadDisplay = 3500
|
||||
|
||||
Reference in New Issue
Block a user