Add notify_change to log and Date header to email notifications
This commit is contained in:
@@ -364,6 +364,10 @@ class DDNSRequestHandler(BaseHTTPRequestHandler):
|
||||
# Update database
|
||||
hostname.save()
|
||||
|
||||
notify_change_val = extract_param(params, endpoint["params"]["notify_change"])
|
||||
notify_change = notify_change_val.lower() not in ["0", "n", "no", "off"] \
|
||||
if notify_change_val else False
|
||||
|
||||
changed_addrs = ""
|
||||
if ipv4_changed:
|
||||
changed_addrs += f" ipv4={ipv4}"
|
||||
@@ -373,7 +377,7 @@ class DDNSRequestHandler(BaseHTTPRequestHandler):
|
||||
if not ipv4_changed and not ipv6_changed:
|
||||
logging.info(
|
||||
f"No change: client={client_ip} hostname={hostname.hostname} "
|
||||
f"zone={hostname.zone}{changed_addrs}"
|
||||
f"zone={hostname.zone}{changed_addrs} notify_change={notify_change}"
|
||||
)
|
||||
return (
|
||||
200, "nochg",
|
||||
@@ -382,11 +386,10 @@ class DDNSRequestHandler(BaseHTTPRequestHandler):
|
||||
|
||||
logging.info(
|
||||
f"Updated: client={client_ip} hostname={hostname.hostname} "
|
||||
f"zone={hostname.zone}{changed_addrs}"
|
||||
f"zone={hostname.zone}{changed_addrs} notify_change={notify_change}"
|
||||
)
|
||||
|
||||
notify_change = extract_param(params, endpoint["params"]["notify_change"])
|
||||
if notify_change and notify_change.lower() not in ["0", "no", "off"]:
|
||||
if notify_change:
|
||||
try:
|
||||
self.app.email_service.send_change_notification(
|
||||
hostname.user.email,
|
||||
|
||||
Reference in New Issue
Block a user