- rename Go module, binary, systemd unit, PG_DATABASE default, frontend package and docs from shared-album to galo - add theme-aware halo emblem and favicon (new ui-branding capability) - add make build-release (versioned, stripped, static binary) and run the binary from the repo root
36 lines
736 B
Go
36 lines
736 B
Go
package notifications
|
|
|
|
import (
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"galo/internal/auth"
|
|
"galo/internal/httpx"
|
|
)
|
|
|
|
type Handler struct {
|
|
svc *Service
|
|
}
|
|
|
|
func NewHandler(svc *Service) *Handler { return &Handler{svc: svc} }
|
|
|
|
func (h *Handler) List(c *gin.Context) {
|
|
limit, _ := strconv.Atoi(c.DefaultQuery("limit", "100"))
|
|
list, err := h.svc.List(c.Request.Context(), auth.UserID(c), limit)
|
|
if err != nil {
|
|
httpx.RespondError(c, err)
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{"notifications": list})
|
|
}
|
|
|
|
func (h *Handler) MarkRead(c *gin.Context) {
|
|
if err := h.svc.MarkRead(c.Request.Context(), c.Param("id"), auth.UserID(c)); err != nil {
|
|
httpx.RespondError(c, err)
|
|
return
|
|
}
|
|
c.Status(http.StatusNoContent)
|
|
}
|