diff --git a/extras/constants.py b/extras/constants.py index cadf20cfe..a54155656 100644 --- a/extras/constants.py +++ b/extras/constants.py @@ -1,3 +1,4 @@ +from django.conf import settings from core.events import * from extras.choices import LogLevelChoices @@ -85,7 +86,7 @@ 'height': 4, 'title': 'NetBox News', 'config': { - 'feed_url': 'https://api.netbox.oss.netboxlabs.com/v1/newsfeed/', + 'feed_url': settings.NEWSFEED_URL, 'max_entries': 10, 'cache_timeout': 14400, 'requires_internet': True, diff --git a/netbox/config/parameters.py b/netbox/config/parameters.py index dd2495b56..8fb0ed025 100644 --- a/netbox/config/parameters.py +++ b/netbox/config/parameters.py @@ -209,8 +209,14 @@ def __init__(self, name, label, default, description='', field=None, field_kwarg ConfigParam( name='MAPS_URL', label=_('Maps URL'), - default='https://maps.google.com/?q=', + default='https://www.google.com/maps/search/?api=1&query=', description=_("Base URL for mapping geographic locations") ), + ConfigParam( + name='NEWSFEED_API_VERSION', + label=_('Newsfeed API Version'), + default='v1', + description=_("Version of the Newsfeed API to use (v1 or v2)") + ), ) diff --git a/netbox/settings.py b/netbox/settings.py index 6efca79be..6f058f62c 100644 --- a/netbox/settings.py +++ b/netbox/settings.py @@ -744,6 +744,22 @@ def _setting(name, default=None): PLUGIN_CATALOG_URL = 'https://api.netbox.oss.netboxlabs.com/v1/plugins' +# +# Newsfeed API Configuration +# + +# Configurable Newsfeed API version (default: "v1") +NEWSFEED_API_VERSION = 'v1' + +# Construct the final newsfeed URL based on version +if NEWSFEED_API_VERSION == 'v1': + NEWSFEED_URL = 'https://api.netbox.oss.netboxlabs.com/v1/newsfeed/' +elif NEWSFEED_API_VERSION == 'v2': + NEWSFEED_URL = f'https://api.netbox.oss.netboxlabs.com/newsfeed/?version=2' +else: + # Fallback to base URL for any other version + NEWSFEED_URL = 'https://api.netbox.oss.netboxlabs.com/newsfeed/' + EVENTS_PIPELINE = list(EVENTS_PIPELINE) if 'extras.events.process_event_queue' not in EVENTS_PIPELINE: EVENTS_PIPELINE.insert(0, 'extras.events.process_event_queue')