Call send_expiry_notification with single arguments instead of tuples
This commit is contained in:
@@ -57,14 +57,22 @@ def cleanup_expired(app):
|
||||
app.dns_service.delete_record(hostname.hostname, hostname.zone, "AAAA")
|
||||
|
||||
if app.email_service:
|
||||
last_ipv4 = (hostname.last_ipv4, hostname.last_ipv4_update) if ipv4_expired else None
|
||||
last_ipv6 = (hostname.last_ipv6, hostname.last_ipv6_update) if ipv6_expired else None
|
||||
last_ipv4 = last_ipv4_update = None
|
||||
if ipv4_expired:
|
||||
last_ipv4 = hostname.last_ipv4
|
||||
last_ipv4_update = hostname.last_ipv4_update
|
||||
last_ipv6 = last_ipv6_update = None
|
||||
if ipv6_expired:
|
||||
last_ipv6 = hostname.last_ipv6
|
||||
last_ipv6_update = hostname.last_ipv6_update
|
||||
|
||||
app.email_service.send_expiry_notification(
|
||||
hostname.user.email,
|
||||
f"{hostname.hostname}.{hostname.zone}",
|
||||
last_ipv4,
|
||||
last_ipv4_update,
|
||||
last_ipv6,
|
||||
last_ipv6_update,
|
||||
hostname.expiry_ttl
|
||||
)
|
||||
|
||||
|
||||
@@ -70,7 +70,9 @@ class EmailService:
|
||||
email,
|
||||
hostname,
|
||||
last_ipv4,
|
||||
last_ipv4_update,
|
||||
last_ipv6,
|
||||
last_ipv6_update,
|
||||
expiry_ttl
|
||||
):
|
||||
"""
|
||||
@@ -86,20 +88,19 @@ class EmailService:
|
||||
Returns:
|
||||
True if sent successfully.
|
||||
"""
|
||||
|
||||
expired = ""
|
||||
if last_ipv4 and last_ipv4_update:
|
||||
expired += f"IPv4 address: {last_ipv4} (last update: {last_ipv4_update})\n"
|
||||
if last_ipv6 and last_ipv6_update:
|
||||
expired += f"IPv6 address: {last_ipv6} (last update: {last_ipv6_update})\n"
|
||||
|
||||
subject = f"DDNS hostname expired: {hostname}"
|
||||
body = f"""Your dynamic DNS entry has expired due to inactivity.
|
||||
|
||||
Hostname: {hostname}
|
||||
"""
|
||||
if last_ipv4:
|
||||
ip = last_ipv4[0]
|
||||
last_update = datetime_str(last_ipv4[1])
|
||||
body += f"IPv4 address: {ip} (last update: {last_update})\n"
|
||||
if last_ipv6:
|
||||
ip = last_ipv6[0]
|
||||
last_update = datetime_str(last_ipv6[1])
|
||||
body += f"IPv6 address: {ip} (last update: {last_update})\n"
|
||||
body += f"""Expiry TTL: {expiry_ttl} seconds
|
||||
{expired}
|
||||
Expiry TTL: {expiry_ttl} seconds
|
||||
|
||||
The DNS records have been removed. Update your client to restore them.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user