Index returns the heartbeats of a phone number @Summary Get heartbeats of an owner phone number @Description Get the last time a phone number requested for outstanding messages. It will be sorted by timestamp in descending order. @Security ApiKeyAuth @Tags Heartbeats @Accept jso
(c fiber.Ctx)
| 67 | // @Failure 500 {object} responses.InternalServerError |
| 68 | // @Router /heartbeats [get] |
| 69 | func (h *HeartbeatHandler) Index(c fiber.Ctx) error { |
| 70 | ctx, span := h.tracer.StartFromFiberCtx(c) |
| 71 | defer span.End() |
| 72 | |
| 73 | ctxLogger := h.tracer.CtxLogger(h.logger, span) |
| 74 | |
| 75 | var request requests.HeartbeatIndex |
| 76 | if err := c.Bind().Query(&request); err != nil { |
| 77 | msg := fmt.Sprintf("cannot marshall params [%s] into %T", c.OriginalURL(), request) |
| 78 | ctxLogger.Warn(stacktrace.Propagate(err, msg)) |
| 79 | return h.responseBadRequest(c, err) |
| 80 | } |
| 81 | |
| 82 | if errors := h.validator.ValidateIndex(ctx, request.Sanitize()); len(errors) != 0 { |
| 83 | msg := fmt.Sprintf("validation errors [%s], while fetching heartbeats [%+#v]", spew.Sdump(errors), request) |
| 84 | ctxLogger.Warn(stacktrace.NewError(msg)) |
| 85 | return h.responseUnprocessableEntity(c, errors, "validation errors while fetching heartbeats") |
| 86 | } |
| 87 | |
| 88 | heartbeats, err := h.service.Index(ctx, h.userIDFomContext(c), request.Owner, request.ToIndexParams()) |
| 89 | if err != nil { |
| 90 | msg := fmt.Sprintf("cannot get messgaes with params [%+#v]", request) |
| 91 | ctxLogger.Error(stacktrace.Propagate(err, msg)) |
| 92 | return h.responseInternalServerError(c) |
| 93 | } |
| 94 | |
| 95 | return h.responseOK(c, fmt.Sprintf("fetched %d %s", len(*heartbeats), h.pluralize("heartbeat", len(*heartbeats))), heartbeats) |
| 96 | } |
| 97 | |
| 98 | // Store the heartbeat of a phone number |
| 99 | // @Summary Register heartbeat of an owner phone number |
nothing calls this directly
no test coverage detected