Add download button in the SharePlayer

This commit is contained in:
Deluan
2023-03-10 23:14:51 -05:00
committed by Deluan Quintão
parent a7d3e6e1f1
commit b520d8827a
6 changed files with 33 additions and 9 deletions
+3
View File
@@ -45,6 +45,9 @@ func checkShareError(ctx context.Context, w http.ResponseWriter, err error, id s
case errors.Is(err, model.ErrNotFound):
log.Error(ctx, "Share not found", "id", id, err)
http.Error(w, "Share not found", http.StatusNotFound)
case errors.Is(err, model.ErrNotAuthorized):
log.Error(ctx, "Share is not downloadable", "id", id, err)
http.Error(w, "This share is not downloadable", http.StatusForbidden)
case err != nil:
log.Error(ctx, "Error retrieving share", "id", id, err)
http.Error(w, "Error retrieving share", http.StatusInternalServerError)
+7 -3
View File
@@ -122,8 +122,10 @@ func getIndexTemplate(r *http.Request, fs fs.FS) (*template.Template, error) {
}
type shareData struct {
Description string `json:"description"`
Tracks []shareTrack `json:"tracks"`
ID string `json:"id"`
Description string `json:"description"`
Downloadable bool `json:"downloadable"`
Tracks []shareTrack `json:"tracks"`
}
type shareTrack struct {
@@ -141,7 +143,9 @@ func addShareData(r *http.Request, data map[string]interface{}, shareInfo *model
return
}
sd := shareData{
Description: shareInfo.Description,
ID: shareInfo.ID,
Description: shareInfo.Description,
Downloadable: shareInfo.Downloadable,
}
sd.Tracks = slice.Map(shareInfo.Tracks, func(mf model.MediaFile) shareTrack {
return shareTrack{