Editors can now refresh audio downloads
This commit is contained in:
29
pages/soundtrack/download.go
Normal file
29
pages/soundtrack/download.go
Normal file
@ -0,0 +1,29 @@
|
||||
package soundtrack
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
// Download tries to refresh the soundtrack file.
|
||||
func Download(ctx *aero.Context) string {
|
||||
id := ctx.Get("id")
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this soundtrack")
|
||||
}
|
||||
|
||||
track, err := arn.GetSoundTrack(id)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusNotFound, "Track not found", err)
|
||||
}
|
||||
|
||||
track.Download()
|
||||
|
||||
return ""
|
||||
}
|
Reference in New Issue
Block a user