fix(notify): open configured web run pages from ntfy
This commit is contained in:
@@ -73,7 +73,7 @@ func (r *runner) notifyStep(id int64, name, workspace string, policy *protocol.N
|
||||
return
|
||||
}
|
||||
receipt := &receipts[len(receipts)-1]
|
||||
result, err := stage.PublishNtfy(ctx, "system", title, summary, filename, data, "")
|
||||
result, err := stage.PublishNtfy(ctx, "system", title, summary, filename, data, runAttentionClick(id))
|
||||
if err != nil {
|
||||
receipt.Status = "failed"
|
||||
receipt.Diagnostic = err.Error()
|
||||
@@ -294,10 +294,18 @@ func (r *runner) forgetAttention(id int64) {
|
||||
delete(r.attentionSent, id)
|
||||
}
|
||||
|
||||
// runAttentionClick is the deep link a run notification carries so tapping it
|
||||
// opens the run in the Android app, whose intent filter registers this scheme
|
||||
// and host.
|
||||
// Prefer the operator's authenticated web origin. Never infer a public address
|
||||
// from a request Host, the unauthenticated API listener or the ntfy server URL.
|
||||
// Older Android-only installations retain their deep link until configured.
|
||||
func runAttentionClick(id int64) string {
|
||||
if raw := os.Getenv("PIPELINES_WEB_PUBLIC_URL"); raw != "" {
|
||||
base := publicNtfyBase(raw)
|
||||
if base == "" {
|
||||
log.Printf("notification web link unavailable: PIPELINES_WEB_PUBLIC_URL must be an HTTP(S) origin without credentials, query or fragment")
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprintf("%s/runs/%d", base, id)
|
||||
}
|
||||
return fmt.Sprintf("pipelines://run/%d", id)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user