Inviting a person to compare charts
CI / test (push) Successful in 1m15s
CI / build (push) Successful in 5m27s
CI / deploy (push) Skipped

The new person page offers 'Adatok megadása' (typed-in data, uses a slot)
or 'Meghívom': a 'how compatible are we?' link with an optional name,
e-mail and message (no links, 300 chars), shareable by copy, the phone's
share menu, WhatsApp or Facebook. With an address we e-mail it too (at most
10 a day per user, opted-out addresses skipped, unsubscribe link included).
The invitee lands on /meghivas/<token>, signs in, gives their own birth data
if needed and gets the comparison; the inviter is told and lists pending
invitations (revocable) on the persons page. No person slot is used.

Also: the accepted e-mail links to /osszevetesek/<id>, and the cross grid no
longer breaks on another user's chart (no highlights there).

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 10:12:51 +00:00
co-authored by Claude Opus 5.5
parent 7b23d71526
commit 4f09aac3f5
16 changed files with 820 additions and 39 deletions
+87
View File
@@ -158,6 +158,7 @@ pub fn render(template: &str, locale: &str, payload: &Value) -> Result<Rendered,
)
}
("invitation", _) => invitation(lang, payload, url)?,
("synastry_invite", _) => synastry_invite(lang, payload, url)?,
_ => return Err(TemplateError::UnknownTemplate(template.to_owned())),
};
Ok(content.render(lang))
@@ -282,6 +283,79 @@ fn name(payload: &Value, field: &str) -> Option<String> {
(!name.is_empty()).then(|| name.to_owned())
}
/// 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");
let message = message(payload);
let until =
payload["expires_on"].as_str().and_then(|d| date(lang, d)).ok_or(TemplateError::MissingField("expires_on"))?;
let until_hu = until.trim_end_matches('.');
let unsubscribe_url = field(payload, "unsubscribe_url")?;
let unsubscribe_post_url = field(payload, "unsubscribe_post_url")?;
Ok(match lang {
Lang::Hu => {
let who = inviter.clone().unwrap_or_else(|| "Valaki".into());
Content {
subject: format!("{who} kíváncsi, mennyire illetek össze"),
preheader: Some(format!(
"Születési képletek összevetése a Sorsfonalakon. A meghívó {until_hu}-ig érvényes."
)),
greeting: "Szia!".into(),
intro: format!(
"{who} szeretné összevetni a születési képleteteket a Sorsfonalakon, és megnézni, mennyire illetek össze."
),
quote: message,
points: Some((
"Mit kapsz?",
vec![
"a saját születési képleted kiszámolva és megrajzolva, egy rövid elemzéssel, ingyen,",
"a kettőtök összevetését: hol erős és hol kényes a kapcsolatotok.",
],
)),
button: "Megnézem",
url,
note: format!(
"A meghívó {until_hu}-ig érvényes. Google-fiókkal lépsz be. A születési adataidat {who} nem látja, csak az összevetést."
),
reason: Some(format!(
"Ezt a levelet azért kaptad, mert {who} megadta az e-mail-címed a Sorsfonalakon."
)),
unsubscribe: Some(("Nem kérek több meghívót", unsubscribe_url)),
unsubscribe_post_url: Some(unsubscribe_post_url),
}
}
Lang::En => {
let who = inviter.clone().unwrap_or_else(|| "Someone".into());
Content {
subject: format!("{who} wonders how well you match"),
preheader: Some(format!(
"Comparing birth charts on Sorsfonalak. The invitation is valid until {until}."
)),
greeting: "Hi,".into(),
intro: format!(
"{who} would like to compare your birth charts on Sorsfonalak and see how well you match."
),
quote: message,
points: Some((
"What you get:",
vec![
"your own birth chart, calculated and drawn, with a short reading, for free,",
"the comparison of the two of you: where your relationship is strong and where it is delicate.",
],
)),
button: "Take a look",
url,
note: format!(
"The invitation is valid until {until}. You sign in with Google. {who} does not see your birth data, only the comparison."
),
reason: Some(format!("You got this e-mail because {who} entered your address on Sorsfonalak.")),
unsubscribe: Some(("No more invitations, please", unsubscribe_url)),
unsubscribe_post_url: Some(unsubscribe_post_url),
}
}
})
}
/// The personal message of an invitation: line breaks kept, other control characters dropped.
fn message(payload: &Value) -> Option<String> {
let text: String =
@@ -465,6 +539,19 @@ mod tests {
})
}
#[test]
fn synastry_invite_names_the_inviter() {
let hu = render("synastry_invite", "hu", &invitation_payload()).unwrap();
assert_eq!(hu.subject, "Kata kíváncsi, mennyire illetek össze");
assert!(hu.text.contains("> Gyere, nézd meg!"));
assert!(hu.text.contains("A meghívó 2026. december 17-ig érvényes."));
assert!(hu.html.contains(r#"href="https://sorsfonalak.test/meghivo/abc""#));
assert!(hu.text.contains("Nem kérek több meghívót"));
let mut anonymous = invitation_payload();
anonymous["inviter_name"] = Value::Null;
assert_eq!(render("synastry_invite", "en", &anonymous).unwrap().subject, "Someone wonders how well you match");
}
#[test]
fn invitation_has_both_parts() {
let hu = render("invitation", "hu", &invitation_payload()).unwrap();