All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 4m44s
- Fix auth bypass in UpdatePost/DeletePost (missing return after auth check) - Remove Spotify access token from callback response - Replace internal error messages with generic responses in all handlers - Harden GraphQL: complexity limit, disable playground/introspection in prod - Add security headers (X-Frame-Options, HSTS, etc.) to nginx - Disable Hasura console/dev mode in production - Add DOMPurify sanitization to Markdown component - Fix cookie removal to use correct domain/path from auth config - Fix nil dereference in rowing handler when Claude API errors - Fix wildcard CORS on stamp endpoint - Pin nginx and certbot Docker image versions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package handlers
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
|
|
"adam-french.co.uk/backend/models"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type CreateActivityInput struct {
|
|
Type string `json:"type" binding:"required"`
|
|
Name string `json:"name" binding:"required"`
|
|
Link *string `json:"link"`
|
|
}
|
|
|
|
func (store *Store) GetActivity(ctx *gin.Context) {
|
|
var activitys []models.Activity
|
|
if err := store.DB.Order("Created_At DESC").Find(&activitys).Error; err != nil {
|
|
log.Println(err)
|
|
ctx.JSON(http.StatusInternalServerError, gin.H{"error": "internal error"})
|
|
return
|
|
}
|
|
ctx.JSON(http.StatusOK, activitys)
|
|
}
|
|
|
|
func (store *Store) CreateActivity(ctx *gin.Context) {
|
|
var input CreateActivityInput
|
|
if err := ctx.ShouldBindBodyWithJSON(&input); err != nil {
|
|
ctx.JSON(http.StatusBadRequest, gin.H{"error": "invalid request body"})
|
|
return
|
|
}
|
|
|
|
activity := models.Activity{Type: input.Type, Name: input.Name, Link: input.Link}
|
|
tx := store.DB.Create(&activity)
|
|
if tx.Error != nil {
|
|
log.Println(tx.Error)
|
|
ctx.JSON(http.StatusInternalServerError, gin.H{"error": "internal error"})
|
|
return
|
|
}
|
|
|
|
ctx.JSON(http.StatusCreated, activity)
|
|
}
|