Inviting shown but off until launch; waitlist confirmation; waitlist invites with a package
CI / test (push) Successful in 1m35s
CI / build (push) Successful in 8m7s
CI / deploy (push) Skipped

USER_INVITES (default false) keeps users from inviting others until the
launch: the 'Meghívom' option and a 'Hívd meg, akit szeretsz' card on the
persons page are shown, disabled, with 'Hamarosan'; the backend refuses
with invites_disabled (admins may always).

Joining the waitlist sends one confirmation e-mail (waitlist_joined) with a
link that takes the address off the list and opts it out; at most 10 per
address in 15 minutes. Admins can pick a package for waitlist invitations,
like on the invitation form.

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-19 11:07:13 +00:00
co-authored by Claude Opus 5.5
parent dad16fe463
commit 8e1205359d
18 changed files with 285 additions and 26 deletions
+63
View File
@@ -159,6 +159,7 @@ pub fn render(template: &str, locale: &str, payload: &Value) -> Result<Rendered,
}
("invitation", _) => invitation(lang, payload, url)?,
("synastry_invite", _) => synastry_invite(lang, payload, url)?,
("waitlist_joined", _) => waitlist_joined(lang, payload, url)?,
_ => return Err(TemplateError::UnknownTemplate(template.to_owned())),
};
Ok(content.render(lang))
@@ -283,6 +284,56 @@ fn name(payload: &Value, field: &str) -> Option<String> {
(!name.is_empty()).then(|| name.to_owned())
}
/// The confirmation of a waitlist sign-up, with the link that takes the address off the list.
fn waitlist_joined(lang: Lang, payload: &Value, url: String) -> Result<Content, TemplateError> {
let unsubscribe_url = field(payload, "unsubscribe_url")?;
let unsubscribe_post_url = field(payload, "unsubscribe_post_url")?;
Ok(match lang {
Lang::Hu => Content {
subject: "Felírtunk a Sorsfonalak várólistájára".into(),
preheader: Some("Amint bejuthatsz, ide írunk.".into()),
greeting: "Szia!".into(),
intro: "Köszönjük, hogy kíváncsi vagy a Sorsfonalakra! Az oldal egyelőre zártkörű, de felírtunk a várólistára: amint bejuthatsz, erre a címre írunk."
.into(),
quote: None,
points: Some((
"Mi vár rád?",
vec![
"a születési képleted percre pontosan kiszámolva és megrajzolva, egy rövid elemzéssel,",
"részletes elemzés, éves előrejelzés és kapcsolati összevetés azokkal, akiket szeretsz.",
],
)),
button: "Körülnézek",
url,
note: "Ha nem te iratkoztál fel, vagy meggondoltad magad, a lenti linkkel törölheted a címed a listáról.".into(),
reason: Some("Ezt a levelet azért kaptad, mert ezt a címet megadták a Sorsfonalak várólistáján.".into()),
unsubscribe: Some(("Leiratkozás a várólistáról", unsubscribe_url)),
unsubscribe_post_url: Some(unsubscribe_post_url),
},
Lang::En => Content {
subject: "You are on the Sorsfonalak waitlist".into(),
preheader: Some("We will write as soon as you can get in.".into()),
greeting: "Hi,".into(),
intro: "Thanks for your interest in Sorsfonalak! The site is invitation-only for now, but you are on the waitlist: we will write to this address as soon as you can get in."
.into(),
quote: None,
points: Some((
"What awaits you:",
vec![
"your birth chart, calculated to the minute and drawn, with a short reading,",
"detailed readings, a yearly forecast and comparisons with the people you love.",
],
)),
button: "Take a look",
url,
note: "If it was not you, or you changed your mind, the link below takes your address off the list.".into(),
reason: Some("You got this e-mail because this address was entered on the Sorsfonalak waitlist.".into()),
unsubscribe: Some(("Leave the waitlist", unsubscribe_url)),
unsubscribe_post_url: Some(unsubscribe_post_url),
},
})
}
/// A user invites someone to compare their charts ("how compatible are we?").
fn synastry_invite(lang: Lang, payload: &Value, url: String) -> Result<Content, TemplateError> {
let inviter = name(payload, "inviter_name");
@@ -539,6 +590,18 @@ mod tests {
})
}
#[test]
fn waitlist_confirmation_has_the_leave_link() {
let hu = render("waitlist_joined", "hu", &invitation_payload()).unwrap();
assert_eq!(hu.subject, "Felírtunk a Sorsfonalak várólistájára");
assert!(
hu.text.contains("Leiratkozás a várólistáról: https://sorsfonalak.test/leiratkozas?token=abc"),
"{}",
hu.text
);
assert!(hu.unsubscribe_post_url.is_some());
}
#[test]
fn synastry_invite_names_the_inviter() {
let hu = render("synastry_invite", "hu", &invitation_payload()).unwrap();