Invitation-only sign-up, invitation e-mails and waitlist
- SIGNUP_MODE=invite (default): a new account needs an open invitation for its address, or the invitation link (then any Google account will do) - admin page "Meghívók": invite many addresses at once, personal message, resend (max 3, 24 h apart), revoke, copy link, mail preview and test copy, waitlist - invitation e-mail in HTML and plain text; Message-ID on the sender's domain, List-Unsubscribe with one-click POST, opt-out list (hashes only) - e-mail texts moved to a shared crate (crates/email-templates) - login page shows the invitation; waitlist for uninvited visitors; unsubscribe page; privacy policy updated - docs/levelkuldes.md: Brevo, DNS (SPF, DKIM, DMARC) and the SMTP setup Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -60,7 +60,7 @@ fn delivery(db: PgPool, fail: Vec<(&str, bool)>) -> Delivery {
|
||||
|
||||
fn sent(d: &Delivery) -> Vec<(String, String)> {
|
||||
let Mailer::Memory { sent, .. } = &d.mailer else { unreachable!() };
|
||||
sent.lock().unwrap().iter().map(|(to, m)| (to.clone(), m.subject.clone())).collect()
|
||||
sent.lock().unwrap().iter().map(|(to, m, _)| (to.clone(), m.subject.clone())).collect()
|
||||
}
|
||||
|
||||
async fn queue(db: &PgPool, to: &str, template: &str) -> Uuid {
|
||||
@@ -123,6 +123,35 @@ async fn delivers_retries_and_gives_up(db: PgPool) {
|
||||
assert_eq!(sent(&d).len(), 1);
|
||||
}
|
||||
|
||||
#[sqlx::test(migrator = "db::MIGRATOR")]
|
||||
async fn invitation_headers_for_spam_filters(db: PgPool) {
|
||||
let id = Uuid::now_v7();
|
||||
sqlx::query(
|
||||
"INSERT INTO email_outbox (id, to_email, template, locale, payload) VALUES ($1, $2, 'invitation', 'hu', $3)",
|
||||
)
|
||||
.bind(id)
|
||||
.bind("guest@example.com")
|
||||
.bind(json!({
|
||||
"url": "https://example.com/meghivo/t",
|
||||
"inviter_name": "Kata",
|
||||
"message": null,
|
||||
"expires_on": "2026-12-17",
|
||||
"unsubscribe_url": "https://example.com/leiratkozas?token=t",
|
||||
"unsubscribe_post_url": "https://example.com/api/v1/public/invitations/unsubscribe?token=t",
|
||||
}))
|
||||
.execute(&db)
|
||||
.await
|
||||
.unwrap();
|
||||
let d = delivery(db.clone(), vec![]);
|
||||
assert_eq!(d.deliver_due().await.unwrap(), 1);
|
||||
let Mailer::Memory { sent, .. } = &d.mailer else { unreachable!() };
|
||||
let raw = sent.lock().unwrap()[0].2.clone();
|
||||
assert!(raw.contains(&format!("Message-ID: <{id}@example.com>")), "{raw}");
|
||||
assert!(raw.contains("List-Unsubscribe: <https://example.com/api/v1/public/invitations/unsubscribe?token=t>"));
|
||||
assert!(raw.contains("List-Unsubscribe-Post: List-Unsubscribe=One-Click"));
|
||||
assert!(raw.contains("multipart/alternative") && raw.contains("text/plain") && raw.contains("text/html"));
|
||||
}
|
||||
|
||||
#[sqlx::test(migrator = "db::MIGRATOR")]
|
||||
async fn concurrent_workers_do_not_send_twice(db: PgPool) {
|
||||
for i in 0..15 {
|
||||
@@ -177,7 +206,14 @@ async fn cleanup_removes_only_expired_data(db: PgPool) {
|
||||
let deleted = crate::cleanup::run_once(&db).await.unwrap();
|
||||
assert_eq!(
|
||||
deleted,
|
||||
vec![("sessions", 1), ("auth_tokens", 0), ("emails", 1), ("invites", 0), ("prompt_previews", 0)]
|
||||
vec![
|
||||
("sessions", 1),
|
||||
("auth_tokens", 0),
|
||||
("emails", 1),
|
||||
("invites", 0),
|
||||
("invitations", 0),
|
||||
("prompt_previews", 0)
|
||||
]
|
||||
);
|
||||
let (left,): (Vec<Uuid>,) =
|
||||
sqlx::query_as("SELECT array_agg(id ORDER BY id) FROM email_outbox").fetch_one(&db).await.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user