Christmas gifts and timed gift e-mails

- Gifts bought 15 Nov - 6 Jan get a Christmas card ("Boldog karácsonyt és
  csillagos 2027-et!", snowflakes) and a Christmas e-mail subject.
- The buyer can time the gift e-mail (e.g. Christmas morning); "Küldés most"
  replaces a waiting one, a refund takes it back.
- Admin: timed e-mails by hour (waiting / sent / failed), e-mail state per gift.
- /karacsony landing page; seasonal hints on /csomagok and /ajandek.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-24 13:46:35 +00:00
co-authored by Claude Opus 5.5
parent 227e8b5b80
commit 382bd31271
22 changed files with 1016 additions and 209 deletions
+20 -3
View File
@@ -132,18 +132,35 @@ pub async fn queue_email_to(
locale: &str,
payload: Value,
) -> Result<(), ApiError> {
queue_email_at(conn, user_id, to, template, locale, payload, None).await.map(drop)
}
/// Queues an e-mail that the worker sends not before `at` (none: at once);
/// returns its id.
pub async fn queue_email_at(
conn: &mut PgConnection,
user_id: Option<Uuid>,
to: &str,
template: &str,
locale: &str,
payload: Value,
at: Option<time::OffsetDateTime>,
) -> Result<Uuid, ApiError> {
let id = Uuid::now_v7();
sqlx::query(
"INSERT INTO email_outbox (id, user_id, to_email, template, locale, payload) VALUES ($1, $2, $3, $4, $5, $6)",
"INSERT INTO email_outbox (id, user_id, to_email, template, locale, payload, next_attempt_at) \
VALUES ($1, $2, $3, $4, $5, $6, coalesce($7, now()))",
)
.bind(Uuid::now_v7())
.bind(id)
.bind(user_id)
.bind(to)
.bind(template)
.bind(locale)
.bind(payload)
.bind(at)
.execute(conn)
.await?;
Ok(())
Ok(id)
}
/// The e-mails that carry a password link.