diff --git a/pages/join-status.html b/pages/join-status.html new file mode 100644 index 0000000..1eda3ea --- /dev/null +++ b/pages/join-status.html @@ -0,0 +1,15 @@ +--- +title: Application status +description: "Check the status of your Alabama Progress join application." +noindex: true +scripts: [join-status.js] +--- +
Checking…
+ + + +Keep this page's address private. It's how you check on your application.
+Questions? Write to AlabamaProgressOrg@gmail.com.
\ No newline at end of file diff --git a/pages/privacy.html b/pages/privacy.html index 0b5f6cb..b1b636e 100644 --- a/pages/privacy.html +++ b/pages/privacy.html @@ -25,14 +25,11 @@ description: How Alabama Progress handles your information, including what the jInformation submitted through the join form is transmitted solely to the administrators of the Alabama Progress - Discord server for the purpose of reviewing and approving your membership request. Submitted form data is not stored - in a database or retained after your application is reviewed.
+Your full application is posted to a private moderator channel in our Discord server. Once a moderator accepts or declines it, the bot removes your answers and keeps only your Discord username and the decision. To let you check your status, the bot also keeps a random pickup code (stored only as a one-way hash), your application's status and, if accepted, a single-use invite link for up to 14 days. None of this contains your answers.
Alabama Progress does not sell, rent, trade, or share any submitted information with third parties, data brokers, or outside organizations.
If you have any questions about this privacy policy or how join requests are handled, contact AlabamaProgressOrg@gmail.com.
\ No newline at end of file +If you have any questions about this privacy policy or how join requests are handled, contact AlabamaProgressOrg@gmail.com.
\ No newline at end of file diff --git a/static/scripts/join-status.js b/static/scripts/join-status.js new file mode 100644 index 0000000..3e03e7c --- /dev/null +++ b/static/scripts/join-status.js @@ -0,0 +1,47 @@ +const message = document.querySelector('[data-status-msg]'); +const box = document.querySelector('[data-invite]'); +const link = box.querySelector('a'); +const code = decodeURIComponent(location.hash.slice(1)); +const INVITE = /^https:\/\/discord\.(gg|com\/invite)\/[A-Za-z0-9-]+$/; +const POLL_MS = 15000; + +const TEXT = { + pending: 'Your application has been received and is waiting for a moderator. This page updates on its own, so you can keep it open, or bookmark it and come back later.', + accepted: 'Good news: your application was approved! Use the invite below to join the server. It works once and expires 7 days after approval.', + declined: 'Your application was not approved at this time.', + unknown: 'We couldn’t find this application. It may be more than 14 days old, or the link may be incomplete.', +}; + +function show(state) { + message.textContent = TEXT[state]; +} + +async function check() { + try { + const res = await fetch('/api/join/status', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ code }), + }); + if (res.status === 404) return show('unknown'); + if (res.ok) { + const body = await res.json(); + if (body.status === 'accepted' && INVITE.test(body.invite || '')) { + link.href = body.invite; + box.hidden = false; + return show('accepted'); + } + if (body.status === 'declined') return show('declined'); + show('pending'); + } + } catch { + // Network hiccup: keep the last message and try again. + } + setTimeout(check, POLL_MS); +} + +if (code) { + check(); +} else { + show('unknown'); +} \ No newline at end of file diff --git a/static/scripts/join.js b/static/scripts/join.js index e69de29..e33abcd 100644 --- a/static/scripts/join.js +++ b/static/scripts/join.js @@ -0,0 +1,33 @@ +const form = document.querySelector('form[data-join]'); + +if (form) { + const status = form.querySelector('[data-status]'); + const button = form.querySelector('button[type="submit"]'); + + form.addEventListener('submit', async (event) => { + event.preventDefault(); + status.textContent = 'Sending…'; + button.disabled = true; + + try { + const res = await fetch('/api/join', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(Object.fromEntries(new FormData(form))), + }); + const body = await res.json().catch(() => ({})); + + if (res.ok && body.code) { + location.href = `/join-status/#${encodeURIComponent(body.code)}`; + return; + } + status.textContent = body.error || + (res.status === 429 + ? 'Too many attempts. Please wait a few minutes and try again.' + : 'Something went wrong. Please try again, or email us instead.'); + } catch { + status.textContent = 'Could not reach the server. Check your connection and try again.'; + } + button.disabled = false; + }); +} \ No newline at end of file