Skip to content
Merged
11 changes: 7 additions & 4 deletions docs/features/discord.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Three roles, held independently. One person can hold several, and the site publi
| --- | --- | --- |
| Hacker | A participant whose status is `approved` and who pressed "I'm coming" on the hackathon Overview (`attendance_confirmed_at` is set), or who is `checked_in`. Being accepted alone is not enough. | Optional |
| Judge | A `judge` row for that edition with `is_active` true, which is what approval sets. A pending, rejected or removed judge holds nothing. | Required |
| Volunteer | An active, unexpired `admin` row with role `volunteer` (added on the staff page). Volunteers are org-wide, not per edition, so the role applies to any edition that is `open`, `closed` or `in_progress`: registration has opened and the event is not over. Not a draft, an announcement, a finished or a cancelled edition. Full staff are not volunteers. | Required |
| Volunteer | An active, unexpired `admin` row with role `volunteer` (added on the staff page). Volunteers are org-wide, not per edition, so the role applies to any edition that is `open`, `closed` or `in_progress`: registration has opened and the event is not over. Not a draft, an announcement, a finished or a cancelled edition. Full staff are not volunteers. Also an `approved` volunteer application for that edition (`isApprovedVolunteer`), from the announcement until the edition is over; a decline, a withdrawal or a pending application holds nothing. Either one is enough. | Required |

Judges and volunteers need no registration. The edition is the one in the link (`?hackathon=ID`), or, from Discord's verification URL, the newest edition that is not cancelled or over in which the person holds a role. A confirmed hacker who is also a judge gets both. One Discord account links to one person: `discord_link.discord_user_id` is unique, and the same account may not sit on another person's registration for that hackathon.

Expand All @@ -36,7 +36,9 @@ It runs after commit on:
| --- | --- |
| A judge approved, switched off, added or removed | `judge.setActive`, `judge.create`, `judge.remove` |
| A volunteer granted, switched off, renewed with a new end date, or removed | `admin.create`, `admin.update`, `admin.remove` |
| A hacker's status changed in any direction, banned, or withdrawn | `updateParticipantStatus`, `batchUpdateParticipantStatus`, `banFromHackathons`, `withdrawRegistration`. Moving out of the accepted statuses takes the hacker roles back; moving in can give them, so a judge who is moved to approved after confirming gets the flower role at once. |
| A volunteer application approved or declined, or withdrawn by the applicant | `volunteer.decide`, `volunteer.withdraw` |
| An edition moved to or from `completed` or `cancelled` | `hackathon.update` |
| A hacker's status changed in any direction, banned (which also declines their volunteer applications), or withdrawn | `updateParticipantStatus`, `batchUpdateParticipantStatus`, `banFromHackathons`, `withdrawRegistration`. Moving out of the accepted statuses takes the hacker roles back; moving in can give them, so a judge who is moved to approved after confirming gets the flower role at once. |
| Unlink | `unlinkDiscord`: the roles are zeroed with the stored token before the row is deleted. If Discord cannot be reached the unlink fails with an error and nothing is deleted. |
| Linking a different Discord account | `completeLink` zeroes the old account first, with the old account's token, then stores the new link. If the old account cannot be reached the link does not move. Linking X, unlinking, then linking Y, or linking Y straight over X, leaves the roles only on Y. |

Expand All @@ -49,7 +51,7 @@ If Discord answers `invalid_grant` to a refresh, the person withdrew the connect
Not covered:

- **Links made before tokens were stored** have no token, so their roles cannot be changed from here. Today that is hackers' `accepted`, flower and Ramadan values, since judges and volunteers could not link before. To revoke one by hand, ask the person to remove the Hacklytics connection under Discord Settings > Connections, or to press "Update my roles" in the portal (which stores a token, after which everything above applies). Taking the server role away by hand is not enough on its own: Linked Roles lets them claim it again while their metadata still qualifies.
- **An edition ending** does not clear anything. A judge or volunteer role stays on until the person is removed, unlinks or their term expires. Hacker roles stay too.
- **An edition ending** clears its roles. `rolesFor` gives no hacker, judge or volunteer role for a `completed` or `cancelled` edition. Moving an edition to either (or back) with `hackathon.update` marks everyone linked who held a role for it pending, in the status transaction (`markEditionRolesPending`: participants, judges, approved volunteer applicants and the volunteer staff tier, whose role follows whichever editions are live), then syncs up to 100 of them inline. The daily job takes the rest, 15 a run, so a large edition takes days to clear fully.
- There is no way to un-confirm "I'm coming" from the portal; an organizer changing the status is what takes a hacker's roles back.
- A person whose roles apply in more than one live edition is synced for the newest, the same one a fresh link uses.

Expand All @@ -66,7 +68,8 @@ Not covered:

- Judges: a card at the top of the judge page (`/judge`). It reads "Join the Hacklytics Discord. It's required for judges: schedules and room changes are posted there." The approval email and the added-by-organizer email say the same and point to the portal step.
- Volunteers: the same card at the top of the check-in desk (`/scan`): "It's required for volunteers: shifts and desk changes are posted there." There is no volunteer email, because a volunteer is added on the staff page and nothing is sent; the card is the notice.
- Someone who is both reads "judges and volunteers". After linking they return to the page the card is on (hackers to the hackathon page, judges to `/judge`, volunteers to `/scan`), or go on to the server invite.
- A volunteer who was approved without the staff tier sees the same card on their application page (`/hackathons/<slug>/volunteer`) once the application is confirmed, and returns there after linking.
- Someone who is both reads "judges and volunteers". After linking they return to the page the card is on (hackers to the hackathon page, judges to `/judge`, staff-tier volunteers to `/scan`, approved applicants to their application page), or go on to the server invite.
- Judges and volunteers have no flower and no Ramadan choice.

