adventure: don't strand an order on a database blip, don't misroute a tap
Two things a code review turned up in the W9 seams. The verdict handler answered 400 for everything ResolveAdvOrder could fail with, not just a bad verdict. gogobee's contract says a 400 means "park this row for a human", so a SQLite busy or a disk hiccup permanently stranded an extract or a bout that was perfectly resolvable. Split the two apart with ErrBadAdvVerdict: a verdict outside the terminal set is still 400, because gogobee will never send it successfully, and a genuine storage failure is now 500 and comes back on the next poll. The push URL builders concatenated the guid and the run id raw, while every other builder beside them path-escapes because these values arrive over a wire. A guid carrying a slash sent the notification tap to a different page.
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -344,13 +345,16 @@ func orPlace(zone string) string {
|
||||
// what they have always done.
|
||||
func advRunOrStoryURL(ev storage.AdvEvent) string {
|
||||
if ev.RunID != "" {
|
||||
return "/adventure/run/" + ev.RunID
|
||||
return runReportPath(ev.RunID)
|
||||
}
|
||||
return advStoryURL(ev.GUID)
|
||||
}
|
||||
|
||||
// advStoryURL is advPermalink's relative half, and it escapes for the same
|
||||
// reason: the guid arrives over a wire, and one that grew a slash would send the
|
||||
// notification somewhere else entirely.
|
||||
func advStoryURL(guid string) string {
|
||||
return "/adventure/" + guid
|
||||
return "/adventure/" + url.PathEscape(guid)
|
||||
}
|
||||
|
||||
// buildAdvPayload renders the notification JSON the service worker expects. The
|
||||
|
||||
Reference in New Issue
Block a user