Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
funkwhale
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zwordi
funkwhale
Commits
581e890a
Verified
Commit
581e890a
authored
5 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
See #853: advertise allow-list configuration in nodeinfo
parent
38a8e998
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/funkwhale_api/instance/nodeinfo.py
+12
-1
12 additions, 1 deletion
api/funkwhale_api/instance/nodeinfo.py
api/tests/instance/test_nodeinfo.py
+22
-0
22 additions, 0 deletions
api/tests/instance/test_nodeinfo.py
with
34 additions
and
1 deletion
api/funkwhale_api/instance/nodeinfo.py
+
12
−
1
View file @
581e890a
...
...
@@ -2,7 +2,7 @@ import memoize.djangocache
import
funkwhale_api
from
funkwhale_api.common
import
preferences
from
funkwhale_api.federation
import
actors
from
funkwhale_api.federation
import
actors
,
models
as
federation_models
from
funkwhale_api.music
import
utils
as
music_utils
from
.
import
stats
...
...
@@ -13,6 +13,16 @@ memo = memoize.Memoizer(store, namespace="instance:stats")
def
get
():
share_stats
=
preferences
.
get
(
"
instance__nodeinfo_stats_enabled
"
)
allow_list_enabled
=
preferences
.
get
(
"
moderation__allow_list_enabled
"
)
allow_list_public
=
preferences
.
get
(
"
moderation__allow_list_public
"
)
if
allow_list_enabled
and
allow_list_public
:
allowed_domains
=
list
(
federation_models
.
Domain
.
objects
.
filter
(
allowed
=
True
)
.
order_by
(
"
name
"
)
.
values_list
(
"
name
"
,
flat
=
True
)
)
else
:
allowed_domains
=
None
data
=
{
"
version
"
:
"
2.0
"
,
"
software
"
:
{
"
name
"
:
"
funkwhale
"
,
"
version
"
:
funkwhale_api
.
__version__
},
...
...
@@ -36,6 +46,7 @@ def get():
),
},
"
supportedUploadExtensions
"
:
music_utils
.
SUPPORTED_EXTENSIONS
,
"
allowList
"
:
{
"
enabled
"
:
allow_list_enabled
,
"
domains
"
:
allowed_domains
},
},
}
if
share_stats
:
...
...
This diff is collapsed.
Click to expand it.
api/tests/instance/test_nodeinfo.py
+
22
−
0
View file @
581e890a
import
pytest
import
funkwhale_api
from
funkwhale_api.instance
import
nodeinfo
from
funkwhale_api.federation
import
actors
...
...
@@ -48,6 +50,7 @@ def test_nodeinfo_dump(preferences, mocker):
"
listenings
"
:
{
"
total
"
:
stats
[
"
listenings
"
]},
},
"
supportedUploadExtensions
"
:
music_utils
.
SUPPORTED_EXTENSIONS
,
"
allowList
"
:
{
"
enabled
"
:
False
,
"
domains
"
:
None
},
},
}
assert
nodeinfo
.
get
()
==
expected
...
...
@@ -79,6 +82,25 @@ def test_nodeinfo_dump_stats_disabled(preferences, mocker):
],
},
"
supportedUploadExtensions
"
:
music_utils
.
SUPPORTED_EXTENSIONS
,
"
allowList
"
:
{
"
enabled
"
:
False
,
"
domains
"
:
None
},
},
}
assert
nodeinfo
.
get
()
==
expected
@pytest.mark.parametrize
(
"
enabled, public, expected
"
,
[
(
True
,
True
,
{
"
enabled
"
:
True
,
"
domains
"
:
[
"
allowed.example
"
]}),
(
True
,
False
,
{
"
enabled
"
:
True
,
"
domains
"
:
None
}),
(
False
,
False
,
{
"
enabled
"
:
False
,
"
domains
"
:
None
}),
],
)
def
test_nodeinfo_allow_list_enabled
(
preferences
,
factories
,
enabled
,
public
,
expected
):
preferences
[
"
moderation__allow_list_enabled
"
]
=
enabled
preferences
[
"
moderation__allow_list_public
"
]
=
public
factories
[
"
federation.Domain
"
](
name
=
"
allowed.example
"
,
allowed
=
True
)
factories
[
"
federation.Domain
"
](
allowed
=
False
)
factories
[
"
federation.Domain
"
](
allowed
=
None
)
assert
nodeinfo
.
get
()[
"
metadata
"
][
"
allowList
"
]
==
expected
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment