Skip to content

Commit

Permalink
Update upload.go
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiloutre committed Oct 11, 2017
1 parent f80bd24 commit ec9bfac
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions controllers/upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,30 @@ func UploadPostHandler(c *gin.Context) {
}

AnidexUpload := false
NyaaSiUpload := false
TokyoToshoUpload := false

if c.PostForm("anidex_api") != "" || c.PostForm("anidex_upload") != "" {
AnidexUpload = true
}
if c.PostForm("nyaasi_api") != "" || c.PostForm("nyaasi_upload") != "" {
NyaaSiUpload = true
}
if c.PostForm("tokyot_api") != "" || c.PostForm("tokyot_upload") != "" {
TokyoToshoUpload = true
}

if !messages.HasErrors() {
// add to db and redirect
torrent, err := torrents.Create(user, &uploadForm)
log.CheckErrorWithMessage(err, "ERROR_TORRENT_CREATED: Error while creating entry in db")

if AnidexUpload || c.PostForm("nyaasi_api") != "" || c.PostForm("tokyot_api") != "" {
if AnidexUpload || NyaaSiUpload || TokyoToshoUpload {
//User wants to upload to other websites too
uploadMultiple := templates.NewUploadMultipleForm()
uploadMultiple.PantsuID = torrent.ID

if c.PostForm("anidex_api") != "" || user.AnidexAPIToken != "" {
if AnidexUpload {
uploadMultiple.AnidexStatus = 1

langId := "0"
Expand All @@ -94,6 +102,7 @@ func UploadPostHandler(c *gin.Context) {

if c.PostForm("anidex_api") == "" {
anonymous = true
apiKey = "XXX"
}

postForm := url.Values{}
Expand Down Expand Up @@ -130,20 +139,20 @@ func UploadPostHandler(c *gin.Context) {
body_byte, err := ioutil.ReadAll(rsp.Body)
if err != nil {
uploadMultiple.AnidexStatus = 2
uploadMultiple.AnidexMessage = "Error"
uploadMultiple.AnidexMessage = "Unknown error"
}
if uploadMultiple.AnidexStatus == 1 {
uploadMultiple.AnidexMessage = string(body_byte)
uploadMultiple.AnidexStatus = 3
}
}

if c.PostForm("nyaasi_api") != "" {
if NyaaSiUpload {
uploadMultiple.NyaasiStatus = 1
uploadMultiple.NyaasiMessage = "Sorry u are not allowed"
}

if c.PostForm("tokyot_api") != "" {
if TokyoToshoUpload {
uploadMultiple.TToshoStatus = 1
}

Expand Down

0 comments on commit ec9bfac

Please sign in to comment.