Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Merge branch 'master' of github.com:ewhal/nyaa into api

Cette révision appartient à :
ayame-git 2017-05-11 06:06:12 +03:00
révision 7e3d116808
2 fichiers modifiés avec 25 ajouts et 18 suppressions

Voir le fichier

@ -39,6 +39,9 @@ func UploadHandler(w http.ResponseWriter, r *http.Request) {
} else if user.Status == 1 {
status = 3 // mark as trusted if user is trusted
}
var sameTorrents int
db.ORM.Model(&model.Torrent{}).Where("torrent_hash = ?", uploadForm.Infohash).Count(&sameTorrents)
if (sameTorrents == 0) {
//add to db and redirect depending on result
torrent := model.Torrent{
Name: uploadForm.Name,
@ -58,6 +61,10 @@ func UploadHandler(w http.ResponseWriter, r *http.Request) {
return
}
http.Redirect(w, r, url.String(), 302)
} else {
http.Error(w, fmt.Errorf("Torrent already in database!").Error(), http.StatusInternalServerError)
return
}
} else if r.Method == "GET" {
uploadForm.CaptchaID = captcha.GetID()
htv := UploadTemplateVariables{uploadForm, NewSearchForm(), Navigation{}, GetUser(r), r.URL, mux.CurrentRoute(r)}

Voir le fichier

@ -94,7 +94,7 @@
{{end}}
</div>
<div class="col-md-2">
{{.CreatedAt.Year}}/{{.CreatedAt.Month}}/{{.CreatedAt.Day}}
{{.Date.Year}}/{{.Date.Month}}/{{.Date.Day}}
</div>
<div class="col-md-8">
{{.Content}}