Derived hardcoded day counts in cleanup messages from threshold constants.
This commit is contained in:
@@ -20,7 +20,12 @@ from typing import TYPE_CHECKING, Any
|
|||||||
|
|
||||||
from mautrix.types import MessageType, TextMessageEventContent
|
from mautrix.types import MessageType, TextMessageEventContent
|
||||||
|
|
||||||
from .utils import SECONDS_BETWEEN_NOTIFICATIONS, sanitize_for_plain_text
|
from .utils import (
|
||||||
|
CLEANUP_DELETE_THRESHOLD,
|
||||||
|
CLEANUP_WARNING_THRESHOLD,
|
||||||
|
SECONDS_BETWEEN_NOTIFICATIONS,
|
||||||
|
sanitize_for_plain_text,
|
||||||
|
)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
import logging
|
import logging
|
||||||
@@ -215,11 +220,15 @@ class NotificationService:
|
|||||||
room_ids = await self.subscription_repo.get_subscribed_rooms(domain)
|
room_ids = await self.subscription_repo.get_subscribed_rooms(domain)
|
||||||
|
|
||||||
# Build the warning message
|
# Build the warning message
|
||||||
|
warning_days = CLEANUP_WARNING_THRESHOLD // (24 * 60)
|
||||||
|
delete_days = CLEANUP_DELETE_THRESHOLD // (24 * 60)
|
||||||
|
remaining_days = delete_days - warning_days
|
||||||
body_text = (
|
body_text = (
|
||||||
"⚠️ Warning: Subscription Cleanup Scheduled\n\n"
|
"⚠️ Warning: Subscription Cleanup Scheduled\n\n"
|
||||||
f"The Owncast instance at {domain} has been "
|
f"The Owncast instance at {domain} has been "
|
||||||
f"unreachable for 83 days. If it remains unreachable "
|
f"unreachable for {warning_days} days. If it remains "
|
||||||
f"for 7 more days (90 days total), this subscription "
|
f"unreachable for {remaining_days} more days "
|
||||||
|
f"({delete_days} days total), this subscription "
|
||||||
f"will be automatically removed."
|
f"will be automatically removed."
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -247,11 +256,13 @@ class NotificationService:
|
|||||||
room_ids = await self.subscription_repo.get_subscribed_rooms(domain)
|
room_ids = await self.subscription_repo.get_subscribed_rooms(domain)
|
||||||
|
|
||||||
# Build the deletion message
|
# Build the deletion message
|
||||||
|
delete_days = CLEANUP_DELETE_THRESHOLD // (24 * 60)
|
||||||
body_text = (
|
body_text = (
|
||||||
"🗑️ Subscription Automatically Removed\n\n"
|
"🗑️ Subscription Automatically Removed\n\n"
|
||||||
f"The Owncast instance at {domain} has been "
|
f"The Owncast instance at {domain} has been "
|
||||||
f"unreachable for 90 days and has been automatically "
|
f"unreachable for {delete_days} days and has been "
|
||||||
f"removed from subscriptions in this room.\n\n"
|
f"automatically removed from subscriptions in this "
|
||||||
|
f"room.\n\n"
|
||||||
f"If the instance comes online again and you want to "
|
f"If the instance comes online again and you want to "
|
||||||
f"resubscribe, run `!subscribe {domain}`."
|
f"resubscribe, run `!subscribe {domain}`."
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user