Changeset 0.22.7 (#149)
This commit is contained in:
@@ -164,10 +164,10 @@ func bilinearMix(c00, c10, c01, c11 color.Color, xf, yf float64) color.Color {
|
||||
}
|
||||
}
|
||||
|
||||
// ── Preset Avatar Upload ────────────────────
|
||||
// POST /api/v1/presets/:id/avatar (user) or /api/v1/admin/presets/:id/avatar (admin)
|
||||
func UploadPresetAvatar(c *gin.Context) {
|
||||
presetID := c.Param("id")
|
||||
// ── Persona Avatar Upload ────────────────────
|
||||
// POST /api/v1/personas/:id/avatar (user) or /api/v1/admin/personas/:id/avatar (admin)
|
||||
func UploadPersonaAvatar(c *gin.Context) {
|
||||
personaID := c.Param("id")
|
||||
|
||||
var req uploadAvatarRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
@@ -208,7 +208,7 @@ func UploadPresetAvatar(c *gin.Context) {
|
||||
|
||||
result, err := database.DB.Exec(
|
||||
database.Q(`UPDATE personas SET avatar = $1, updated_at = NOW() WHERE id = $2`),
|
||||
dataURI, presetID,
|
||||
dataURI, personaID,
|
||||
)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to save avatar"})
|
||||
@@ -216,20 +216,20 @@ func UploadPresetAvatar(c *gin.Context) {
|
||||
}
|
||||
rows, _ := result.RowsAffected()
|
||||
if rows == 0 {
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "preset not found"})
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "persona not found"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"avatar": dataURI})
|
||||
}
|
||||
|
||||
// DeletePresetAvatar clears a preset's avatar.
|
||||
func DeletePresetAvatar(c *gin.Context) {
|
||||
presetID := c.Param("id")
|
||||
// DeletePersonaAvatar clears a persona's avatar.
|
||||
func DeletePersonaAvatar(c *gin.Context) {
|
||||
personaID := c.Param("id")
|
||||
|
||||
result, err := database.DB.Exec(
|
||||
database.Q(`UPDATE personas SET avatar = '', updated_at = NOW() WHERE id = $1`),
|
||||
presetID,
|
||||
personaID,
|
||||
)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to remove avatar"})
|
||||
@@ -237,7 +237,7 @@ func DeletePresetAvatar(c *gin.Context) {
|
||||
}
|
||||
rows, _ := result.RowsAffected()
|
||||
if rows == 0 {
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "preset not found"})
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "persona not found"})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user