add history entries for rrsets delivered via zone api which is forwarded to pdns

This commit is contained in:
Tobias Paepke 2019-12-11 14:04:18 +01:00
parent 242e31a490
commit 81869f4cd8

View File

@ -453,6 +453,27 @@ def api_zone_forward(server_id, zone_id):
resp = helper.forward_request()
domain = Domain()
domain.update()
status = resp.status_code
if 200 <= status < 300:
current_app.logger.debug("Request to powerdns API successful")
if request.method != 'GET' and request.method != 'DELETE':
data = request.get_json(force=True)
for rrset_data in data['rrsets']:
history = History(
msg='{0} zone {1} record of {2}'.format(rrset_data['changetype'].lower(),
rrset_data['type'],
rrset_data['name'].rstrip('.')),
detail=json.dumps(data),
created_by=g.apikey.description
)
history.add()
elif request.method == 'DELETE':
history = History(
msg='Deleted zone {0}'.format(domain.name),
detail='',
created_by=g.apikey.description
)
history.add()
return resp.content, resp.status_code, resp.headers.items()