Update an entities.Discord @Summary Update a discord integration @Description Update a discord integration for the currently authenticated user @Security ApiKeyAuth @Tags DiscordIntegration @Accept json @Produce json @Param discordID path string true "ID of the
(c fiber.Ctx)
| 160 | // @Failure 500 {object} responses.InternalServerError |
| 161 | // @Router /discord-integrations/{discordID} [put] |
| 162 | func (h *DiscordHandler) Update(c fiber.Ctx) error { |
| 163 | ctx, span, ctxLogger := h.tracer.StartFromFiberCtxWithLogger(c, h.logger) |
| 164 | defer span.End() |
| 165 | |
| 166 | var request requests.DiscordUpdate |
| 167 | if err := c.Bind().Body(&request); err != nil { |
| 168 | msg := fmt.Sprintf("cannot marshall params [%s] into [%T]", c.Body(), request) |
| 169 | ctxLogger.Warn(stacktrace.Propagate(err, msg)) |
| 170 | return h.responseBadRequest(c, err) |
| 171 | } |
| 172 | |
| 173 | request.DiscordID = c.Params("discordID") |
| 174 | if errors := h.validator.ValidateUpdate(ctx, request.Sanitize()); len(errors) != 0 { |
| 175 | msg := fmt.Sprintf("validation errors [%s], while updating user [%+#v]", spew.Sdump(errors), request) |
| 176 | ctxLogger.Warn(stacktrace.NewError(msg)) |
| 177 | return h.responseUnprocessableEntity(c, errors, "validation errors while updating discord integration") |
| 178 | } |
| 179 | |
| 180 | user, err := h.service.Update(ctx, request.ToUpdateParams(h.userFromContext(c))) |
| 181 | if err != nil { |
| 182 | msg := fmt.Sprintf("cannot update discord integration with params [%+#v]", request) |
| 183 | ctxLogger.Error(stacktrace.Propagate(err, msg)) |
| 184 | return h.responseInternalServerError(c) |
| 185 | } |
| 186 | |
| 187 | return h.responseOK(c, "discord integration updated successfully", user) |
| 188 | } |
| 189 | |
| 190 | // Store an entities.Discord |
| 191 | // @Summary Store discord integration |
nothing calls this directly
no test coverage detected