feat(notify): own webhook as a full notification channel
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 1m59s

The custom webhook could be entered but never switched on since the
notification matrix replaced the old alarm channels. It is now a third
column next to e-mail and Discord for every event and the daily summary;
bundles go out as JSON (event "digest").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sandrodachandClaude Opus 5.5 committed 2026-10-30 19:02:46 +01:00
1 parent 6c154af251
commit 261579f0f2
10 files changed
+202 -56

No files matched your search

+21 -1
View File
@@ -28,6 +28,14 @@ func notifyServer(t *testing.T) (*Server, *[]sentNote) {
sent = append(sent, sentNote{channel: "discord", to: url, text: strings.Join(lines, "\n")})
return nil
}
srv.notifyWebhookHook = func(url, heading string, items []notifyItem) error {
lines := make([]string, 0, len(items))
for _, it := range items {
lines = append(lines, it.text)
}
sent = append(sent, sentNote{channel: "webhook", to: url, text: strings.Join(lines, "\n")})
return nil
}
return srv, &sent
}
@@ -102,6 +110,18 @@ func TestOwnChangesPauseAndChannels(t *testing.T) {
t.Fatalf("expected one Discord message, got %+v", *sent)
}
// Own webhook as a channel of its own
*sent = nil
set.Events.Watched = domain.ChannelChoice{Webhook: true}
_ = store.SetNotificationSettings(me.ID, set)
own := "https://hooks.example.com/mindsift"
_, _ = store.UpdateUserFull(me.ID, nil, nil, nil, nil, nil, nil, nil, &own, nil, nil)
sessionCall(router, "PATCH", "/api/v1/thoughts/"+task.ID, myToken, `{"priority":"normal"}`, "")
srv.flushNotifications(time.Now().Add(10 * time.Minute))
if len(*sent) != 1 || (*sent)[0].channel != "webhook" || (*sent)[0].to != own {
t.Fatalf("expected one webhook message, got %+v", *sent)
}
// Paused: nothing at all
*sent = nil
set.Paused = true
@@ -114,7 +134,7 @@ func TestOwnChangesPauseAndChannels(t *testing.T) {
// Settings round trip over the profile API
rec := sessionCall(router, "PATCH", "/api/v1/auth/settings", myToken, `{"notificationSettings":{"paused":false,"events":{"shared":{"email":false,"discord":true}},"dailySummary":{"enabled":true,"time":"6:5"}}}`, "")
if rec.Code != http.StatusOK || !strings.Contains(rec.Body.String(), `"time":"07:00"`) || !strings.Contains(rec.Body.String(), `"shared":{"email":false,"discord":true}`) {
if rec.Code != http.StatusOK || !strings.Contains(rec.Body.String(), `"time":"07:00"`) || !strings.Contains(rec.Body.String(), `"shared":{"email":false,"discord":true,"webhook":false}`) {
t.Fatalf("settings: %d %s", rec.Code, rec.Body.String())
}
}