4
0

aim_stub.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package handlers
  2. import (
  3. "log/slog"
  4. "net/http"
  5. )
  6. // AimStubHandler serves unimplemented Web AIM /aim/* endpoints the client
  7. // calls during normal startup (client-side storage, forward-domain config).
  8. type AimStubHandler struct {
  9. Logger *slog.Logger
  10. }
  11. // SetForwardDomain acknowledges the client's forward-domain registration.
  12. // The Web AIM client fires this once when the session goes online; name may be
  13. // the literal string "null" for local/dev servers.
  14. func (h *AimStubHandler) SetForwardDomain(w http.ResponseWriter, r *http.Request) {
  15. resp := BaseResponse{}
  16. resp.Response.StatusCode = 200
  17. resp.Response.StatusText = "OK"
  18. SendResponse(w, r, resp, h.Logger)
  19. }
  20. // ReportAction acknowledges a client-side UI telemetry ping. The Web AIM client
  21. // fires this on menu clicks and similar interactions with an action param of the
  22. // form "type=click,id=block-user-chatmenu"; it ignores the response.
  23. func (h *AimStubHandler) ReportAction(w http.ResponseWriter, r *http.Request) {
  24. resp := BaseResponse{}
  25. resp.Response.StatusCode = 200
  26. resp.Response.StatusText = "OK"
  27. SendResponse(w, r, resp, h.Logger)
  28. }
  29. // StoredDataItems is the client-side data blob store, which this server does
  30. // not keep, so it always answers with an empty items list.
  31. type StoredDataItems struct {
  32. Items []string `json:"items" xml:"items>item"`
  33. }
  34. // GetData returns empty client-side data blobs (buddy list favorites, etc.).
  35. func (h *AimStubHandler) GetData(w http.ResponseWriter, r *http.Request) {
  36. resp := BaseResponse{}
  37. resp.Response.StatusCode = 200
  38. resp.Response.StatusText = "OK"
  39. resp.Response.Data = &StoredDataItems{Items: []string{}}
  40. SendResponse(w, r, resp, h.Logger)
  41. }