See #853: advertise allow-list configuration in nodeinfo

This commit is contained in:
Eliot Berriot 2019-06-21 15:57:04 +02:00
parent 38a8e998fd
commit 581e890ad9
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
2 changed files with 34 additions and 1 deletions

View file

@ -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: