Show connected clients and their last human action in Status
This commit is contained in:
@@ -134,10 +134,34 @@ func (s *Server) identify(next http.Handler) http.Handler {
|
||||
return
|
||||
}
|
||||
|
||||
if (r.Method != http.MethodGet && !automaticRequests[r.Pattern]) || humanGets[r.Pattern] {
|
||||
s.acted(login, r)
|
||||
}
|
||||
|
||||
next.ServeHTTP(w, r.WithContext(context.WithValue(r.Context(), ctxKey{}, login)))
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Server) acted(login string, r *http.Request) {
|
||||
if s.hub.acted(login, r.Header.Get("Byre-Host"), r.Header.Get("Byre-Commit")) {
|
||||
s.clientsChanged()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) clientsChanged() {
|
||||
s.store.Broadcast(api.Event{Kind: "admin.clients", Actor: "byre", Payload: map[string]any{}})
|
||||
}
|
||||
|
||||
var automaticRequests = map[string]bool{
|
||||
"PUT /api/me/pane-focus": true,
|
||||
"PUT /api/tasks/{taskId}/summary-read": true,
|
||||
"POST /api/inbox/{itemId}/runs": true,
|
||||
}
|
||||
|
||||
var humanGets = map[string]bool{
|
||||
"GET /api/inbox/{itemId}/bundle": true,
|
||||
}
|
||||
|
||||
func (s *Server) ensureUser(ctx context.Context, login, name string) error {
|
||||
s.usersMu.Lock()
|
||||
defer s.usersMu.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user