fix: invite code snowflake id collisions

This commit is contained in:
trisua 2025-06-23 14:17:01 -04:00
parent 253f11b00c
commit 339aa59434
2 changed files with 3 additions and 1 deletions

View file

@ -578,7 +578,7 @@
document.getElementById(\"invite_codes_output\").classList.remove(\"hidden\"); document.getElementById(\"invite_codes_output\").classList.remove(\"hidden\");
document.getElementById(\"invite_codes_error_output\").classList.remove(\"hidden\"); document.getElementById(\"invite_codes_error_output\").classList.remove(\"hidden\");
document.getElementById(\"invite_codes_output\").children[0].innerText = \"Working...\"; document.getElementById(\"invite_codes_output\").children[0].innerText = \"Working... expect to wait 50ms per invite code\";
fetch(`/api/v1/invites/${count}`, { fetch(`/api/v1/invites/${count}`, {
method: \"POST\", method: \"POST\",

View file

@ -855,6 +855,8 @@ pub async fn generate_invite_codes_request(
let mut errors_string = String::new(); let mut errors_string = String::new();
for _ in 0..count { for _ in 0..count {
// ids will quickly collide, so we need to wait a bit so timestamps are different
tokio::time::sleep(Duration::from_millis(50)).await;
match data match data
.create_invite_code(InviteCode::new(user.id), &user) .create_invite_code(InviteCode::new(user.id), &user)
.await .await