kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
Merge branch '808-supported-mimetypes' into 'develop'
Fix #808: Advertise the list of supported upload extensions in the Nodeinfo endpoint Closes #808 See merge request funkwhale/funkwhale!748merge-requests/757/head
commit
9d09e9f83c
|
@ -3,6 +3,7 @@ import memoize.djangocache
|
||||||
import funkwhale_api
|
import funkwhale_api
|
||||||
from funkwhale_api.common import preferences
|
from funkwhale_api.common import preferences
|
||||||
from funkwhale_api.federation import actors
|
from funkwhale_api.federation import actors
|
||||||
|
from funkwhale_api.music import utils as music_utils
|
||||||
|
|
||||||
from . import stats
|
from . import stats
|
||||||
|
|
||||||
|
@ -34,6 +35,7 @@ def get():
|
||||||
"common__api_authentication_required"
|
"common__api_authentication_required"
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
"supportedUploadExtensions": music_utils.SUPPORTED_EXTENSIONS,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if share_stats:
|
if share_stats:
|
||||||
|
|
|
@ -39,6 +39,10 @@ AUDIO_EXTENSIONS_AND_MIMETYPE = [
|
||||||
EXTENSION_TO_MIMETYPE = {ext: mt for ext, mt in AUDIO_EXTENSIONS_AND_MIMETYPE}
|
EXTENSION_TO_MIMETYPE = {ext: mt for ext, mt in AUDIO_EXTENSIONS_AND_MIMETYPE}
|
||||||
MIMETYPE_TO_EXTENSION = {mt: ext for ext, mt in AUDIO_EXTENSIONS_AND_MIMETYPE}
|
MIMETYPE_TO_EXTENSION = {mt: ext for ext, mt in AUDIO_EXTENSIONS_AND_MIMETYPE}
|
||||||
|
|
||||||
|
SUPPORTED_EXTENSIONS = list(
|
||||||
|
sorted(set([ext for ext, _ in AUDIO_EXTENSIONS_AND_MIMETYPE]))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_ext_from_type(mimetype):
|
def get_ext_from_type(mimetype):
|
||||||
return MIMETYPE_TO_EXTENSION.get(mimetype)
|
return MIMETYPE_TO_EXTENSION.get(mimetype)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import funkwhale_api
|
import funkwhale_api
|
||||||
from funkwhale_api.instance import nodeinfo
|
from funkwhale_api.instance import nodeinfo
|
||||||
from funkwhale_api.federation import actors
|
from funkwhale_api.federation import actors
|
||||||
|
from funkwhale_api.music import utils as music_utils
|
||||||
|
|
||||||
|
|
||||||
def test_nodeinfo_dump(preferences, mocker):
|
def test_nodeinfo_dump(preferences, mocker):
|
||||||
|
@ -46,6 +47,7 @@ def test_nodeinfo_dump(preferences, mocker):
|
||||||
"favorites": {"tracks": {"total": stats["track_favorites"]}},
|
"favorites": {"tracks": {"total": stats["track_favorites"]}},
|
||||||
"listenings": {"total": stats["listenings"]},
|
"listenings": {"total": stats["listenings"]},
|
||||||
},
|
},
|
||||||
|
"supportedUploadExtensions": music_utils.SUPPORTED_EXTENSIONS,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
assert nodeinfo.get() == expected
|
assert nodeinfo.get() == expected
|
||||||
|
@ -76,6 +78,7 @@ def test_nodeinfo_dump_stats_disabled(preferences, mocker):
|
||||||
"common__api_authentication_required"
|
"common__api_authentication_required"
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
"supportedUploadExtensions": music_utils.SUPPORTED_EXTENSIONS,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
assert nodeinfo.get() == expected
|
assert nodeinfo.get() == expected
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Advertise the list of supported upload extensions in the Nodeinfo endpoint (#808)
|
Ładowanie…
Reference in New Issue