Files
project-gifuu/backend/routes/DELETE_Moderation_Art_ID.go
T
2026-05-23 17:17:56 -07:00

35 lines
647 B
Go

package routes
import (
"gifuu/tools"
"net/http"
)
func DELETE_Moderation_Art_ID(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
paramID := tools.ParseSnowflake(r.PathValue("id"))
if paramID == 0 {
tools.SendClientError(w, r, tools.ERROR_BODY_INVALID_FIELD)
return
}
// Delete Art
tag, err := tools.Database.Exec(ctx,
`DELETE FROM gifuu.upload WHERE id = $1`,
paramID,
)
if err != nil {
tools.SendServerError(w, r, err)
return
}
if tag.RowsAffected() == 0 {
tools.SendClientError(w, r, tools.ERROR_GENERIC_UNAUTHORIZED)
return
}
go RemoveFilesForArt(paramID)
w.WriteHeader(http.StatusNoContent)
}