Skip to content

🎧 Your Personal Streaming Service

Disable share downloading when `EnableDownloads` is false.

Deluan377e7ebd5230
diff --git a/server/public/public.go b/server/public/public.go
index 3c43dbffe..5ead6b320 100644
--- a/server/public/public.go
+++ b/server/public/public.go
@@ -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)
diff --git a/ui/src/dialogs/ShareDialog.js b/ui/src/dialogs/ShareDialog.js
index fc877234d..b88754a8d 100644
--- a/ui/src/dialogs/ShareDialog.js
+++ b/ui/src/dialogs/ShareDialog.js
@@ -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')}
diff --git a/ui/src/share/ShareEdit.js b/ui/src/share/ShareEdit.js
index 208b91366..91a7b11dc 100644
--- a/ui/src/share/ShareEdit.js
+++ b/ui/src/share/ShareEdit.js
@@ -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 />
diff --git a/ui/src/share/ShareList.js b/ui/src/share/ShareList.js
index 8b8f235e9..0219e49db 100644
--- a/ui/src/share/ShareList.js
+++ b/ui/src/share/ShareList.js
@@ -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'} />
diff --git a/ui/src/share/SharePlayer.js b/ui/src/share/SharePlayer.js
index 387b6fcd4..38493d3ce 100644
--- a/ui/src/share/SharePlayer.js
+++ b/ui/src/share/SharePlayer.js
@@ -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',