M4 networkmanager: open the page and tell the person

At a join, at the watcher's start and at a session's start while PORTAL, once per ask,
the watcher opens the check address with systemd-run --user and xdg-open in the
person's session and then shows the notification its outcome calls for, critical when
the open failed; it says when the network is open, and handles what it hears during
an open after it.

Builds: design 08 sign-in-page §15, §18, §19, §22
This commit is contained in:
jochen
2026-11-24 21:20:20 +01:00
parent fee3f8ab8b
commit a4169a2325
6 changed files with 515 additions and 54 deletions
@@ -207,50 +207,3 @@ type sessionNote struct {
At time.Time `json:"at"`
Did string `json:"did"`
}
// desk is the person's desktop as the watcher reaches it: opening an address in their session (§18).
type desk interface {
open(s Session, address string) openOutcome
}
// openOutcome is how an open ended: opened, opening (still running at its bound) or failed, with the program and the
// reason of a failure.
type openOutcome struct {
Address string `json:"address"`
Program string `json:"program,omitempty"`
Outcome string `json:"outcome"`
Reason string `json:"reason,omitempty"`
At time.Time `json:"at"`
}
// The outcomes of an open.
const (
outcomeOpened = "opened"
outcomeOpening = "opening"
outcomeFailed = "failed"
)
// present opens the address in the person's session, s or the one found now (§15, §18); with no session found it opens
// nothing, and the events are kept all the same (§15, §16).
func (w *Watcher) present(s *Session, network, address string) {
if s == nil {
found, err := w.findSession()
if err != nil {
journal("finding the person's session failed: %v; the sign-in page of %q is not opened", err, network)
return
}
if found == nil {
journal("no graphical session: the sign-in page of %q is not opened", network)
return
}
s = found
}
o := w.Desk.open(*s, address)
o.At = w.Now()
w.state.LastOpen = &o
if o.Outcome == outcomeFailed {
journal("opening %s in session %s failed: %s", address, s.ID, o.Reason)
} else {
journal("the sign-in page %s is %s in %s", address, o.Outcome, o.Program)
}
}