presence_api.go 590 B

12345678910111213141516171819202122232425
  1. package httpapi
  2. import (
  3. "net/http"
  4. )
  5. func (s *server) handlePresenceStatus(w http.ResponseWriter, _ *http.Request) {
  6. if s.presence == nil {
  7. writeJSON(w, http.StatusOK, map[string]any{"available": false})
  8. return
  9. }
  10. writeJSON(w, http.StatusOK, map[string]any{
  11. "available": true,
  12. "people": s.presence.ListPeople(),
  13. "status": s.presence.CurrentStatus(),
  14. })
  15. }
  16. func (s *server) handlePresencePeople(w http.ResponseWriter, _ *http.Request) {
  17. if s.presence == nil {
  18. writeJSON(w, http.StatusOK, []any{})
  19. return
  20. }
  21. writeJSON(w, http.StatusOK, s.presence.ListPeople())
  22. }