instagram cta changes, mail fixes
This commit is contained in:
+33
-19
@@ -89,6 +89,8 @@ def _load_config() -> dict:
|
||||
"owner_email": os.environ["OWNER_EMAIL"],
|
||||
"from_email": os.environ.get("FROM_EMAIL", "GoodWalk <bookings@goodwalk.co.nz>"),
|
||||
"reply_to": os.environ.get("REPLY_TO", "aless@goodwalk.co.nz"),
|
||||
"owner_bcc": os.environ.get("OWNER_BCC", "example@example.com").strip(),
|
||||
"client_bcc": os.environ.get("CLIENT_BCC", "").strip(),
|
||||
"enable_general_enquiries": os.environ.get("ENABLE_GENERAL_ENQUIRIES", "false").strip().lower() in {"1", "true", "yes", "on", "enabled"},
|
||||
"max_attempts": max(1, int(os.environ.get("MAIL_MAX_ATTEMPTS", "3"))),
|
||||
"form_min_seconds": max(1, int(os.environ.get("FORM_MIN_SECONDS", "4"))),
|
||||
@@ -104,6 +106,8 @@ _config = _load_config()
|
||||
APP_VERSION = os.environ.get("APP_VERSION", "unknown")
|
||||
resend.api_key = _config["resend_api_key"]
|
||||
OWNER_EMAIL = _config["owner_email"]
|
||||
OWNER_BCC = _config["owner_bcc"]
|
||||
CLIENT_BCC = _config["client_bcc"]
|
||||
FROM_EMAIL = _config["from_email"]
|
||||
REPLY_TO = _config["reply_to"]
|
||||
ENABLE_GENERAL_ENQUIRIES = _config["enable_general_enquiries"]
|
||||
@@ -118,12 +122,14 @@ RATE_LIMIT_MIN_INTERVAL_SECONDS = _config["rate_limit_min_interval_seconds"]
|
||||
LOGO_URL = "https://www.goodwalk.co.nz/images/goodwalk-auckland-dog-walking-logo.png"
|
||||
|
||||
logger.info(
|
||||
"Mail API config: version=%r timezone=%r from=%r reply_to=%r owner=%r general_enquiries=%r max_attempts=%d form_min=%ss form_max=%ss rate_window=%ss per_ip=%d per_email=%d min_interval=%ss",
|
||||
"Mail API config: version=%r timezone=%r from=%r reply_to=%r owner=%r owner_bcc=%r client_bcc=%r general_enquiries=%r max_attempts=%d form_min=%ss form_max=%ss rate_window=%ss per_ip=%d per_email=%d min_interval=%ss",
|
||||
APP_VERSION,
|
||||
os.environ.get("TZ", "system-default"),
|
||||
FROM_EMAIL,
|
||||
REPLY_TO,
|
||||
OWNER_EMAIL,
|
||||
OWNER_BCC,
|
||||
CLIENT_BCC,
|
||||
ENABLE_GENERAL_ENQUIRIES,
|
||||
MAX_SEND_ATTEMPTS,
|
||||
FORM_MIN_SECONDS,
|
||||
@@ -891,15 +897,19 @@ async def submit_booking(data: BookingSubmission, request: Request):
|
||||
|
||||
failures: list[dict] = []
|
||||
|
||||
client_payload = {
|
||||
"from": FROM_EMAIL,
|
||||
"to": [data.email],
|
||||
"reply_to": REPLY_TO,
|
||||
"subject": f"We received your {'general enquiry' if _is_general_enquiry(data) else 'enquiry'}, {first_name}! 🐾",
|
||||
"html": client_email(data),
|
||||
}
|
||||
if CLIENT_BCC:
|
||||
client_payload["bcc"] = [CLIENT_BCC]
|
||||
|
||||
try:
|
||||
await _send_email(
|
||||
{
|
||||
"from": FROM_EMAIL,
|
||||
"to": [data.email],
|
||||
"reply_to": REPLY_TO,
|
||||
"subject": f"We received your {'general enquiry' if _is_general_enquiry(data) else 'enquiry'}, {first_name}! 🐾",
|
||||
"html": client_email(data),
|
||||
},
|
||||
client_payload,
|
||||
label="client_email",
|
||||
request_id=request_id,
|
||||
)
|
||||
@@ -911,19 +921,23 @@ async def submit_booking(data: BookingSubmission, request: Request):
|
||||
"status": getattr(exc, "status_code", None) or getattr(exc, "code", None),
|
||||
})
|
||||
|
||||
owner_payload = {
|
||||
"from": FROM_EMAIL,
|
||||
"to": [OWNER_EMAIL],
|
||||
"reply_to": data.email,
|
||||
"subject": (
|
||||
f"New GoodWalk general enquiry — {data.fullName}"
|
||||
if _is_general_enquiry(data)
|
||||
else f"New GoodWalk lead — {data.fullName} ({data.petName})"
|
||||
),
|
||||
"html": owner_email(data, ip, browser),
|
||||
}
|
||||
if OWNER_BCC:
|
||||
owner_payload["bcc"] = [OWNER_BCC]
|
||||
|
||||
try:
|
||||
await _send_email(
|
||||
{
|
||||
"from": FROM_EMAIL,
|
||||
"to": [OWNER_EMAIL],
|
||||
"reply_to": data.email,
|
||||
"subject": (
|
||||
f"New GoodWalk general enquiry — {data.fullName}"
|
||||
if _is_general_enquiry(data)
|
||||
else f"New GoodWalk lead — {data.fullName} ({data.petName})"
|
||||
),
|
||||
"html": owner_email(data, ip, browser),
|
||||
},
|
||||
owner_payload,
|
||||
label="owner_email",
|
||||
request_id=request_id,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user