Skip to content

Commit a4e6a26

Browse files
committed
adds support new newsfeed api
Signed-off-by: Старцев Матвей <tozarin@yandex.ru>
1 parent 51de282 commit a4e6a26

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

extras/constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from django.conf import settings
12
from core.events import *
23
from extras.choices import LogLevelChoices
34

@@ -85,7 +86,7 @@
8586
'height': 4,
8687
'title': 'NetBox News',
8788
'config': {
88-
'feed_url': 'https://api.netbox.oss.netboxlabs.com/v1/newsfeed/',
89+
'feed_url': settings.NEWSFEED_URL,
8990
'max_entries': 10,
9091
'cache_timeout': 14400,
9192
'requires_internet': True,

netbox/config/parameters.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,14 @@ def __init__(self, name, label, default, description='', field=None, field_kwarg
209209
ConfigParam(
210210
name='MAPS_URL',
211211
label=_('Maps URL'),
212-
default='https://maps.google.com/?q=',
212+
default='https://www.google.com/maps/search/?api=1&query=',
213213
description=_("Base URL for mapping geographic locations")
214214
),
215+
ConfigParam(
216+
name='NEWSFEED_API_VERSION',
217+
label=_('Newsfeed API Version'),
218+
default='v1',
219+
description=_("Version of the Newsfeed API to use (v1 or v2)")
220+
),
215221

216222
)

netbox/settings.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,22 @@ def _setting(name, default=None):
744744

745745
PLUGIN_CATALOG_URL = 'https://api.netbox.oss.netboxlabs.com/v1/plugins'
746746

747+
#
748+
# Newsfeed API Configuration
749+
#
750+
751+
# Configurable Newsfeed API version (default: "v1")
752+
NEWSFEED_API_VERSION = 'v1'
753+
754+
# Construct the final newsfeed URL based on version
755+
if NEWSFEED_API_VERSION == 'v1':
756+
NEWSFEED_URL = 'https://api.netbox.oss.netboxlabs.com/v1/newsfeed/'
757+
elif NEWSFEED_API_VERSION == 'v2':
758+
NEWSFEED_URL = f'https://api.netbox.oss.netboxlabs.com/newsfeed/?version=2'
759+
else:
760+
# Fallback to base URL for any other version
761+
NEWSFEED_URL = 'https://api.netbox.oss.netboxlabs.com/newsfeed/'
762+
747763
EVENTS_PIPELINE = list(EVENTS_PIPELINE)
748764
if 'extras.events.process_event_queue' not in EVENTS_PIPELINE:
749765
EVENTS_PIPELINE.insert(0, 'extras.events.process_event_queue')

0 commit comments

Comments
 (0)