Open ntfy notifications in the app and notify chats that need the operator
Run notifications now always click through to pipelines://run/<id>; a valid PIPELINES_WEB_PUBLIC_URL adds an "Open in browser" ntfy view action instead of replacing the click. Queued rows derive links from the run id at delivery, so legacy rows holding a web URL still open the app. Unresolved chat questions/forms and permission requests publish one async, bounded notification to the system destination (pipelines://chat/<id> plus the browser action), deduplicated per form/request id across reconnects and replays. stage.PublishNtfy gains optional, strictly validated view actions. Server tests now clear the operator's real ntfy environment.
This commit is contained in:
@@ -28,8 +28,8 @@ func TestRunNotificationPublisherFailureRetriesAfterReopen(t *testing.T) {
|
||||
}
|
||||
var calls atomic.Int32
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if got := r.Header.Get("Click"); got != "https://pipelines.example.com/runs/7" {
|
||||
t.Errorf("wrong web retry link: %q", got)
|
||||
if got, actions := r.Header.Get("Click"), r.Header.Get("Actions"); got != "pipelines://run/7" || actions != "view, Open in browser, https://pipelines.example.com/runs/7" {
|
||||
t.Errorf("wrong retry links: %q %q", got, actions)
|
||||
}
|
||||
if calls.Add(1) == 1 {
|
||||
http.Error(w, "transient", http.StatusServiceUnavailable)
|
||||
@@ -93,9 +93,12 @@ func TestTransactionalSuccessNotificationUsesWebLink(t *testing.T) {
|
||||
var calls atomic.Int32
|
||||
endpoint := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
calls.Add(1)
|
||||
if got, want := req.Header.Get("Click"), "https://pipelines.example.com/runs/"+fmt.Sprint(id); got != want {
|
||||
if got, want := req.Header.Get("Click"), "pipelines://run/"+fmt.Sprint(id); got != want {
|
||||
t.Errorf("click = %q, want %q", got, want)
|
||||
}
|
||||
if got, want := req.Header.Get("Actions"), "view, Open in browser, https://pipelines.example.com/runs/"+fmt.Sprint(id); got != want {
|
||||
t.Errorf("actions = %q, want %q", got, want)
|
||||
}
|
||||
_ = json.NewEncoder(w).Encode(map[string]string{"id": "web-success", "event": "message"})
|
||||
}))
|
||||
defer endpoint.Close()
|
||||
|
||||
Reference in New Issue
Block a user