feat: add shared media assets and fix credit lifecycle
This commit is contained in:
@@ -66,6 +66,7 @@ func (a *App) adminCreateRedeemBatch(c *gin.Context) {
|
||||
c.JSON(500, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
a.audit(admin.ID, "redeem.batch.create", "redeem_batch", fmt.Sprint(batch.ID), fmt.Sprintf("credits=%d,count=%d", batch.Credits, batch.Count))
|
||||
c.JSON(201, gin.H{"batch": batch, "codes": codes})
|
||||
}
|
||||
|
||||
@@ -126,6 +127,7 @@ func (a *App) redeem(c *gin.Context) {
|
||||
c.JSON(status, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
a.audit(user.ID, "redeem.use", "redeem_code", "hash:"+hashRedeemCode(in.Code)[:12], fmt.Sprintf("credits=%d", amount))
|
||||
c.JSON(200, gin.H{"credits": amount})
|
||||
}
|
||||
|
||||
@@ -135,6 +137,8 @@ func (a *App) adminRevokeRedeemBatch(c *gin.Context) {
|
||||
c.JSON(500, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
admin := c.MustGet("user").(*User)
|
||||
a.audit(admin.ID, "redeem.batch.revoke", "redeem_batch", id, "unused codes revoked")
|
||||
c.JSON(200, gin.H{"ok": true})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user