From 22139e48f8371e760412bf1971bbf60a0ebff35f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D1=82=D0=B0=D1=80=D1=86=D0=B5=D0=B2=20=D0=9C=D0=B0?= =?UTF-8?q?=D1=82=D0=B2=D0=B5=D0=B9?= Date: Tue, 28 Oct 2025 14:54:16 +0300 Subject: [PATCH] adds support new newsfeed api MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Старцев Матвей --- extras/constants.py | 3 ++- netbox/config/parameters.py | 8 +++++++- netbox/settings.py | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/extras/constants.py b/extras/constants.py index cadf20cfec..a541556569 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 dd2495b566..8fb0ed0251 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 6efca79bee..fdb350e04f 100644 --- a/netbox/settings.py +++ b/netbox/settings.py @@ -744,6 +744,25 @@ 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 = getattr(configuration, 'NEWSFEED_API_VERSION', 'v1') + +# Base URL for newsfeed API +NEWSFEED_BASE_URL = 'https://api.netbox.oss.netboxlabs.com/newsfeed/' + +# 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'{NEWSFEED_BASE_URL}?version=2' +else: + # Fallback to base URL for any other version + NEWSFEED_URL = NEWSFEED_BASE_URL + EVENTS_PIPELINE = list(EVENTS_PIPELINE) if 'extras.events.process_event_queue' not in EVENTS_PIPELINE: EVENTS_PIPELINE.insert(0, 'extras.events.process_event_queue')