Disable share downloading when `EnableDownloads` is false.

Fixes https://github.com/navidrome/navidrome/pull/2246#issuecomment-1472341635
This commit is contained in:
Deluan 2023-03-16 13:11:26 -04:00
parent 23c483da10
commit 377e7ebd52
5 changed files with 19 additions and 14 deletions

View File

@ -52,7 +52,9 @@ func (p *Router) routes() http.Handler {
})
if conf.Server.EnableSharing {
r.HandleFunc("/s/{id}", p.handleStream)
r.HandleFunc("/d/{id}", p.handleDownloads)
if conf.Server.EnableDownloads {
r.HandleFunc("/d/{id}", p.handleDownloads)
}
r.HandleFunc("/{id}", p.handleShares)
r.HandleFunc("/", p.handleShares)
r.Handle("/*", p.assetsHandler)

View File

@ -33,7 +33,7 @@ export const ShareDialog = () => {
const translate = useTranslate()
const [description, setDescription] = useState('')
const [downloadable, setDownloadable] = useState(
config.defaultDownloadableShare
config.defaultDownloadableShare && config.enableDownloads
)
useEffect(() => {
setDescription('')
@ -118,14 +118,16 @@ export const ShareDialog = () => {
setDescription(event.target.value)
}}
/>
<BooleanInput
resource={'share'}
source={'downloadable'}
defaultValue={downloadable}
onChange={(value) => {
setDownloadable(value)
}}
/>
{config.enableDownloads && (
<BooleanInput
resource={'share'}
source={'downloadable'}
defaultValue={downloadable}
onChange={(value) => {
setDownloadable(value)
}}
/>
)}
<TranscodingOptionsInput
fullWidth
label={translate('message.shareOriginalFormat')}

View File

@ -9,6 +9,7 @@ import {
import { shareUrl } from '../utils'
import { Link } from '@material-ui/core'
import { DateField } from '../common'
import config from '../config'
export const ShareEdit = (props) => {
const { id, basePath, hasCreate, ...rest } = props
@ -20,7 +21,7 @@ export const ShareEdit = (props) => {
{url}
</Link>
<TextInput source="description" />
<BooleanInput source="downloadable" />
{config.enableDownloads && <BooleanInput source="downloadable" />}
<DateTimeInput source="expiresAt" />
<TextInput source="contents" disabled />
<TextInput source="format" disabled />

View File

@ -105,7 +105,7 @@ const ShareList = (props) => {
<TextField source="description" />
{isDesktop && <TextField source="contents" />}
{isDesktop && <FormatInfo source="format" />}
<BooleanField source="downloadable" />
{config.enableDownloads && <BooleanField source="downloadable" />}
<NumberField source="visitCount" />
{isDesktop && (
<DateField source="lastVisitedAt" showTime sortByOrder={'DESC'} />

View File

@ -1,5 +1,5 @@
import ReactJkMusicPlayer from 'navidrome-music-player'
import { shareInfo } from '../config'
import config, { shareInfo } from '../config'
import { shareCoverUrl, shareDownloadUrl, shareStreamUrl } from '../utils'
import { makeStyles } from '@material-ui/core/styles'
@ -44,7 +44,7 @@ const SharePlayer = () => {
mode: 'full',
toggleMode: false,
mobileMediaQuery: '',
showDownload: shareInfo?.downloadable,
showDownload: shareInfo?.downloadable && config.enableDownloads,
showReload: false,
showMediaSession: true,
theme: 'auto',