mirror of
https://github.com/skoelle/icloud-contacts-sync.git
synced 2026-09-17 23:40:24 +00:00
mail test method
This commit is contained in:
+8
-5
@@ -18,8 +18,7 @@ logging.basicConfig(level=Config.LOG_LEVEL, format="%(asctime)s [%(levelname)s]
|
||||
logger = logging.getLogger("mailer")
|
||||
|
||||
|
||||
def fetch_todays_birthdays(conn) -> list[dict]:
|
||||
today = date.today()
|
||||
def fetch_birthdays_for_date(conn, target_date: date) -> list[dict]:
|
||||
with conn.cursor() as cur:
|
||||
cur.execute(
|
||||
"""SELECT id, account, full_name, birthday, organization, photo_url
|
||||
@@ -28,11 +27,15 @@ def fetch_todays_birthdays(conn) -> list[dict]:
|
||||
AND MONTH(birthday) = %s
|
||||
AND DAY(birthday) = %s
|
||||
ORDER BY full_name""",
|
||||
(today.month, today.day),
|
||||
(target_date.month, target_date.day),
|
||||
)
|
||||
return cur.fetchall()
|
||||
|
||||
|
||||
def fetch_todays_birthdays(conn) -> list[dict]:
|
||||
return fetch_birthdays_for_date(conn, date.today())
|
||||
|
||||
|
||||
def already_sent_today(conn) -> bool:
|
||||
today = date.today()
|
||||
with conn.cursor() as cur:
|
||||
@@ -50,8 +53,8 @@ def log_sent(conn, count: int):
|
||||
conn.commit()
|
||||
|
||||
|
||||
def build_message(birthdays: list[dict]) -> EmailMessage:
|
||||
today = date.today()
|
||||
def build_message(birthdays: list[dict], target_date: date | None = None) -> EmailMessage:
|
||||
today = target_date or date.today()
|
||||
msg = EmailMessage()
|
||||
msg["From"] = Config.MAIL_FROM
|
||||
msg["To"] = Config.MAIL_TO
|
||||
|
||||
Reference in New Issue
Block a user