Skip to main content

Module account_linking

Module account_linking 

Source
Expand description

Claiming the right to mail a Sisu person an account-linking link, and minting the token it carries. Both caps and the dedup guard are evaluated here and nowhere else, and no argument switches them off; an override has to soft-delete a ledger row.

The token is minted bound to no account: the recipient’s Sisu address is routinely not the address on their account here, so the click while logged in is what creates the binding.

Structs§

DiscoveredPerson
One person Sisu’s list-by-course returned, and the address we mail them at.
RetiredMails
What retire_capped_mails did.

Enums§

LinkingMailClaim
What claiming a linking mail did for one person. Ordered from weakest to strongest, so the strongest of several claims for one person is their maximum.

Constants§

JUST_CLAIMED_PERIOD
No override retires a mail claimed this recently, so a second click, tab or colleague cannot replace one that has only just gone out.
LINKING_MAIL_QUIET_PERIOD
How long after a linking mail the person is left alone, across every course and address.
LINKING_MAIL_RESEND_INTERVAL
How long after a linking mail for a course the same person may get another for it.
LINK_STUDENT_NUMBER_PATH
Both the mailed URL and the frontend route that serves it are built from this one value.
MAX_LINKING_MAILS_PER_PERSON_AND_COURSE
How many linking mails one person may ever get for one course, tokens that expired unused included.

Functions§

claim_linking_mail
One person’s claim_linking_mails_batch.
claim_linking_mails_batch
Claims one slot and one unbound token per person whose address has no usable link from us yet, dedup before the rate caps. Returns one claim per input, in order.
holds_address 🔒
Whether a mail to this (person, course, address) still holds the address. The unique index behind claim_send_slots is what actually prevents a second one.
is_within_caps 🔒
Whether the caps still allow this person another mail for this course.
link_student_number_url
The link the mail carries: a bearer credential, whoever holds it can claim the student number.
listed_addresses
The person’s non-empty Sisu addresses, trimmed, primary first.
mail_address
The address a linking mail to person goes to, if Sisu holds one: the primary, else the secondary.
person_id_of_mails 🔒
registerable_completion_courses_by_account_email
For each of the lowercased addresses that is the account email of someone with a completion the push path will register (credit_registration_eligible_completions, prerequisites met and not held for review) on one of course_ids created at or after since, the courses it is on.
retire_capped_mails
Retires the linking-mail rows the caps are counting for this person, so the ordinary claim path can take a slot again. No parameter relaxes a cap: the single writer of the ledger evaluates them from the rows that exist, so getting past one means soft-deleting rows, audited as its own action.
void_tokens 🔒
Soft-deletes tokens whose slot lost the race, so no unusable link is left behind.