service_stub.go 1.1 KB

12345678910111213141516171819202122232425262728
  1. package handlers
  2. import (
  3. "log/slog"
  4. "net/http"
  5. )
  6. // ServiceStubHandler serves the /service/* endpoints that manage third-party
  7. // service linking (Google Talk, Facebook), none of which this server federates.
  8. type ServiceStubHandler struct {
  9. Logger *slog.Logger
  10. }
  11. // statusNoSuchService is the envelope status the Web AIM client accepts as
  12. // "this account has no such linked service". Its getAttributes callback treats
  13. // 601 as an expected outcome and returns early; any other status sends it into
  14. // the success branch, where it dereferences response.data.serviceName and marks
  15. // the service associated. A 404 therefore both crashes the callback and, if it
  16. // did not, would advertise a Google Talk link that does not exist.
  17. const statusNoSuchService = 601
  18. // GetAttributes reports that the requested third-party service is not linked.
  19. func (h *ServiceStubHandler) GetAttributes(w http.ResponseWriter, r *http.Request) {
  20. resp := BaseResponse{}
  21. resp.Response.StatusCode = statusNoSuchService
  22. resp.Response.StatusText = "Service not available"
  23. SendResponse(w, r, resp, h.Logger)
  24. }