2024-04-23 07:15:38 -07:00
|
|
|
package v1
|
2023-01-22 10:12:55 -08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2024-04-23 22:18:07 -07:00
|
|
|
"git.jamestombleson.com/jtom38/newsbot-api/internal/domain"
|
2024-04-23 07:15:38 -07:00
|
|
|
"git.jamestombleson.com/jtom38/newsbot-api/internal/domain/models"
|
2024-04-23 22:18:07 -07:00
|
|
|
"github.com/labstack/echo/v4"
|
2023-01-22 10:12:55 -08:00
|
|
|
)
|
|
|
|
|
2023-01-31 08:19:23 -08:00
|
|
|
type ListDiscordWebHooksQueueResults struct {
|
|
|
|
ApiStatusModel
|
|
|
|
Payload []models.DiscordQueueDetailsDto `json:"payload"`
|
|
|
|
}
|
|
|
|
|
2023-01-22 10:12:55 -08:00
|
|
|
// GetDiscordQueue
|
|
|
|
// @Summary Returns the top 100 entries from the queue to be processed.
|
|
|
|
// @Produce application/json
|
|
|
|
// @Tags Queue
|
|
|
|
// @Router /queue/discord/webhooks [get]
|
|
|
|
// @Success 200 {object} ListDiscordWebHooksQueueResults "ok"
|
2024-04-23 22:18:07 -07:00
|
|
|
func (s *Handler) ListDiscordWebhookQueue(c echo.Context) error {
|
2023-01-22 10:12:55 -08:00
|
|
|
p := ListDiscordWebHooksQueueResults{
|
|
|
|
ApiStatusModel: ApiStatusModel{
|
|
|
|
Message: "OK",
|
|
|
|
StatusCode: http.StatusOK,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the raw resp from sql
|
2024-04-23 22:18:07 -07:00
|
|
|
res, err := s.dto.ListDiscordWebhookQueueDetails(c.Request().Context(), 50)
|
2023-01-22 10:12:55 -08:00
|
|
|
if err != nil {
|
2024-04-28 11:41:34 -07:00
|
|
|
return c.JSON(http.StatusInternalServerError, domain.BaseResponse{
|
2024-04-23 22:18:07 -07:00
|
|
|
Message: err.Error(),
|
|
|
|
})
|
2023-01-22 10:12:55 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
p.Payload = res
|
2024-04-23 22:18:07 -07:00
|
|
|
return c.JSON(http.StatusOK, p)
|
2023-01-22 10:12:55 -08:00
|
|
|
}
|