delete endpoint

This commit is contained in:
Sotirios Pupakis
2025-11-20 16:18:52 +01:00
parent ed9489b01a
commit cf26ac4bed
3 changed files with 35 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
port: 8083 port: 8083
ip: "0.0.0.0" ip: "localhost"
secret: "secret" secret: "secret"
db: "crawler.db" db: "crawler.db"
discordWebhook: "https://discord.com/api/webhooks/1413673169792925787/bfbCJ8wiFeKsYkLGCp1U8sr5jOOWDcF0NP9DsHuGXy8NjrfKOncYWJbPnROophTXr-kH" discordWebhook: ""
scraperWebhook: "https://discord.com/api/webhooks/1420535203725840407/4lBMKhp0abqgie_9Mx0uDUERBCuitjfeguleMyq1JJts0JiUmw5GR4VO-A5iGEq7NFV0" scraperWebhook: ""
adminSecret: "123456789" adminSecret: "123456789"

View File

@@ -164,6 +164,37 @@ func SaveIndexingResult(c *gin.Context) {
c.JSON(200, gin.H{"status": "success"}) c.JSON(200, gin.H{"status": "success"})
} }
func DeleteAddon(c *gin.Context) {
guid := c.Query("guid")
if guid == "" {
c.JSON(400, gin.H{"error": "GUID is required"})
return
}
var addon models.Addon
ret := initializers.DB.Where("id = ?", guid).First(&addon)
if ret.Error != nil {
c.JSON(404, gin.H{"error": "Addon not found"})
return
}
// Delete associated files
ret = initializers.DB.Where("addon_id = ?", addon.ID).Delete(&models.AddonFile{})
if ret.Error != nil {
c.JSON(500, gin.H{"error": ret.Error.Error()})
return
}
// Delete the addon
ret = initializers.DB.Delete(&addon)
if ret.Error != nil {
c.JSON(500, gin.H{"error": ret.Error.Error()})
return
}
c.JSON(200, gin.H{"status": "addon deleted"})
}
func checkIndexingTimeout() { func checkIndexingTimeout() {
var addons []models.Addon var addons []models.Addon
initializers.DB.Where("is_being_indexed = ?", true).Find(&addons) initializers.DB.Where("is_being_indexed = ?", true).Find(&addons)

View File

@@ -24,6 +24,7 @@ func main() {
back.POST("/addon", controllers.CheckAllowed, controllers.CreateAddon) back.POST("/addon", controllers.CheckAllowed, controllers.CreateAddon)
back.GET("/nextToBeIndexed", controllers.CheckAllowed, controllers.GetNextToBeIndexed) back.GET("/nextToBeIndexed", controllers.CheckAllowed, controllers.GetNextToBeIndexed)
back.POST("/submitAddon", controllers.CheckAllowed, controllers.SaveIndexingResult) back.POST("/submitAddon", controllers.CheckAllowed, controllers.SaveIndexingResult)
back.DELETE("/deleteAddon", controllers.CheckAllowed, controllers.DeleteAddon)
} }
admin := r.Group("/admin") admin := r.Group("/admin")