2018-10-30 20:24:12 +00:00
|
|
|
package soundtrack
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/aerogo/aero"
|
2019-06-03 09:32:43 +00:00
|
|
|
"github.com/animenotifier/notify.moe/arn"
|
2018-10-30 20:24:12 +00:00
|
|
|
"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 {
|
2018-10-30 20:24:12 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2019-06-05 06:45:54 +00:00
|
|
|
return track.Download()
|
2018-10-30 20:24:12 +00:00
|
|
|
}
|