mirror of
https://github.com/netbox-community/netbox.git
synced 2026-03-21 20:18:38 -06:00
Closes #21702: Include originating HTTP request in outbound webhook context data
This commit is contained in:
@@ -370,6 +370,9 @@ class EventRuleTest(APITestCase):
|
||||
self.assertEqual(body['data']['name'], 'Site 1')
|
||||
self.assertEqual(body['data']['foo'], 1)
|
||||
self.assertEqual(body['context']['foo'], 123) # From netbox.tests.dummy_plugin
|
||||
self.assertEqual(body['request']['id'], str(request_id))
|
||||
self.assertEqual(body['request']['method'], 'GET')
|
||||
self.assertEqual(body['request']['user'], 'testuser')
|
||||
|
||||
return HttpResponse()
|
||||
|
||||
|
||||
@@ -57,6 +57,13 @@ def send_webhook(event_rule, object_type, event_type, data, timestamp, username,
|
||||
'request_id': request.id if request else None,
|
||||
'data': data,
|
||||
}
|
||||
if request:
|
||||
context['request'] = {
|
||||
'id': str(request.id) if request.id else None,
|
||||
'method': request.method,
|
||||
'path': request.path,
|
||||
'user': str(request.user),
|
||||
}
|
||||
if snapshots:
|
||||
context.update({
|
||||
'snapshots': snapshots
|
||||
|
||||
Reference in New Issue
Block a user