## Flowers
Expand Down
6 changes: 3 additions & 3 deletions docs/features/hackathons.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Roles come from `packages/api/src/middleware/procedures.ts`. `isAdmin` is full s
| `list` | public | Hides `draft` and non-public editions for non-admins. Cached per caller type. |
| `listAll` | admin | Every edition. |
| `getById` | public | Takes an id, exact name or slug. |
| `create`, `update` | admin | Names must be unique, since they appear in admin links. End must follow start. |
| `create`, `update` | admin | Names must be unique, since they appear in admin links. End must follow start. Moving an edition to `completed` or `cancelled` (or back) marks its linked Discord accounts pending in the same transaction and syncs up to 100 inline; the daily job takes the rest (see [Discord](./discord.md#taking-roles-back)). |
| `delete` | super admin | Needs `confirmName` typed to match. Every child table (participants, teams, projects, events, announcements, legacy votes and results, all `judging_*`, points and store) cascades. |

### Acceptance (`admin.ts`)
Expand Down Expand Up @@ -128,7 +128,7 @@ Audiences: `interested`, `registered`, `approved`, `checked_in`, `not_accepted`,

### Bans (`bans.ts`)

`listBans`, `banFromHackathons`, `liftHackathonBan`. A ban is keyed by lowercase email in `hackathon_ban` and leaves club membership alone. Enforcement is the `notHackathonBanned` procedure, used by `register`, `registerInterest`, `updateMyRegistration`, `confirmAttendance`, `createTeam`, `joinTeam`, `submitProject`, the event-code `checkIn`, judge `register` and `judging.hacker.claimByEmail`, `claimByToken` and `invite`. Withdrawing is not blocked. Ban and unban write audit records and clear the ban cache.
`listBans`, `banFromHackathons`, `liftHackathonBan`. A ban is keyed by lowercase email in `hackathon_ban` and leaves club membership alone. It also rejects the person's registrations and declines their pending and approved volunteer applications in every edition that is not over, in the same transaction, and syncs their Discord roles. Enforcement is the `notHackathonBanned` procedure, used by `register`, `registerInterest`, `updateMyRegistration`, `confirmAttendance`, `createTeam`, `joinTeam`, `submitProject`, the event-code `checkIn`, judge `register` and `judging.hacker.claimByEmail`, `claimByToken` and `invite`. Withdrawing is not blocked. Ban and unban write audit records and clear the ban cache.

### Volunteers (`routers/volunteer/`)

Expand All @@ -143,7 +143,7 @@ A volunteer runs the weekend (check-in, meals, rooms, help for hackers). It is i
- **Organizers** (Volunteers tab next to Judges in the hackathon admin): `volunteer.list` (filters: status, type, in-person role and time block, mentor topic and online hour; coverage counts per time block and role for the venue and per online hour and topic for mentoring, plus how many chose each type, all split approved and pending and taken over everyone so the counts do not move with the filters; someone who chose both counts in both halves), `volunteer.decide` (approve or decline; `isAdmin`, so bug testers and scanner volunteers are refused; audited as `volunteer.approve` and `volunteer.decline`; either can follow the other; a withdrawn application cannot be decided) and `volunteer.exportApplications` (the filtered rows, audited as `volunteer.export`). `list` and `exportApplications` also refuse bug testers: the answers hold phone numbers. The CSV is built in the browser by `lib/volunteer-csv.ts` and carries the type, and the mentor's topics, hours and experience beside the venue's answers.
- **Emails** (`sendVolunteerApprovedEmail`, `sendVolunteerDeclinedEmail`, Hacklytics theme for a Hacklytics edition): sent once, on the transition into the status, and best-effort. Nothing is sent on submit. The approval says what their type means: shifts and venue details for in person, the Discord's mentor channels for online, both for both.
- **Approving does not grant the `volunteer` staff tier.** That tier is check-in scanner access, and organizers still grant it deliberately on the Staff page. The Volunteers tab says so.
- **Discord.** Eligibility for the volunteer Discord role should use `isApprovedVolunteer(db, userId, hackathonId)` from `@query/api/volunteer` (`packages/api/src/services/volunteer.ts`), not the staff tier and not the table directly. It is true only for an `approved` application at that edition, so a withdrawal or a decline takes it away.
- **Discord.** An `approved` application makes the person eligible for the volunteer Discord role, like the staff tier does (see [Discord](./discord.md)). The role code asks `isApprovedVolunteer` / `approvedVolunteerEditions` in `packages/api/src/services/volunteer.ts`, never the table. `volunteer.decide` (approve or decline) and `volunteer.withdraw` re-sync the person's roles after commit, so a decline or a withdrawal takes the role back. The confirmed state of the application page carries the Discord card.
- **Phone.** It lives in `answers.phone` and is only used for contact during the event. Nothing deletes it afterwards yet.

### Content (`content.ts`)
Expand Down
Loading
Loading