refactor: rename EnableCoverArtUpload to EnableArtworkUpload
The config flag gates all image uploads (artists, radios, playlists), not just cover art. Rename it to accurately reflect its scope across the backend config, native API permission check, Subsonic CoverArtRole, serve_index JSON key, and frontend config.
This commit is contained in:
@@ -78,7 +78,7 @@ type configOptions struct {
|
|||||||
EnableFavourites bool
|
EnableFavourites bool
|
||||||
EnableStarRating bool
|
EnableStarRating bool
|
||||||
EnableUserEditing bool
|
EnableUserEditing bool
|
||||||
EnableCoverArtUpload bool
|
EnableArtworkUpload bool
|
||||||
EnableSharing bool
|
EnableSharing bool
|
||||||
ShareURL string
|
ShareURL string
|
||||||
DefaultShareExpiration time.Duration
|
DefaultShareExpiration time.Duration
|
||||||
@@ -689,7 +689,7 @@ func setViperDefaults() {
|
|||||||
viper.SetDefault("enablereplaygain", true)
|
viper.SetDefault("enablereplaygain", true)
|
||||||
viper.SetDefault("enablecoveranimation", true)
|
viper.SetDefault("enablecoveranimation", true)
|
||||||
viper.SetDefault("enablenowplaying", true)
|
viper.SetDefault("enablenowplaying", true)
|
||||||
viper.SetDefault("enablecoverartupload", true)
|
viper.SetDefault("enableartworkupload", true)
|
||||||
viper.SetDefault("enablesharing", false)
|
viper.SetDefault("enablesharing", false)
|
||||||
viper.SetDefault("shareurl", "")
|
viper.SetDefault("shareurl", "")
|
||||||
viper.SetDefault("defaultshareexpiration", 8760*time.Hour)
|
viper.SetDefault("defaultshareexpiration", 8760*time.Hour)
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ const maxImageSize = 10 << 20 // 10MB
|
|||||||
|
|
||||||
func checkImageUploadPermission(w http.ResponseWriter, r *http.Request) bool {
|
func checkImageUploadPermission(w http.ResponseWriter, r *http.Request) bool {
|
||||||
user, _ := request.UserFrom(r.Context())
|
user, _ := request.UserFrom(r.Context())
|
||||||
if !conf.Server.EnableCoverArtUpload && !user.IsAdmin {
|
if !conf.Server.EnableArtworkUpload && !user.IsAdmin {
|
||||||
http.Error(w, "cover art upload is disabled", http.StatusForbidden)
|
http.Error(w, "artwork upload is disabled", http.StatusForbidden)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ var _ = Describe("Playlist Image Endpoints", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
DescribeTable("uploadPlaylistImage guard",
|
DescribeTable("uploadPlaylistImage guard",
|
||||||
func(enableCoverArtUpload, isAdmin bool, expectedStatus int) {
|
func(enableArtworkUpload, isAdmin bool, expectedStatus int) {
|
||||||
conf.Server.EnableCoverArtUpload = enableCoverArtUpload
|
conf.Server.EnableArtworkUpload = enableArtworkUpload
|
||||||
handler := uploadPlaylistImage(&mockPlaylistsService{})
|
handler := uploadPlaylistImage(&mockPlaylistsService{})
|
||||||
|
|
||||||
req := httptest.NewRequest("POST", "/playlist/pls-1/image", nil)
|
req := httptest.NewRequest("POST", "/playlist/pls-1/image", nil)
|
||||||
@@ -47,8 +47,8 @@ var _ = Describe("Playlist Image Endpoints", func() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
DescribeTable("deletePlaylistImage guard",
|
DescribeTable("deletePlaylistImage guard",
|
||||||
func(enableCoverArtUpload, isAdmin bool, expectedStatus int) {
|
func(enableArtworkUpload, isAdmin bool, expectedStatus int) {
|
||||||
conf.Server.EnableCoverArtUpload = enableCoverArtUpload
|
conf.Server.EnableArtworkUpload = enableArtworkUpload
|
||||||
handler := deletePlaylistImage(&mockPlaylistsService{})
|
handler := deletePlaylistImage(&mockPlaylistsService{})
|
||||||
|
|
||||||
req := httptest.NewRequest("DELETE", "/playlist/pls-1/image", nil)
|
req := httptest.NewRequest("DELETE", "/playlist/pls-1/image", nil)
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ func serveIndex(ds model.DataStore, fs fs.FS, shareInfo *model.Share) http.Handl
|
|||||||
"losslessFormats": strings.ToUpper(strings.Join(mime.LosslessFormats, ",")),
|
"losslessFormats": strings.ToUpper(strings.Join(mime.LosslessFormats, ",")),
|
||||||
"devActivityPanel": conf.Server.DevActivityPanel,
|
"devActivityPanel": conf.Server.DevActivityPanel,
|
||||||
"enableUserEditing": conf.Server.EnableUserEditing,
|
"enableUserEditing": conf.Server.EnableUserEditing,
|
||||||
"enableCoverArtUpload": conf.Server.EnableCoverArtUpload,
|
"enableArtworkUpload": conf.Server.EnableArtworkUpload,
|
||||||
"enableSharing": conf.Server.EnableSharing,
|
"enableSharing": conf.Server.EnableSharing,
|
||||||
"shareURL": conf.Server.ShareURL,
|
"shareURL": conf.Server.ShareURL,
|
||||||
"defaultDownloadableShare": conf.Server.DefaultDownloadableShare,
|
"defaultDownloadableShare": conf.Server.DefaultDownloadableShare,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ func buildUserResponse(user model.User) responses.User {
|
|||||||
ScrobblingEnabled: true,
|
ScrobblingEnabled: true,
|
||||||
DownloadRole: conf.Server.EnableDownloads,
|
DownloadRole: conf.Server.EnableDownloads,
|
||||||
ShareRole: conf.Server.EnableSharing,
|
ShareRole: conf.Server.EnableSharing,
|
||||||
CoverArtRole: conf.Server.EnableCoverArtUpload || user.IsAdmin,
|
CoverArtRole: conf.Server.EnableArtworkUpload || user.IsAdmin,
|
||||||
Folder: slice.Map(user.Libraries, func(lib model.Library) int32 { return int32(lib.ID) }),
|
Folder: slice.Map(user.Libraries, func(lib model.Library) int32 { return int32(lib.ID) }),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,8 +105,8 @@ var _ = Describe("Users", func() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
DescribeTable("CoverArt role permissions",
|
DescribeTable("CoverArt role permissions",
|
||||||
func(enableCoverArtUpload, isAdmin, expectedCoverArtRole bool) {
|
func(enableArtworkUpload, isAdmin, expectedCoverArtRole bool) {
|
||||||
conf.Server.EnableCoverArtUpload = enableCoverArtUpload
|
conf.Server.EnableArtworkUpload = enableArtworkUpload
|
||||||
testUser.IsAdmin = isAdmin
|
testUser.IsAdmin = isAdmin
|
||||||
|
|
||||||
response := buildUserResponse(testUser)
|
response := buildUserResponse(testUser)
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export const ImageUploadOverlay = ({
|
|||||||
const fileInputRef = useRef(null)
|
const fileInputRef = useRef(null)
|
||||||
|
|
||||||
const canEdit =
|
const canEdit =
|
||||||
config.enableCoverArtUpload || localStorage.getItem('role') === 'admin'
|
config.enableArtworkUpload || localStorage.getItem('role') === 'admin'
|
||||||
|
|
||||||
const handleUploadClick = useCallback((e) => {
|
const handleUploadClick = useCallback((e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ const defaultConfig = {
|
|||||||
defaultUIVolume: 100,
|
defaultUIVolume: 100,
|
||||||
uiSearchDebounceMs: 200,
|
uiSearchDebounceMs: 200,
|
||||||
enableUserEditing: true,
|
enableUserEditing: true,
|
||||||
enableCoverArtUpload: true,
|
enableArtworkUpload: true,
|
||||||
enableSharing: true,
|
enableSharing: true,
|
||||||
shareURL: '',
|
shareURL: '',
|
||||||
defaultDownloadableShare: true,
|
defaultDownloadableShare: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user