gitea, notion webhook
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

39 lines
1.2 KiB

package server
import (
"log/slog"
"net/http"
"strings"
"github.com/gin-gonic/gin"
)
func (s *Server) adminMappings(c *gin.Context) {
c.HTML(http.StatusOK, "mappings.html", gin.H{"Mappings": s.mappings.List()})
}
func (s *Server) adminAddMapping(c *gin.Context) {
source := strings.TrimSpace(c.PostForm("source"))
slackEmail := strings.TrimSpace(c.PostForm("slack_email"))
if source == "" || slackEmail == "" {
c.String(http.StatusBadRequest, "source and slack_email are required")
return
}
if err := s.mappings.Add(source, slackEmail); err != nil {
slog.Error("add mapping failed", "source", source, "err", err)
c.String(http.StatusInternalServerError, "failed to save")
return
}
// Return the refreshed table partial (HTMX swaps it in).
c.HTML(http.StatusOK, "table", gin.H{"Mappings": s.mappings.List()})
}
func (s *Server) adminDeleteMapping(c *gin.Context) {
source := c.Param("source")
if err := s.mappings.Delete(source); err != nil {
slog.Error("delete mapping failed", "source", source, "err", err)
c.String(http.StatusInternalServerError, "failed to delete")
return
}
c.HTML(http.StatusOK, "table", gin.H{"Mappings": s.mappings.List()})
}