Notify link=: a stage's public/ file sets the phone tap target

A stage's notify block may name `link=<pattern>` (validated like `open=`).
When the hook fires, the newest public/ match is read (at most 4 KiB); its
first non-empty line, if an absolute http(s) URL ntfy accepts as a click,
becomes the ntfy Click and the app notification click, with the run kept
as the app's run action and ntfy's browser view. A missing file or invalid
URL keeps today's tap target and is noted on the receipt diagnostic.

Android opens such an http(s) click in the browser (after clearing the
notification) instead of handing it to Flutter as a route.
This commit is contained in:
2026-12-02 12:20:22 +00:00
parent 26b1c00094
commit f5f31b7bcd
12 changed files with 355 additions and 55 deletions
+26 -14
View File
@@ -24,7 +24,7 @@ func parseNotify(text string) (*protocol.NotificationPolicy, error) {
return nil, fmt.Errorf("duplicate notify setting %s", key)
}
switch key {
case "on", "destination", "artifacts", "open":
case "on", "destination", "artifacts", "open", "link":
default:
return nil, fmt.Errorf("unknown notify setting %s", key)
}
@@ -60,19 +60,31 @@ func parseNotify(text string) (*protocol.NotificationPolicy, error) {
return nil, err
}
}
if open := values["open"]; open != "" {
if strings.ContainsAny(open, "\\\x00\r\n") || strings.HasPrefix(open, "/") || path.IsAbs(open) || path.Clean(open) != open {
return nil, fmt.Errorf("invalid notify open pattern")
}
for _, part := range strings.Split(open, "/") {
if part == ".." || strings.HasPrefix(part, ".") || part == "" {
return nil, fmt.Errorf("invalid notify open pattern")
}
}
if _, err := path.Match(open, ""); err != nil {
return nil, fmt.Errorf("invalid notify open pattern: %v", err)
}
p.Open = open
if p.Open, err = notifyPattern("open", values["open"]); err != nil {
return nil, err
}
if p.Link, err = notifyPattern("link", values["link"]); err != nil {
return nil, err
}
return p, nil
}
// notifyPattern validates an optional glob over the run's shared public/
// directory: relative, clean, no hidden or traversal segment.
func notifyPattern(key, pattern string) (string, error) {
if pattern == "" {
return "", nil
}
if strings.ContainsAny(pattern, "\\\x00\r\n") || strings.HasPrefix(pattern, "/") || path.IsAbs(pattern) || path.Clean(pattern) != pattern {
return "", fmt.Errorf("invalid notify %s pattern", key)
}
for _, part := range strings.Split(pattern, "/") {
if part == ".." || strings.HasPrefix(part, ".") || part == "" {
return "", fmt.Errorf("invalid notify %s pattern", key)
}
}
if _, err := path.Match(pattern, ""); err != nil {
return "", fmt.Errorf("invalid notify %s pattern: %v", key, err)
}
return pattern, nil
}