From 1974c17e7616b418ee202d2af6c10fdae544cf6e Mon Sep 17 00:00:00 2001 From: Eliot Berriot <contact@eliotberriot.com> Date: Wed, 16 May 2018 22:21:40 +0200 Subject: [PATCH] Fix #200: Instances can now indicate on the nodeinfo endpoint if they want to remain private --- .../instance/dynamic_preferences_registry.py | 14 ++++++++++++++ api/funkwhale_api/instance/nodeinfo.py | 2 ++ api/tests/instance/test_nodeinfo.py | 2 ++ changes/changelog.d/200.enhancement | 1 + 4 files changed, 19 insertions(+) create mode 100644 changes/changelog.d/200.enhancement diff --git a/api/funkwhale_api/instance/dynamic_preferences_registry.py b/api/funkwhale_api/instance/dynamic_preferences_registry.py index 03555b0b..20679fd3 100644 --- a/api/funkwhale_api/instance/dynamic_preferences_registry.py +++ b/api/funkwhale_api/instance/dynamic_preferences_registry.py @@ -85,6 +85,20 @@ class InstanceNodeinfoEnabled(types.BooleanPreference): ) +@global_preferences_registry.register +class InstanceNodeinfoPrivate(types.BooleanPreference): + show_in_api = False + section = instance + name = 'nodeinfo_private' + default = False + verbose_name = 'Enable nodeinfo endpoint' + help_text = ( + 'Indicate in the nodeinfo endpoint that you do not want your instance' + 'to be tracked by third-party services.' + 'There is no guarantee these tools will honor this setting though.' + ) + + @global_preferences_registry.register class InstanceNodeinfoStatsEnabled(types.BooleanPreference): show_in_api = False diff --git a/api/funkwhale_api/instance/nodeinfo.py b/api/funkwhale_api/instance/nodeinfo.py index e267f197..dbc005af 100644 --- a/api/funkwhale_api/instance/nodeinfo.py +++ b/api/funkwhale_api/instance/nodeinfo.py @@ -12,6 +12,7 @@ memo = memoize.Memoizer(store, namespace='instance:stats') def get(): share_stats = preferences.get('instance__nodeinfo_stats_enabled') + private = preferences.get('instance__nodeinfo_private') data = { 'version': '2.0', 'software': { @@ -30,6 +31,7 @@ def get(): } }, 'metadata': { + 'private': preferences.get('instance__nodeinfo_private'), 'shortDescription': preferences.get('instance__short_description'), 'longDescription': preferences.get('instance__long_description'), 'nodeName': preferences.get('instance__name'), diff --git a/api/tests/instance/test_nodeinfo.py b/api/tests/instance/test_nodeinfo.py index 4ca1c43a..87b88828 100644 --- a/api/tests/instance/test_nodeinfo.py +++ b/api/tests/instance/test_nodeinfo.py @@ -36,6 +36,7 @@ def test_nodeinfo_dump(preferences, mocker): } }, 'metadata': { + 'private': preferences['instance__nodeinfo_private'], 'shortDescription': preferences['instance__short_description'], 'longDescription': preferences['instance__long_description'], 'nodeName': preferences['instance__name'], @@ -92,6 +93,7 @@ def test_nodeinfo_dump_stats_disabled(preferences, mocker): } }, 'metadata': { + 'private': preferences['instance__nodeinfo_private'], 'shortDescription': preferences['instance__short_description'], 'longDescription': preferences['instance__long_description'], 'nodeName': preferences['instance__name'], diff --git a/changes/changelog.d/200.enhancement b/changes/changelog.d/200.enhancement new file mode 100644 index 00000000..1e78b92f --- /dev/null +++ b/changes/changelog.d/200.enhancement @@ -0,0 +1 @@ +Instances can now indicate on the nodeinfo endpoint if they want to remain private (#200) -- GitLab