Skip to main content

claim_unqueued

pub async fn claim_unqueued(
    conn: &mut PgConnection,
    limit: i64,
    course_id: Option<Uuid>,
) -> ModelResult<Vec<LinkingMailToQueue>>
Expand description

Claims slots whose mail has not been queued yet, oldest first.

Locks them, so the caller must hold a transaction: the delivery insert is not idempotent, and two iterations claiming one slot would queue the same mail twice.

A retired, used or expired token is skipped rather than mailed — a dead link spends the recipient’s one mail for this course on nothing — but its slot stays, since it is still proof we may not mail that address again.