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")
|
app.dns_service.delete_record(hostname.hostname, hostname.zone, "AAAA")
|
||||||
|
|
||||||
if app.email_service:
|
if app.email_service:
|
||||||
last_ipv4 = (hostname.last_ipv4, hostname.last_ipv4_update) if ipv4_expired else None
|
last_ipv4 = last_ipv4_update = None
|
||||||
last_ipv6 = (hostname.last_ipv6, hostname.last_ipv6_update) if ipv6_expired else 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(
|
app.email_service.send_expiry_notification(
|
||||||
hostname.user.email,
|
hostname.user.email,
|
||||||
f"{hostname.hostname}.{hostname.zone}",
|
f"{hostname.hostname}.{hostname.zone}",
|
||||||
last_ipv4,
|
last_ipv4,
|
||||||
|
last_ipv4_update,
|
||||||
last_ipv6,
|
last_ipv6,
|
||||||
|
last_ipv6_update,
|
||||||
hostname.expiry_ttl
|
hostname.expiry_ttl
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,9 @@ class EmailService:
|
|||||||
email,
|
email,
|
||||||
hostname,
|
hostname,
|
||||||
last_ipv4,
|
last_ipv4,
|
||||||
|
last_ipv4_update,
|
||||||
last_ipv6,
|
last_ipv6,
|
||||||
|
last_ipv6_update,
|
||||||
expiry_ttl
|
expiry_ttl
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
@@ -86,20 +88,19 @@ class EmailService:
|
|||||||
Returns:
|
Returns:
|
||||||
True if sent successfully.
|
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}"
|
subject = f"DDNS hostname expired: {hostname}"
|
||||||
body = f"""Your dynamic DNS entry has expired due to inactivity.
|
body = f"""Your dynamic DNS entry has expired due to inactivity.
|
||||||
|
|
||||||
Hostname: {hostname}
|
Hostname: {hostname}
|
||||||
"""
|
{expired}
|
||||||
if last_ipv4:
|
Expiry TTL: {expiry_ttl} seconds
|
||||||
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
|
|
||||||
|
|
||||||
The DNS records have been removed. Update your client to restore them.
|
The DNS records have been removed. Update your client to restore them.
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user