Merge remote-tracking branch 'paepke/history-rrsets'

This commit is contained in:
Khanh Ngo 2019-12-11 21:14:44 +07:00
commit 65d4acc6c5

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()