Guest section: invitations send directly — remove the pending-approval state

The portal provisions member invites immediately now (approval gate removed
2026-11-08), so the dashboard drops the trial-gate UI: no auto_approve
branch, no 'pending approval' pill or its CSS, button is always 'Send
invite', and the confirmation says the friend can set up their account now.
The trail still shows each guest active with its expiry (legacy rejected
requests from the trial period remain as history).
This commit is contained in:
inference-bot committed 2026-11-08 20:20:33 +00:00
1 parent 032068bfb4
commit 1e9d212bd0
1 file changed
+17 -23
+17 -23
View File
@@ -280,8 +280,8 @@ async def api_guests(request: Request):
One hop to the portal broker's GET /broker/guests: whether this member One hop to the portal broker's GET /broker/guests: whether this member
can send a guest invitation now (the rolling one-per-30-days rule, can send a guest invitation now (the rolling one-per-30-days rule,
counting pending and approved requests) and every invitation they have counted from the guests ledger) and every invitation they have made,
made, with its status. The portal's refusal statuses pass through as-is. with its status. The portal's refusal statuses pass through as-is.
""" """
identity = get_user_identity(request) identity = get_user_identity(request)
if not identity: if not identity:
@@ -297,10 +297,10 @@ async def api_guest_invite(request: Request):
Body: {"email": "<recipient>", "name": "<optional display name>"}. One Body: {"email": "<recipient>", "name": "<optional display name>"}. One
hop to the portal broker, which holds every protection (active-member hop to the portal broker, which holds every protection (active-member
inviter, one invitation per member per 30 days, recipient never an inviter, one invitation per member per 30 days, recipient never an
existing member / prior guest / pending request / manual account) and existing member / prior guest / manual account) and PROVISIONS
the trial gate: with approval on, the request waits for the co-op's IMMEDIATELY on a valid request — the friend's account and invitation
approve/reject and nothing goes to the recipient until then. The email go out at once (the trial-approval gate was removed 2026-11-08).
portal's refusals are member-facing text and pass through verbatim. The portal's refusals are member-facing text and pass through verbatim.
""" """
identity = get_user_identity(request) identity = get_user_identity(request)
if not identity: if not identity:
@@ -644,7 +644,6 @@ PAGE_HTML = """<!DOCTYPE html>
.guest-who { font-weight: 600; font-size: 13px; } .guest-who { font-weight: 600; font-size: 13px; }
.guest-meta { color: var(--muted); font-size: 12px; margin-top: 2px; } .guest-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.gpill { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 11px; font-weight: 600; white-space: nowrap; } .gpill { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.gpill.pending { background: #fdf3e3; color: #a97a2a; }
.gpill.ok { background: #eaf3ea; color: #2f5c30; } .gpill.ok { background: #eaf3ea; color: #2f5c30; }
.gpill.done { background: #f1e8da; color: #a97a4a; } .gpill.done { background: #f1e8da; color: #a97a4a; }
.gpill.bad { background: #f6e9e5; color: var(--danger); } .gpill.bad { background: #f6e9e5; color: var(--danger); }
@@ -949,11 +948,11 @@ function renderGuestEnded(g) {
// --- Member self-serve guest access ---------------------------------------- // --- Member self-serve guest access ----------------------------------------
// One invitation per member per rolling 30 days (the portal owns the rule); // One invitation per member per rolling 30 days (the portal owns the rule);
// under the trial gate a request waits for the co-op's approval before the // an invitation provisions immediately — the friend's account and invitation
// friend's account is created. The trail is the member's own history only. // email go out at once (the trial-approval gate was removed 2026-11-08).
// The trail is the member's own history only.
const GUEST_STATUS_LABELS = { const GUEST_STATUS_LABELS = {
pending: ['pending approval', 'pending'],
rejected: ['not approved', 'bad'], rejected: ['not approved', 'bad'],
active: ['active guest', 'ok'], active: ['active guest', 'ok'],
converted: ['became a member', 'done'], converted: ['became a member', 'done'],
@@ -992,15 +991,10 @@ function renderGuests(d) {
$('guest-trail').innerHTML = '<div class="empty">' + escapeHtml(d.error) + '</div>'; $('guest-trail').innerHTML = '<div class="empty">' + escapeHtml(d.error) + '</div>';
return; return;
} }
// The gate: with auto-approve on the invitation sends directly; under the // An invitation provisions immediately (the approval gate is gone) — the
// trial it waits for the co-op's approval. The button says which. // button and hint say what happens, with no approval step.
const auto = !!d.auto_approve; $('guest-btn').textContent = 'Send invite';
$('guest-btn').textContent = auto ? 'Send invite' : 'Send request';
if (auto) {
$('guest-hint').textContent = "Give a friend $2 of AI credits for the co-op's chat and API — no membership needed. They get 60 days to try it. One guest per member every 30 days."; $('guest-hint').textContent = "Give a friend $2 of AI credits for the co-op's chat and API — no membership needed. They get 60 days to try it. One guest per member every 30 days.";
} else {
$('guest-hint').textContent = "Give a friend $2 of AI credits for the co-op's chat and API — no membership needed. They get 60 days to try it. One guest per member every 30 days. The co-op approves guest requests before the account is created.";
}
if (d.eligible) { if (d.eligible) {
$('guest-allowance').textContent = 'You can send one guest invitation now.'; $('guest-allowance').textContent = 'You can send one guest invitation now.';
} else if (d.next_eligible_at) { } else if (d.next_eligible_at) {
@@ -1029,8 +1023,8 @@ function renderGuests(d) {
// The standard guest-invite form: the guest's email (required) plus an // The standard guest-invite form: the guest's email (required) plus an
// OPTIONAL display name. The inviter is the logged-in member — automatic, no // OPTIONAL display name. The inviter is the logged-in member — automatic, no
// field; the portal applies the member-side protections (active member, one // field; the portal applies the member-side protections (active member, one
// per 30 days, recipient checks) and, with the trial gate on, holds the // per 30 days, recipient checks) and a valid invitation provisions
// request for approval. An empty name is never derived from the email. // immediately. An empty name is never derived from the email.
async function sendGuestInvite(ev) { async function sendGuestInvite(ev) {
if (ev) ev.preventDefault(); if (ev) ev.preventDefault();
const email = ($('guest-email').value || '').trim(); const email = ($('guest-email').value || '').trim();
@@ -1047,15 +1041,15 @@ async function sendGuestInvite(ev) {
}); });
const d = await r.json().catch(() => ({})); const d = await r.json().catch(() => ({}));
if (!r.ok || d.error) { if (!r.ok || d.error) {
flash(d.detail || d.note || d.error || 'Could not send the request', false); flash(d.detail || d.note || d.error || 'Could not send the invitation', false);
return; return;
} }
$('guest-email').value = ''; $('guest-email').value = '';
$('guest-name').value = ''; $('guest-name').value = '';
flash(d.note || 'Request sent — waiting for approval.', true); flash(d.note || 'Invitation sent — your friend can set up their account now.', true);
await loadGuests(); await loadGuests();
} catch (e) { } catch (e) {
flash('Could not send the request: ' + e.message, false); flash('Could not send the invitation: ' + e.message, false);
} finally { } finally {
btn.disabled = false; btn.disabled = false;
btn.textContent = label; btn.textContent = label;