29 lines
629 B
Go
Raw Normal View History

package soundtrack
import (
"net/http"
"github.com/aerogo/aero"
2019-06-03 09:32:43 +00:00
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/utils"
)
// Download tries to refresh the soundtrack file.
2019-06-01 04:55:49 +00:00
func Download(ctx aero.Context) error {
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()
2019-06-01 04:55:49 +00:00
return nil
}