- Binary name: imc-vibe -> imc - Go module: github.com/imc-vibe/backend -> github.com/imc/backend - JWT issuer: imc-vibe -> imc - UI labels: IMC Vibe -> IMC - Update all imports and comments
46 lines
943 B
Go
46 lines
943 B
Go
package handlers
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/imc/backend/internal/mail"
|
|
)
|
|
|
|
type QueueHandler struct{}
|
|
|
|
func NewQueueHandler() *QueueHandler {
|
|
return &QueueHandler{}
|
|
}
|
|
|
|
func (h *QueueHandler) List(c *gin.Context) {
|
|
entries, err := mail.GetQueue()
|
|
if err != nil {
|
|
log.Printf("Queue error: %v", err)
|
|
Error(c, http.StatusServiceUnavailable, "failed to get queue: "+err.Error())
|
|
return
|
|
}
|
|
|
|
Success(c, entries)
|
|
}
|
|
|
|
func (h *QueueHandler) Requeue(c *gin.Context) {
|
|
id := c.Param("id")
|
|
if err := mail.RequeueMail(id); err != nil {
|
|
Error(c, http.StatusInternalServerError, "failed to requeue mail")
|
|
return
|
|
}
|
|
|
|
Success(c, map[string]string{"message": "mail requeued"})
|
|
}
|
|
|
|
func (h *QueueHandler) Delete(c *gin.Context) {
|
|
id := c.Param("id")
|
|
if err := mail.DeleteFromQueue(id); err != nil {
|
|
Error(c, http.StatusInternalServerError, "failed to delete from queue")
|
|
return
|
|
}
|
|
|
|
NoContent(c)
|
|
}
|