Commit 756063fa authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Merge branch '872-term' into 'develop'

See #872: new "terms of service" settings

See merge request funkwhale/funkwhale!894
parents 3a9f2cde 5ca30557
......@@ -14,6 +14,11 @@ def get(pref):
return manager[pref]
def all():
manager = global_preferences_registry.manager()
return manager.all()
def set(pref, value):
manager = global_preferences_registry.manager()
manager[pref] = value
......
......@@ -43,6 +43,20 @@ class InstanceLongDescription(types.StringPreference):
field_kwargs = {"required": False}
@global_preferences_registry.register
class InstanceTerms(types.StringPreference):
show_in_api = True
section = instance
name = "terms"
verbose_name = "Terms of service"
default = ""
help_text = (
"Terms of service and privacy policy for your instance (markdown allowed)."
)
widget = widgets.Textarea
field_kwargs = {"required": False}
@global_preferences_registry.register
class RavenDSN(types.StringPreference):
show_in_api = True
......
......@@ -13,10 +13,11 @@ 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")
unauthenticated_report_types = preferences.get(
all_preferences = preferences.all()
share_stats = all_preferences.get("instance__nodeinfo_stats_enabled")
allow_list_enabled = all_preferences.get("moderation__allow_list_enabled")
allow_list_public = all_preferences.get("moderation__allow_list_public")
unauthenticated_report_types = all_preferences.get(
"moderation__unauthenticated_report_types"
)
if allow_list_enabled and allow_list_public:
......@@ -32,20 +33,21 @@ def get():
"software": {"name": "funkwhale", "version": funkwhale_api.__version__},
"protocols": ["activitypub"],
"services": {"inbound": [], "outbound": []},
"openRegistrations": preferences.get("users__registration_enabled"),
"openRegistrations": all_preferences.get("users__registration_enabled"),
"usage": {"users": {"total": 0, "activeHalfyear": 0, "activeMonth": 0}},
"metadata": {
"actorId": actors.get_service_actor().fid,
"private": preferences.get("instance__nodeinfo_private"),
"shortDescription": preferences.get("instance__short_description"),
"longDescription": preferences.get("instance__long_description"),
"nodeName": preferences.get("instance__name"),
"private": all_preferences.get("instance__nodeinfo_private"),
"shortDescription": all_preferences.get("instance__short_description"),
"longDescription": all_preferences.get("instance__long_description"),
"terms": all_preferences.get("instance__terms"),
"nodeName": all_preferences.get("instance__name"),
"library": {
"federationEnabled": preferences.get("federation__enabled"),
"federationNeedsApproval": preferences.get(
"federationEnabled": all_preferences.get("federation__enabled"),
"federationNeedsApproval": all_preferences.get(
"federation__music_needs_approval"
),
"anonymousCanListen": not preferences.get(
"anonymousCanListen": not all_preferences.get(
"common__api_authentication_required"
),
},
......
......@@ -38,6 +38,7 @@ def test_nodeinfo_dump(preferences, mocker):
"shortDescription": preferences["instance__short_description"],
"longDescription": preferences["instance__long_description"],
"nodeName": preferences["instance__name"],
"terms": preferences["instance__terms"],
"library": {
"federationEnabled": preferences["federation__enabled"],
"federationNeedsApproval": preferences[
......@@ -105,6 +106,7 @@ def test_nodeinfo_dump_stats_disabled(preferences, mocker):
"shortDescription": preferences["instance__short_description"],
"longDescription": preferences["instance__long_description"],
"nodeName": preferences["instance__name"],
"terms": preferences["instance__terms"],
"library": {
"federationEnabled": preferences["federation__enabled"],
"federationNeedsApproval": preferences[
......
......@@ -94,7 +94,8 @@ export default {
settings: [
"instance__name",
"instance__short_description",
"instance__long_description"
"instance__long_description",
"instance__terms",
]
},
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment