Inviting a person to compare charts
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:
@@ -127,7 +127,7 @@ async fn gift_of(conn: &mut PgConnection, invitation_id: Uuid) -> Result<Option<
|
||||
|
||||
// --- sending ---------------------------------------------------------------------------------
|
||||
|
||||
fn clean_message(message: Option<String>) -> Result<Option<String>, ApiError> {
|
||||
pub(super) fn clean_message(message: Option<String>) -> Result<Option<String>, ApiError> {
|
||||
let Some(message) = message.map(|m| m.replace("\r\n", "\n").trim().to_owned()).filter(|m| !m.is_empty()) else {
|
||||
return Ok(None);
|
||||
};
|
||||
@@ -142,7 +142,7 @@ fn clean_message(message: Option<String>) -> Result<Option<String>, ApiError> {
|
||||
Ok(Some(message))
|
||||
}
|
||||
|
||||
fn links(state: &AppState, token: &str) -> (String, String, String) {
|
||||
pub(super) fn links(state: &AppState, token: &str) -> (String, String, String) {
|
||||
let base = &state.config.public_base_url;
|
||||
(
|
||||
format!("{base}/meghivo/{token}"),
|
||||
@@ -199,7 +199,7 @@ async fn send(
|
||||
Ok(url)
|
||||
}
|
||||
|
||||
async fn opted_out(conn: &mut PgConnection, email: &str) -> Result<bool, ApiError> {
|
||||
pub(super) async fn opted_out(conn: &mut PgConnection, email: &str) -> Result<bool, ApiError> {
|
||||
Ok(sqlx::query_scalar("SELECT EXISTS (SELECT 1 FROM email_optouts WHERE email_hash = $1)")
|
||||
.bind(db::token_hash(email))
|
||||
.fetch_one(conn)
|
||||
@@ -587,8 +587,11 @@ pub async fn unsubscribe(
|
||||
WithRejection(Query(q), _): WithRejection<Query<TokenQuery>, ApiError>,
|
||||
) -> ApiResult<Json<Value>> {
|
||||
let mut tx = state.db.begin().await?;
|
||||
// The link of a site invitation, or of a "how compatible are we?" one a user had us e-mail.
|
||||
let email: Option<String> = sqlx::query_scalar(
|
||||
"SELECT i.email FROM invitation_tokens t JOIN invitations i ON i.id = t.invitation_id WHERE t.token_hash = $1",
|
||||
"SELECT i.email FROM invitation_tokens t JOIN invitations i ON i.id = t.invitation_id WHERE t.token_hash = $1 \
|
||||
UNION ALL SELECT invitee_email FROM synastry_invites WHERE token_hash = $1 AND invitee_email IS NOT NULL \
|
||||
LIMIT 1",
|
||||
)
|
||||
.bind(db::token_hash(q.token.trim()))
|
||||
.fetch_optional(&mut *tx)
|
||||
|
||||
Reference in New Issue
Block a user