|
|
|
@ -81,6 +81,7 @@ func (ctrl UploadCtrl) New(c *gin.Context) {
|
|
|
|
|
|
|
|
|
|
// Set the uploadId as last upload for session
|
|
|
|
|
session.Set(SessLastUploadName, uploadId)
|
|
|
|
|
//session.AddFlash(SessLastUploadName, uploadId)
|
|
|
|
|
session.Save()
|
|
|
|
|
|
|
|
|
|
// If not free upload generate a an invoice
|
|
|
|
@ -94,6 +95,13 @@ func (ctrl UploadCtrl) New(c *gin.Context) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Save the secret admin token
|
|
|
|
|
err = SetUploadAdminToken(uploadId, invoice.PreImage)
|
|
|
|
|
if err != nil {
|
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update Upload Invoice
|
|
|
|
|
err = SetUploadInvoice(uploadId, invoice)
|
|
|
|
|
if err != nil {
|
|
|
|
@ -263,10 +271,23 @@ func (ctrl UploadCtrl) PollStatus(c *gin.Context) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// get the secret admin token
|
|
|
|
|
token, err := GetUploadAdminToken(uploadId)
|
|
|
|
|
if err != nil {
|
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Clear the session
|
|
|
|
|
session := sessions.Default(c)
|
|
|
|
|
session.Clear()
|
|
|
|
|
session.Save()
|
|
|
|
|
|
|
|
|
|
// invoice was paid
|
|
|
|
|
c.JSON(http.StatusAccepted, gin.H{
|
|
|
|
|
"status": uploadStatus,
|
|
|
|
|
"invoice": invoice,
|
|
|
|
|
"admin_token": token,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
@ -421,8 +442,8 @@ func (ctrl UploadCtrl) Upload(c *gin.Context) {
|
|
|
|
|
|
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
|
|
|
"status": http.StatusOK,
|
|
|
|
|
"result": "uploaded",
|
|
|
|
|
"store_status": UpStored,
|
|
|
|
|
"upload_id": uploadId,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|