Commit a9a3e7e
committed
feat(webhooks): templated body, custom headers/method, now_playing event, verified presets
Webhooks now carry a stable ID, optional Name, HTTP method, ContentType,
custom Headers map, and a Go text/template BodyTemplate. Empty template
preserves the legacy JSON envelope so existing receivers keep working.
- WebhookConfig grows ID/Name/Method/Headers/BodyTemplate/ContentType.
Legacy entries get an ID backfilled at load time.
- dispatchWebhook renders the template against a context that merges
event metadata (.Event/.Timestamp/.Hostname) with the per-event
payload promoted to top-level fields (.Artist, .Title, .Mount, ...).
Header values are templated too. For GET/HEAD the rendered body is
appended as a query string so endpoints like TuneIn AIR's
Playing.ashx work from a single template.
- Helper funcs exposed inside templates: urlencode, json, lower, upper.
- New now_playing event, fired from the streamer on each track start
via a new StreamerManager.OnTrackStart callback (avoids server↔relay
cyclic import).
- /api/webhooks: GET/POST/PUT/DELETE CRUD + /api/webhooks/test for
firing a sample payload + /api/webhooks/meta exposing the canonical
event list, sample payloads, placeholders and verified presets.
- Verified presets shipped: generic JSON, Discord, Slack, Mattermost,
Microsoft Teams MessageCard, Telegram sendMessage, ntfy.sh, Pushover,
TuneIn AIR Playing.ashx, webhook.site echo.
- Outbound URL is re-validated on every send (defence in depth against
hand-edited configs becoming SSRF vectors).1 parent caf0235 commit a9a3e7e
7 files changed
Lines changed: 773 additions & 39 deletions
File tree
- config
- relay
- server
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
11 | 24 | | |
12 | 25 | | |
13 | 26 | | |
| |||
108 | 121 | | |
109 | 122 | | |
110 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
111 | 141 | | |
112 | | - | |
113 | | - | |
114 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
115 | 151 | | |
116 | 152 | | |
117 | 153 | | |
| |||
405 | 441 | | |
406 | 442 | | |
407 | 443 | | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
408 | 452 | | |
409 | 453 | | |
410 | 454 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
85 | 92 | | |
86 | 93 | | |
87 | 94 | | |
| |||
1049 | 1056 | | |
1050 | 1057 | | |
1051 | 1058 | | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
1052 | 1066 | | |
1053 | 1067 | | |
1054 | 1068 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
495 | 495 | | |
496 | 496 | | |
497 | 497 | | |
| 498 | + | |
498 | 499 | | |
499 | 500 | | |
500 | 501 | | |
| |||
0 commit comments