You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
946 B
27 lines
946 B
package notify |
|
|
|
// Block is a single Slack Block Kit element (rendered to JSON for chat.postMessage). |
|
type Block = map[string]any |
|
|
|
// Notification is one DM to deliver: who (Email / Login for mapping) gets what. |
|
type Notification struct { |
|
Email string // best-known recipient email (from Gitea/Notion) |
|
Login string // source username/login, used as a secondary mapping key |
|
Text string // plain-text fallback (notifications, accessibility) |
|
Blocks []Block |
|
} |
|
|
|
// SimpleBlocks builds a message: bold title, body section, optional context line. |
|
func SimpleBlocks(title, body, context string) []Block { |
|
blocks := []Block{ |
|
{"type": "section", "text": Block{"type": "mrkdwn", "text": "*" + title + "*"}}, |
|
{"type": "section", "text": Block{"type": "mrkdwn", "text": body}}, |
|
} |
|
if context != "" { |
|
blocks = append(blocks, Block{ |
|
"type": "context", |
|
"elements": []Block{{"type": "mrkdwn", "text": context}}, |
|
}) |
|
} |
|
return blocks |
|
}
|
|
|