2024-04-23 07:15:38 -07:00
|
|
|
package v1
|
2022-06-19 22:02:44 -07:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
2024-04-28 12:32:51 -07:00
|
|
|
"strconv"
|
2022-06-19 22:02:44 -07:00
|
|
|
"strings"
|
|
|
|
|
2024-04-23 22:18:07 -07:00
|
|
|
"git.jamestombleson.com/jtom38/newsbot-api/internal/domain"
|
2024-04-28 12:32:51 -07:00
|
|
|
"git.jamestombleson.com/jtom38/newsbot-api/internal/services"
|
2024-04-23 22:18:07 -07:00
|
|
|
"github.com/labstack/echo/v4"
|
2022-06-19 22:02:44 -07:00
|
|
|
)
|
|
|
|
|
2023-01-22 10:12:55 -08:00
|
|
|
// ListDiscordWebhooks
|
2024-04-28 12:32:51 -07:00
|
|
|
// @Summary Returns the top 100
|
2022-06-19 22:02:44 -07:00
|
|
|
// @Produce application/json
|
2024-05-02 17:36:39 -07:00
|
|
|
// @Tags DiscordWebhook
|
|
|
|
// @Router /v1/discord/webhooks [get]
|
2024-04-28 12:32:51 -07:00
|
|
|
// @Success 200 {object} domain.DiscordWebhookResponse
|
|
|
|
// @Failure 400 {object} domain.BaseResponse
|
|
|
|
// @Failure 500 {object} domain.BaseResponse
|
2024-05-07 19:14:37 -07:00
|
|
|
// @Security Bearer
|
2024-04-23 22:18:07 -07:00
|
|
|
func (s *Handler) ListDiscordWebHooks(c echo.Context) error {
|
2024-05-07 19:14:37 -07:00
|
|
|
s.ValidateJwtToken(c, domain.ScopeDiscordWebhookRead)
|
2024-04-28 12:32:51 -07:00
|
|
|
p := domain.DiscordWebhookResponse{
|
|
|
|
BaseResponse: domain.BaseResponse{
|
|
|
|
Message: ResponseMessageSuccess,
|
2023-01-22 10:12:55 -08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2024-04-28 12:32:51 -07:00
|
|
|
res, err := s.repo.DiscordWebHooks.ListByServerName(c.Request().Context(), "")
|
2022-06-19 22:02:44 -07:00
|
|
|
if err != nil {
|
2024-04-23 22:18:07 -07:00
|
|
|
return c.JSON(http.StatusInternalServerError, err)
|
2022-06-19 22:02:44 -07:00
|
|
|
}
|
2024-04-28 12:32:51 -07:00
|
|
|
p.Payload = services.DiscordWebhooksToDto(res)
|
2024-04-23 22:18:07 -07:00
|
|
|
return c.JSON(http.StatusOK, p)
|
2023-01-22 10:12:55 -08:00
|
|
|
}
|
|
|
|
|
2022-08-21 20:02:45 -07:00
|
|
|
// GetDiscordWebHook
|
2022-06-19 22:02:44 -07:00
|
|
|
// @Summary Returns the top 100 entries from the queue to be processed.
|
|
|
|
// @Produce application/json
|
2024-04-28 12:32:51 -07:00
|
|
|
// @Param id path int true "id"
|
2024-05-02 17:36:39 -07:00
|
|
|
// @Tags DiscordWebhook
|
|
|
|
// @Router /v1/discord/webhooks/{id} [get]
|
2024-04-28 12:32:51 -07:00
|
|
|
// @Success 200 {object} domain.DiscordWebhookResponse "OK"
|
|
|
|
// @Failure 400 {object} domain.BaseResponse
|
|
|
|
// @Failure 500 {object} domain.BaseResponse
|
2024-05-07 19:14:37 -07:00
|
|
|
// @Security Bearer
|
2024-04-23 22:18:07 -07:00
|
|
|
func (s *Handler) GetDiscordWebHooksById(c echo.Context) error {
|
2024-05-07 19:14:37 -07:00
|
|
|
s.ValidateJwtToken(c, domain.ScopeDiscordWebhookRead)
|
2024-04-28 12:32:51 -07:00
|
|
|
p := domain.DiscordWebhookResponse{
|
|
|
|
BaseResponse: domain.BaseResponse{
|
|
|
|
Message: ResponseMessageSuccess,
|
2023-01-22 10:12:55 -08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2024-04-28 12:32:51 -07:00
|
|
|
id, err := strconv.Atoi(c.Param("ID"))
|
2022-06-19 22:02:44 -07:00
|
|
|
if err != nil {
|
2024-04-28 12:32:51 -07:00
|
|
|
s.WriteError(c, err, http.StatusBadRequest)
|
2022-06-19 22:02:44 -07:00
|
|
|
}
|
2022-12-04 08:49:17 -08:00
|
|
|
|
2024-04-28 12:32:51 -07:00
|
|
|
res, err := s.repo.DiscordWebHooks.GetById(c.Request().Context(), int64(id))
|
2022-06-19 22:02:44 -07:00
|
|
|
if err != nil {
|
2024-04-28 12:32:51 -07:00
|
|
|
s.WriteError(c, err, http.StatusInternalServerError)
|
2022-06-19 22:02:44 -07:00
|
|
|
}
|
2024-04-28 12:32:51 -07:00
|
|
|
var dtos []domain.DiscordWebHookDto
|
|
|
|
dtos = append(dtos, services.DiscordWebhookToDto(res))
|
|
|
|
p.Payload = dtos
|
2024-04-23 22:18:07 -07:00
|
|
|
return c.JSON(http.StatusOK, p)
|
2022-06-19 22:02:44 -07:00
|
|
|
}
|
|
|
|
|
2022-11-30 21:43:53 -08:00
|
|
|
// GetDiscordWebHookByServerAndChannel
|
|
|
|
// @Summary Returns all the known web hooks based on the Server and Channel given.
|
|
|
|
// @Produce application/json
|
|
|
|
// @Param server query string true "Fancy Server"
|
|
|
|
// @Param channel query string true "memes"
|
2024-05-02 17:36:39 -07:00
|
|
|
// @Tags DiscordWebhook
|
|
|
|
// @Router /v1/discord/webhooks/by/serverAndChannel [get]
|
2024-04-28 12:32:51 -07:00
|
|
|
// @Success 200 {object} domain.DiscordWebhookResponse "OK"
|
|
|
|
// @Failure 400 {object} domain.BaseResponse
|
|
|
|
// @Failure 500 {object} domain.BaseResponse
|
2024-05-07 19:14:37 -07:00
|
|
|
// @Security Bearer
|
2024-04-23 22:18:07 -07:00
|
|
|
func (s *Handler) GetDiscordWebHooksByServerAndChannel(c echo.Context) error {
|
2024-05-07 19:14:37 -07:00
|
|
|
s.ValidateJwtToken(c, domain.ScopeDiscordWebhookRead)
|
2024-04-28 12:32:51 -07:00
|
|
|
p := domain.DiscordWebhookResponse{
|
|
|
|
BaseResponse: domain.BaseResponse{
|
|
|
|
Message: ResponseMessageSuccess,
|
2023-01-22 10:12:55 -08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2024-04-23 22:18:07 -07:00
|
|
|
_server := c.QueryParam("server")
|
2022-11-30 21:43:53 -08:00
|
|
|
if _server == "" {
|
2024-04-28 12:32:51 -07:00
|
|
|
s.WriteMessage(c, "server was not defined", http.StatusBadRequest)
|
2022-11-30 21:43:53 -08:00
|
|
|
}
|
|
|
|
|
2024-04-23 22:18:07 -07:00
|
|
|
_channel := c.QueryParam("channel")
|
2022-11-30 21:43:53 -08:00
|
|
|
if _channel == "" {
|
2024-04-28 12:32:51 -07:00
|
|
|
s.WriteMessage(c, "channel was not defined", http.StatusBadRequest)
|
2022-11-30 21:43:53 -08:00
|
|
|
}
|
2023-01-22 10:12:55 -08:00
|
|
|
|
2024-04-28 12:32:51 -07:00
|
|
|
res, err := s.repo.DiscordWebHooks.ListByServerAndChannel(c.Request().Context(), _server, _channel)
|
2022-11-30 21:43:53 -08:00
|
|
|
if err != nil {
|
2024-04-28 12:32:51 -07:00
|
|
|
s.WriteError(c, err, http.StatusInternalServerError)
|
2022-11-30 21:43:53 -08:00
|
|
|
}
|
|
|
|
|
2024-04-28 12:32:51 -07:00
|
|
|
p.Payload = services.DiscordWebhooksToDto(res)
|
2024-04-23 22:18:07 -07:00
|
|
|
return c.JSON(http.StatusOK, p)
|
2022-11-30 21:43:53 -08:00
|
|
|
}
|
|
|
|
|
2022-06-19 22:02:44 -07:00
|
|
|
// NewDiscordWebHook
|
|
|
|
// @Summary Creates a new record for a discord web hook to post data to.
|
|
|
|
// @Param url query string true "url"
|
|
|
|
// @Param server query string true "Server name"
|
2022-07-12 15:28:31 -07:00
|
|
|
// @Param channel query string true "Channel name"
|
2024-05-02 17:36:39 -07:00
|
|
|
// @Tags DiscordWebhook
|
|
|
|
// @Router /v1/discord/webhooks/new [post]
|
2024-04-28 12:32:51 -07:00
|
|
|
// @Success 200 {object} domain.DiscordWebhookResponse "OK"
|
|
|
|
// @Failure 400 {object} domain.BaseResponse
|
|
|
|
// @Failure 500 {object} domain.BaseResponse
|
2024-05-07 19:14:37 -07:00
|
|
|
// @Security Bearer
|
2024-04-23 22:18:07 -07:00
|
|
|
func (s *Handler) NewDiscordWebHook(c echo.Context) error {
|
2024-05-07 19:14:37 -07:00
|
|
|
token := s.ValidateJwtToken(c, domain.ScopeDiscordWebHookCreate)
|
2024-05-04 11:58:35 -07:00
|
|
|
|
2024-04-23 22:18:07 -07:00
|
|
|
_url := c.QueryParam("url")
|
|
|
|
_server := c.QueryParam("server")
|
|
|
|
_channel := c.QueryParam("channel")
|
2022-06-19 22:02:44 -07:00
|
|
|
|
|
|
|
if _url == "" {
|
2024-04-28 11:41:34 -07:00
|
|
|
return c.JSON(http.StatusBadRequest, domain.BaseResponse{
|
2024-04-23 22:18:07 -07:00
|
|
|
Message: "url is missing a value",
|
|
|
|
})
|
2022-06-19 22:02:44 -07:00
|
|
|
}
|
|
|
|
if !strings.Contains(_url, "discord.com/api/webhooks") {
|
2024-04-28 11:41:34 -07:00
|
|
|
return c.JSON(http.StatusBadRequest, domain.BaseResponse{
|
2024-04-23 22:18:07 -07:00
|
|
|
Message: "invalid url",
|
|
|
|
})
|
2022-06-19 22:02:44 -07:00
|
|
|
}
|
2022-12-04 08:49:17 -08:00
|
|
|
if _server == "" {
|
2024-04-28 11:41:34 -07:00
|
|
|
return c.JSON(http.StatusBadRequest, domain.BaseResponse{
|
2024-04-23 22:18:07 -07:00
|
|
|
Message: "server is missing",
|
|
|
|
})
|
2022-06-19 22:02:44 -07:00
|
|
|
}
|
|
|
|
if _channel == "" {
|
2024-04-28 11:41:34 -07:00
|
|
|
return c.JSON(http.StatusBadRequest, domain.BaseResponse{
|
2024-04-23 22:18:07 -07:00
|
|
|
Message: "channel is missing",
|
|
|
|
})
|
2022-06-19 22:02:44 -07:00
|
|
|
}
|
2024-04-28 12:32:51 -07:00
|
|
|
|
2024-05-05 10:02:17 -07:00
|
|
|
user, err := s.repo.Users.GetUser(c.Request().Context(), token.UserName)
|
2024-05-04 11:58:35 -07:00
|
|
|
if err != nil {
|
|
|
|
s.WriteMessage(c, ErrUserUnknown, http.StatusBadRequest)
|
|
|
|
}
|
|
|
|
|
|
|
|
rows, err := s.repo.DiscordWebHooks.Create(c.Request().Context(), user.ID, _url, _server, _channel, true)
|
2024-04-28 12:32:51 -07:00
|
|
|
if err != nil {
|
|
|
|
s.WriteError(c, err, http.StatusInternalServerError)
|
|
|
|
}
|
|
|
|
|
|
|
|
if rows != 1 {
|
|
|
|
s.WriteMessage(c, "data was not written to database", http.StatusInternalServerError)
|
|
|
|
}
|
|
|
|
|
|
|
|
item, err := s.repo.DiscordWebHooks.GetByUrl(c.Request().Context(), _url)
|
|
|
|
if err != nil {
|
|
|
|
s.WriteError(c, err, http.StatusInternalServerError)
|
2022-06-19 22:02:44 -07:00
|
|
|
}
|
|
|
|
|
2024-04-28 12:32:51 -07:00
|
|
|
var dtos []domain.DiscordWebHookDto
|
|
|
|
dtos = append(dtos, services.DiscordWebhookToDto(item))
|
|
|
|
|
|
|
|
return c.JSON(http.StatusOK, domain.DiscordWebhookResponse{
|
|
|
|
BaseResponse: domain.BaseResponse{
|
|
|
|
Message: ResponseMessageSuccess,
|
|
|
|
},
|
|
|
|
Payload: dtos,
|
|
|
|
})
|
2022-06-19 22:02:44 -07:00
|
|
|
}
|
2022-08-21 20:02:45 -07:00
|
|
|
|
|
|
|
// DisableDiscordWebHooks
|
|
|
|
// @Summary Disables a Webhook from being used.
|
2024-04-28 12:32:51 -07:00
|
|
|
// @Param id path int true "id"
|
2024-05-02 17:36:39 -07:00
|
|
|
// @Tags DiscordWebhook
|
|
|
|
// @Router /v1/discord/webhooks/{ID}/disable [post]
|
2024-04-28 12:32:51 -07:00
|
|
|
// @Success 200 {object} domain.DiscordWebhookResponse "OK"
|
|
|
|
// @Failure 400 {object} domain.BaseResponse
|
|
|
|
// @Failure 500 {object} domain.BaseResponse
|
2024-05-07 19:14:37 -07:00
|
|
|
// @Security Bearer
|
2024-04-23 22:18:07 -07:00
|
|
|
func (s *Handler) disableDiscordWebHook(c echo.Context) error {
|
2024-05-07 19:14:37 -07:00
|
|
|
s.ValidateJwtToken(c, domain.ScopeDiscordWebHookCreate)
|
2024-04-28 12:32:51 -07:00
|
|
|
id, err := strconv.Atoi(c.Param("ID"))
|
2022-08-21 20:02:45 -07:00
|
|
|
if err != nil {
|
2024-04-28 11:41:34 -07:00
|
|
|
return c.JSON(http.StatusBadRequest, domain.BaseResponse{
|
2024-04-23 22:18:07 -07:00
|
|
|
Message: err.Error(),
|
|
|
|
})
|
2022-08-21 20:02:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check to make sure we can find the record
|
2024-05-07 19:14:37 -07:00
|
|
|
record, err := s.repo.DiscordWebHooks.GetById(c.Request().Context(), int64(id))
|
2022-08-21 20:02:45 -07:00
|
|
|
if err != nil {
|
2024-04-28 12:32:51 -07:00
|
|
|
s.WriteError(c, err, http.StatusInternalServerError)
|
2022-08-21 20:02:45 -07:00
|
|
|
}
|
|
|
|
|
2024-05-07 19:14:37 -07:00
|
|
|
if record.UserID != s.GetUserIdFromJwtToken(c) {
|
|
|
|
s.WriteMessage(c, ErrYouDontOwnTheRecord, http.StatusBadRequest)
|
|
|
|
}
|
|
|
|
|
2024-04-28 12:32:51 -07:00
|
|
|
// flip the it
|
|
|
|
updated, err := s.repo.DiscordWebHooks.Disable(c.Request().Context(), int64(id))
|
2022-08-21 20:02:45 -07:00
|
|
|
if err != nil {
|
2024-04-28 12:32:51 -07:00
|
|
|
s.WriteError(c, err, http.StatusInternalServerError)
|
|
|
|
}
|
|
|
|
|
|
|
|
// make sure we got a row updated
|
|
|
|
if updated != 1 {
|
|
|
|
s.WriteMessage(c, "unexpected number of updates found", http.StatusInternalServerError)
|
2022-08-21 20:02:45 -07:00
|
|
|
}
|
2024-04-28 12:32:51 -07:00
|
|
|
|
|
|
|
item, err := s.repo.DiscordWebHooks.GetById(c.Request().Context(), int64(id))
|
|
|
|
if err != nil {
|
|
|
|
s.WriteError(c, err, http.StatusInternalServerError)
|
|
|
|
}
|
|
|
|
|
|
|
|
var dtos []domain.DiscordWebHookDto
|
|
|
|
dtos = append(dtos, services.DiscordWebhookToDto(item))
|
|
|
|
return c.JSON(http.StatusOK, domain.DiscordWebhookResponse{
|
|
|
|
BaseResponse: domain.BaseResponse{
|
|
|
|
Message: ResponseMessageSuccess,
|
|
|
|
},
|
|
|
|
Payload: dtos,
|
|
|
|
})
|
2022-08-21 20:02:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// EnableDiscordWebHook
|
|
|
|
// @Summary Enables a source to continue processing.
|
2024-04-28 12:32:51 -07:00
|
|
|
// @Param id path int true "id"
|
2024-05-02 17:36:39 -07:00
|
|
|
// @Tags DiscordWebhook
|
|
|
|
// @Router /v1/discord/webhooks/{ID}/enable [post]
|
2024-05-07 19:14:37 -07:00
|
|
|
// @Security Bearer
|
2024-04-23 22:18:07 -07:00
|
|
|
func (s *Handler) enableDiscordWebHook(c echo.Context) error {
|
2024-05-07 19:14:37 -07:00
|
|
|
s.ValidateJwtToken(c, domain.ScopeDiscordWebHookCreate)
|
2024-04-28 12:32:51 -07:00
|
|
|
id, err := strconv.Atoi(c.Param("ID"))
|
2022-08-21 20:02:45 -07:00
|
|
|
if err != nil {
|
2024-04-28 12:32:51 -07:00
|
|
|
s.WriteError(c, err, http.StatusBadRequest)
|
2022-08-21 20:02:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check to make sure we can find the record
|
2024-05-07 19:14:37 -07:00
|
|
|
record, err := s.repo.DiscordWebHooks.GetById(c.Request().Context(), int64(id))
|
2022-08-21 20:02:45 -07:00
|
|
|
if err != nil {
|
2024-04-28 12:32:51 -07:00
|
|
|
s.WriteError(c, err, http.StatusBadRequest)
|
2022-08-21 20:02:45 -07:00
|
|
|
}
|
|
|
|
|
2024-05-07 19:14:37 -07:00
|
|
|
if record.UserID != s.GetUserIdFromJwtToken(c) {
|
|
|
|
s.WriteMessage(c, ErrYouDontOwnTheRecord, http.StatusBadRequest)
|
|
|
|
}
|
|
|
|
|
2024-04-28 12:32:51 -07:00
|
|
|
updated, err := s.repo.DiscordWebHooks.Enable(c.Request().Context(), int64(id))
|
2022-08-21 20:02:45 -07:00
|
|
|
if err != nil {
|
2024-04-28 12:32:51 -07:00
|
|
|
s.WriteError(c, err, http.StatusInternalServerError)
|
|
|
|
}
|
|
|
|
|
|
|
|
if updated != 1 {
|
|
|
|
s.WriteMessage(c, "unexpected number of updates found", http.StatusInternalServerError)
|
2022-08-21 20:02:45 -07:00
|
|
|
}
|
2024-04-28 12:32:51 -07:00
|
|
|
|
|
|
|
item, err := s.repo.DiscordWebHooks.GetById(c.Request().Context(), int64(id))
|
|
|
|
if err != nil {
|
|
|
|
s.WriteError(c, err, http.StatusInternalServerError)
|
|
|
|
}
|
|
|
|
|
|
|
|
var dtos []domain.DiscordWebHookDto
|
|
|
|
dtos = append(dtos, services.DiscordWebhookToDto(item))
|
|
|
|
return c.JSON(http.StatusOK, domain.DiscordWebhookResponse{
|
|
|
|
BaseResponse: domain.BaseResponse{
|
|
|
|
Message: ResponseMessageSuccess,
|
|
|
|
},
|
|
|
|
Payload: dtos,
|
|
|
|
})
|
2022-08-21 20:02:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// DeleteDiscordWebHook
|
|
|
|
// @Summary Deletes a record by ID.
|
|
|
|
// @Param id path string true "id"
|
2024-05-02 17:36:39 -07:00
|
|
|
// @Tags DiscordWebhook
|
|
|
|
// @Router /v1/discord/webhooks/{ID} [delete]
|
2024-04-28 12:32:51 -07:00
|
|
|
// @Success 200 {object} domain.DiscordWebhookResponse "OK"
|
|
|
|
// @Failure 400 {object} domain.BaseResponse
|
|
|
|
// @Failure 500 {object} domain.BaseResponse
|
2024-04-23 22:18:07 -07:00
|
|
|
func (s *Handler) deleteDiscordWebHook(c echo.Context) error {
|
2024-05-07 19:14:37 -07:00
|
|
|
s.ValidateJwtToken(c, domain.ScopeDiscordWebHookCreate)
|
2024-04-28 12:32:51 -07:00
|
|
|
id, err := strconv.Atoi(c.Param("ID"))
|
2022-08-21 20:02:45 -07:00
|
|
|
if err != nil {
|
2024-04-23 22:18:07 -07:00
|
|
|
return c.JSON(http.StatusBadRequest, err.Error())
|
2022-08-21 20:02:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check to make sure we can find the record
|
2024-05-07 19:14:37 -07:00
|
|
|
record, err := s.repo.DiscordWebHooks.GetById(c.Request().Context(), int64(id))
|
2022-08-21 20:02:45 -07:00
|
|
|
if err != nil {
|
2024-04-23 22:18:07 -07:00
|
|
|
return c.JSON(http.StatusInternalServerError, err.Error())
|
2022-08-21 20:02:45 -07:00
|
|
|
}
|
|
|
|
|
2024-05-07 19:14:37 -07:00
|
|
|
if record.UserID != s.GetUserIdFromJwtToken(c) {
|
|
|
|
s.WriteMessage(c, ErrYouDontOwnTheRecord, http.StatusBadRequest)
|
|
|
|
}
|
|
|
|
|
2024-04-28 12:32:51 -07:00
|
|
|
// Soft delete the record
|
|
|
|
updated, err := s.repo.DiscordWebHooks.SoftDelete(c.Request().Context(), int64(id))
|
2022-08-21 20:02:45 -07:00
|
|
|
if err != nil {
|
2024-04-23 22:18:07 -07:00
|
|
|
return c.JSON(http.StatusInternalServerError, err.Error())
|
2022-08-21 20:02:45 -07:00
|
|
|
}
|
2024-04-23 22:18:07 -07:00
|
|
|
|
2024-04-28 12:32:51 -07:00
|
|
|
if updated != 1 {
|
|
|
|
s.WriteMessage(c, "unexpected number of updates found", http.StatusInternalServerError)
|
|
|
|
}
|
|
|
|
|
|
|
|
item, err := s.repo.DiscordWebHooks.GetById(c.Request().Context(), int64(id))
|
|
|
|
if err != nil {
|
|
|
|
s.WriteError(c, err, http.StatusInternalServerError)
|
|
|
|
}
|
|
|
|
|
|
|
|
var dtos []domain.DiscordWebHookDto
|
|
|
|
dtos = append(dtos, services.DiscordWebhookToDto(item))
|
|
|
|
return c.JSON(http.StatusOK, domain.DiscordWebhookResponse{
|
|
|
|
BaseResponse: domain.BaseResponse{
|
|
|
|
Message: ResponseMessageSuccess,
|
|
|
|
},
|
|
|
|
Payload: dtos,
|
|
|
|
})
|
2022-08-21 20:02:45 -07:00
|
|
|
}
|
2022-11-06 17:17:46 -08:00
|
|
|
|
|
|
|
// UpdateDiscordWebHook
|
|
|
|
// @Summary Updates a valid discord webhook ID based on the body given.
|
|
|
|
// @Param id path string true "id"
|
2024-05-02 17:36:39 -07:00
|
|
|
// @Tags DiscordWebhook
|
|
|
|
// @Router /v1/discord/webhooks/{id} [patch]
|
2024-04-28 12:32:51 -07:00
|
|
|
// @Success 200 {object} domain.DiscordWebhookResponse "OK"
|
|
|
|
// @Failure 400 {object} domain.BaseResponse
|
|
|
|
// @Failure 500 {object} domain.BaseResponse
|
|
|
|
//func (s *Handler) UpdateDiscordWebHook(c echo.Context) error {
|
|
|
|
// id, err := strconv.Atoi(c.Param("ID"))
|
|
|
|
// if err != nil {
|
|
|
|
// return c.JSON(http.StatusInternalServerError, err.Error())
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// // Check to make sure we can find the record
|
|
|
|
// _, err = s.repo.DiscordWebHooks.GetById(c.Request().Context(), int64(id))
|
|
|
|
// if err != nil {
|
|
|
|
// return c.JSON(http.StatusInternalServerError, err.Error())
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// // Soft delete the record
|
|
|
|
// updated, err := s.repo.DiscordWebHooks(c.Request().Context(), int64(id))
|
|
|
|
// if err != nil {
|
|
|
|
// return c.JSON(http.StatusInternalServerError, err.Error())
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// _, err = s.Db.GetDiscordQueueByID(c.Request().Context(), uuid)
|
|
|
|
// if err != nil {
|
|
|
|
// return c.JSON(http.StatusInternalServerError, err.Error())
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// return nil
|
|
|
|
//}
|