feat: attendance marking + spam prevention - #701
Conversation
|
@palxsh01 is attempting to deploy a commit to the Prashantkumar Khatri's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Hi @palxsh01, Thanks for opening this pull request. This PR has been automatically classified based on the files modified. Applied Labels
Primary Review Area
Reviewer@Harxhit has been identified as the primary reviewer for this pull request. If you have any questions regarding the affected area or implementation details, feel free to reach out to the assigned reviewer. Thank you for your contribution! |
CI — All Checks PassedBackend — PASS
Mobile — SKIP
Web — PASS
Last updated: |
|
Hi @Harxhit, |
|
Hi @Harxhit, |
|
Hi @Harxhit, |
Summary
Lets a signed-in user mark themselves as attending an event (hackathon) as a Participant / Organizer / Mentor and leave again, with two independent guardrails against "attendance spam" (marking every hackathon without actually attending): a hard rate limit and a soft heuristic flag. Adds the web UI, the
rolefield, the anti-spam logic, tests, and docs.Closes #693
Type of Change
What Changed
Backend (
apps/backend)prisma/schema.prisma— newAttendeeRoleenum (PARTICIPANT | ORGANIZER | MENTOR) androle/flaggedcolumns onEventAttendee;joinedAtnow defaults tonow(); added@@index([userId, joinedAt])to back the spam-count query. Migration20260722181416_attendee_role_and_spam_flagincluded.src/validations/event.validation.ts—joinEventSchemaaccepts an optionalrole(defaults toPARTICIPANT).src/routes/event.ts—POST /:slug/joinvalidates/persistsroleand returns{ message, role, flagged }; two anti-spam layers: a route-level rate limit (10 req/min → 429) and a heuristic soft-flag (≥8 joins in a 5-min window ⇒flagged = true+ audit log, join still succeeds).GET /:slug/attendeesnow exposes each attendee's publicrole;flaggedis never exposed.Web (
apps/web)src/pages/EventPage.tsx+.css— new/events/:slugpage: event details, attendee count, role picker, mark/leave attendance, and a public attendee list with role badges. Handles 401 / 409 / 429 gracefully.src/lib/api.ts—apiFetchextended to support authenticated non-GET requests (Bearertoken fromlocalStorage['devcard-token']), a typedApiError, and 204 handling.src/App.tsx— registered the/events/:slugroute.src/shared/types.ts+index.ts— addedEventDetail,EventAttendee,AttendeeRole.Docs
README.md— new "Events & Attendance" section: endpoints, join example, error cases, and the Attendance spam rules (what triggers a flag vs. a block).apps/web/README.md— "Pages" table (incl./events/:slug) and an "Authentication for attendance" note on thedevcard-tokenflow.How to Test
npm run db:migrate, thennpm run dev:backendandnpm run dev:web.localStorage.setItem('devcard-token', '<your-jwt>')./events/<slug>: pick a role, click Mark attendance → count increments and a role badge appears. Click Leave event → count decrements. Re-marking returns "already attending" (409 path).flagged = true(join still succeeds); exceeding 10 joins/min returns 429.npm --prefix apps/backend run test(backendevent.test.ts, 40 passed) and theapps/webVitest suite (test/EventPage.test.tsx, 4 passed).Checklist
npm run lintpasses).npm run typecheck --workspaces --if-present).npm run test --workspaces --if-present).console.logor debug statements left in the code.Additional Context
localStorage. Documented inapps/web/README.md; a full login flow is out of scope here.20260722181416_attendee_role_and_spam_flag/migration.sqlwas hand-authored (no DB was reachable in the dev environment). A reviewer should runprisma migrate devagainst a real Postgres to confirm the checksum and history.SPAM_WINDOW_MINUTES,SPAM_MAX_JOINS) inapps/backend/src/routes/event.ts.