27 lines
588 B
Go
Raw Normal View History

package soundtrack
import (
"net/http"
"github.com/aerogo/aero"
2019-06-03 18:32:43 +09:00
"github.com/animenotifier/notify.moe/arn"
)
// Download tries to refresh the soundtrack file.
2019-06-01 13:55:49 +09:00
func Download(ctx aero.Context) error {
id := ctx.Get("id")
2019-11-17 16:59:34 +09: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 15:45:54 +09:00
return track.Download()
}