mirror of
https://github.com/skoelle/calender_sync.git
synced 2026-09-17 18:20:24 +00:00
Weekly Notification: Zeitraum auf 2 Wochen erweitern
This commit is contained in:
@@ -452,7 +452,7 @@ def get_weekly_events(conn, calendar_label, searchwords, blacklistwords=None):
|
|||||||
if days_until_saturday == 0:
|
if days_until_saturday == 0:
|
||||||
days_until_saturday = 7
|
days_until_saturday = 7
|
||||||
week_start = today + timedelta(days=days_until_saturday)
|
week_start = today + timedelta(days=days_until_saturday)
|
||||||
week_end = week_start + timedelta(days=6, hours=23, minutes=59, seconds=59)
|
week_end = week_start + timedelta(days=13, hours=23, minutes=59, seconds=59)
|
||||||
|
|
||||||
week_start_naive = week_start.replace(tzinfo=None)
|
week_start_naive = week_start.replace(tzinfo=None)
|
||||||
week_end_naive = week_end.replace(tzinfo=None)
|
week_end_naive = week_end.replace(tzinfo=None)
|
||||||
@@ -546,7 +546,7 @@ def send_weekly_notification(events, searchwords, week_start, week_end, blacklis
|
|||||||
event_date = event["start_at"].replace(tzinfo=timezone.utc).astimezone(tz).strftime("%a, %d.%m.")
|
event_date = event["start_at"].replace(tzinfo=timezone.utc).astimezone(tz).strftime("%a, %d.%m.")
|
||||||
subject = f"Vorab-Info: Termin am {event_date}"
|
subject = f"Vorab-Info: Termin am {event_date}"
|
||||||
else:
|
else:
|
||||||
subject = f"Vorab-Info: {count} Termine naechste Woche"
|
subject = f"Vorab-Info: {count} Termine in 2 Wochen"
|
||||||
|
|
||||||
event_rows = ""
|
event_rows = ""
|
||||||
for event in events:
|
for event in events:
|
||||||
@@ -570,7 +570,7 @@ def send_weekly_notification(events, searchwords, week_start, week_end, blacklis
|
|||||||
<html>
|
<html>
|
||||||
<head><meta charset="utf-8"></head>
|
<head><meta charset="utf-8"></head>
|
||||||
<body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; max-width: 600px; margin: 0 auto; padding: 20px;">
|
<body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; max-width: 600px; margin: 0 auto; padding: 20px;">
|
||||||
<h2 style="color: #333;">Vorab-Info: Naechste Woche</h2>
|
<h2 style="color: #333;">Vorab-Info: Naechste 2 Wochen</h2>
|
||||||
<p style="color: #555;">Vom <strong>{start_str}</strong> bis <strong>{end_str}</strong> stehen folgende Termine an:</p>
|
<p style="color: #555;">Vom <strong>{start_str}</strong> bis <strong>{end_str}</strong> stehen folgende Termine an:</p>
|
||||||
<table style="width: 100%; border-collapse: collapse; margin: 20px 0; background: #f9f9f9; border-radius: 8px; overflow: hidden;">
|
<table style="width: 100%; border-collapse: collapse; margin: 20px 0; background: #f9f9f9; border-radius: 8px; overflow: hidden;">
|
||||||
{event_rows}
|
{event_rows}
|
||||||
@@ -612,7 +612,9 @@ def check_and_send_weekly_notification():
|
|||||||
if should_send_weekly(conn):
|
if should_send_weekly(conn):
|
||||||
searchwords = parse_weekly_searchwords()
|
searchwords = parse_weekly_searchwords()
|
||||||
blacklistwords = parse_weekly_blacklistwords()
|
blacklistwords = parse_weekly_blacklistwords()
|
||||||
|
log.info("Wochenbenachrichtigung: Suchbegriffe=%s, Blacklist=%s", searchwords, blacklistwords)
|
||||||
events, week_start, week_end = get_weekly_events(conn, CALENDAR_LABEL, searchwords, blacklistwords)
|
events, week_start, week_end = get_weekly_events(conn, CALENDAR_LABEL, searchwords, blacklistwords)
|
||||||
|
log.info("Wochenbenachrichtigung: %d Events nach Filterung", len(events))
|
||||||
if events:
|
if events:
|
||||||
send_weekly_notification(events, searchwords, week_start, week_end, blacklistwords)
|
send_weekly_notification(events, searchwords, week_start, week_end, blacklistwords)
|
||||||
log_weekly_notification(conn, len(events))
|
log_weekly_notification(conn, len(events))
|
||||||
|
|||||||
Reference in New Issue
Block a user