mirror of
https://github.com/skoelle/icloud-contacts-sync.git
synced 2026-09-17 15:30:24 +00:00
mailer test if today already sent
This commit is contained in:
@@ -107,6 +107,23 @@ def main():
|
|||||||
last_sync = datetime.now(Config.TIMEZONE)
|
last_sync = datetime.now(Config.TIMEZONE)
|
||||||
next_mailer = next_run_time(MAIL_SEND_HOUR)
|
next_mailer = next_run_time(MAIL_SEND_HOUR)
|
||||||
|
|
||||||
|
if MAILER_ENABLED:
|
||||||
|
try:
|
||||||
|
today = datetime.now(Config.TIMEZONE).date()
|
||||||
|
with db.get_connection() as conn:
|
||||||
|
with conn.cursor() as cur:
|
||||||
|
cur.execute(
|
||||||
|
"SELECT 1 FROM birthday_mail_log WHERE sent_date = %s LIMIT 1",
|
||||||
|
(today,),
|
||||||
|
)
|
||||||
|
already_sent = cur.fetchone() is not None
|
||||||
|
if not already_sent and next_mailer.date() > today:
|
||||||
|
logger.info("Mailer fuer heute noch nicht gesendet — hole nach")
|
||||||
|
run_mailer()
|
||||||
|
next_mailer = next_run_time(MAIL_SEND_HOUR)
|
||||||
|
except Exception:
|
||||||
|
logger.exception("Pruefung/Nachholen des Mailers fehlgeschlagen")
|
||||||
|
|
||||||
while not _shutdown:
|
while not _shutdown:
|
||||||
now = datetime.now(Config.TIMEZONE)
|
now = datetime.now(Config.TIMEZONE)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user