27 lines
588 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"
)
// 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")
2019-11-17 07:59:34 +00:00
user := arn.GetUserFromContext(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)
}
2019-06-05 06:45:54 +00:00
return track.Download()
}