Share rewards: a question for a visit, an analysis for a new user
A click proves little, so the first visit of a shared link now earns a question (once per user) instead of a natal analysis. A natal analysis is earned by bringing a new user: the share page remembers the link, the Google sign-up sends it, and when that user makes their own chart the sharer gets one, at most three (referrals table, referral_reward). This is off until sign-up opens (REFERRAL_REWARDS, default false). The share button and its small print follow; /v1/me tells what was earned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -170,6 +170,8 @@ pub struct RegisterRequest {
|
||||
locale: Option<String>,
|
||||
/// The invitation link's token, while sign-up needs an invitation.
|
||||
invite_token: Option<String>,
|
||||
/// The slug of the shared link the visitor came from.
|
||||
referral: Option<String>,
|
||||
}
|
||||
|
||||
/// Password endpoints answer 403 while `PASSWORD_LOGIN` is off.
|
||||
@@ -224,6 +226,7 @@ pub async fn register(
|
||||
state.config.free_person_slots,
|
||||
)
|
||||
.await?;
|
||||
super::shares::record_referral(&mut tx, state.config.referral_rewards, user_id, req.referral.as_deref()).await?;
|
||||
let mut user = load_user(&mut tx, user_id).await?;
|
||||
apply_bootstrap_admin(&state, &mut tx, &mut user).await?;
|
||||
queue_verification(&state, &mut tx, &user).await?;
|
||||
@@ -291,6 +294,8 @@ pub struct GoogleRequest {
|
||||
id_token: String,
|
||||
/// The invitation link's token, while sign-up needs an invitation.
|
||||
invite_token: Option<String>,
|
||||
/// The slug of the shared link the visitor came from.
|
||||
referral: Option<String>,
|
||||
}
|
||||
|
||||
/// Logs in with Google. An unknown Google account is linked to the existing
|
||||
@@ -362,6 +367,8 @@ pub async fn google(
|
||||
state.config.free_person_slots,
|
||||
)
|
||||
.await?;
|
||||
super::shares::record_referral(&mut tx, state.config.referral_rewards, id, req.referral.as_deref())
|
||||
.await?;
|
||||
(id, true)
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user