feat(dashboard): add Bunkx shortcut in overflow menu#16
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughDashboard FAB gains a new "Bunkx" action that closes the FAB, collects attendance data from the attendance store, builds and encodes a Bunkx-formatted attendance payload, and opens Changes
Sequence Diagram(s)sequenceDiagram
participant UI as Dashboard (FAB)
participant Store as Attendance Store
participant Utils as Bunkx Utils
participant OS as Linking / External Browser
UI->>UI: User taps "Bunkx" FAB action
UI->>UI: Close FAB menu
UI->>Store: read courses & lastSyncTime
Store-->>UI: courses, lastSyncTime
UI->>Utils: buildBunkxAttendancePayload(courses, lastSyncTime)
Utils-->>UI: BunkxAttendancePayload
UI->>Utils: encodeBunkxPayload(payload)
Utils-->>UI: encodedString
UI->>OS: Linking.openURL("https://bunkx-iiitk.vercel.app/?payload="+encodedString)
OS-->>UI: success / error
alt error
UI->>UI: Toast.show(error.message)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Preview |
|
Preview |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/app/`(tabs)/index.tsx:
- Around line 243-257: The handleOpenBunkx flow currently closes the FAB and
calls getCredentials() and Linking.openURL() without error handling; wrap the
async IIFE inside handleOpenBunkx in a try/catch, call setShowFabMenu(false)
before the try, and on any error call Toast.show(...) with a user-friendly
message (and optionally include error.message for debugging), and ensure the
error does not leave the app in an inconsistent state; reference
handleOpenBunkx, getCredentials, Linking.openURL, setShowFabMenu, and Toast.show
when making the change.
- Line 12: The code currently embeds the raw LMS password returned by
getCredentials() into the Bunkx URL (https://username:password@...), leaking
secrets; change the flow so you never serialize the password into a URL—use a
short‑lived token, OAuth callback, auth header, or an API gateway token instead
(generate/exchange the credential server‑side or request a temp token and append
only that token or perform a POST auth flow). Also wrap the getCredentials()
call and Linking.openURL(...) in try/catch, surface failures via the app
toast/user feedback system, and handle errors (e.g., fallback UI or copy link)
so failures don’t fail silently; update the code around getCredentials, the URL
construction, and the Linking.openURL invocation to implement these changes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a86ec913-1e0b-4d85-87ca-057ba32f0634
📒 Files selected for processing (1)
src/app/(tabs)/index.tsx
|
Preview |
Noelithub77
left a comment
There was a problem hiding this comment.
pass the bunk data as a base4 encoded url parameter instead of username password
Noelithub77
left a comment
There was a problem hiding this comment.
pass the bunk data as a base4 encoded url parameter instead of passing username password over url parameters, you won't have to handle auth again too
/bunkialo?bunkdata={$base64 from bunkialo}
|
Preview |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/utils/bunkx-payload.ts`:
- Around line 71-85: parseFacultyDetails is currently extracting and returning
raw email-like tokens (faculty_email) from free text, which then gets serialized
by toAttendanceRows; remove this disclosure by stopping extraction/storage of
email addresses and ensuring the faculty value contains no email. Modify
parseFacultyDetails to not populate or return faculty_email (remove the
faculty_email variable from the returned object) and sanitize
facultyFromLabel/facultyFromEmail by stripping any email-like substrings before
returning (use the existing parsing logic but drop anything matching
/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/i). Also update toAttendanceRows (and any
serializer that consumes parseFacultyDetails) to stop including faculty_email in
the exported payload and only use the sanitized faculty string.
- Around line 138-145: The payload uses referenceMs = lastSyncTime ?? nowMs
which can make dataset_expires_at immediately expired when lastSyncTime is old;
change referenceMs to the later of nowMs and lastSyncTime (e.g. referenceMs =
Math.max(nowMs, lastSyncTime ?? nowMs)) so dataset_expires_at = new
Date(referenceMs + 30*60*1000).toISOString() (and keep dataset_id based on that
same referenceMs) to guarantee the dataset expires 30 minutes from "now" rather
than from an old sync timestamp.
- Around line 45-50: The code using new Date(year, month, day) (see variables
parsed and fallbackMs and the toIsoDate return) should detect silent
normalization of overflowed dates — after constructing parsed, verify that
parsed.getFullYear() === year, parsed.getMonth() === month, and parsed.getDate()
=== day (and use Number.isNaN(parsed.getTime()) for strict TypeScript checks);
if any check fails, treat it as invalid and return toIsoDate(new
Date(fallbackMs)), otherwise return toIsoDate(parsed).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: afa54560-824a-4249-9b77-db97a6ce9259
📒 Files selected for processing (3)
src/app/(tabs)/index.tsxsrc/types/attendance.tssrc/utils/bunkx-payload.ts
✅ Files skipped from review due to trivial changes (1)
- src/types/attendance.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/app/(tabs)/index.tsx
|
Preview |
There was a problem hiding this comment.
♻️ Duplicate comments (2)
src/utils/bunkx-payload.ts (2)
45-50:⚠️ Potential issue | 🟠 MajorValidate overflowed calendar dates after
Dateconstruction.Line 45 can silently normalize invalid dates (e.g., Feb 31), and Line 46 won’t catch that. This can shift attendance to the wrong day.
🩹 Proposed fix
const parsed = new Date(year, month, day); - if (isNaN(parsed.getTime())) { + if ( + Number.isNaN(parsed.getTime()) || + parsed.getFullYear() !== year || + parsed.getMonth() !== month || + parsed.getDate() !== day + ) { return toIsoDate(new Date(fallbackMs)); }In JavaScript, does `new Date(year, monthIndex, day)` normalize overflow dates (like February 31) instead of returning `Invalid Date`, and is comparing the resulting year/month/day the recommended way to validate strict calendar input?🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/utils/bunkx-payload.ts` around lines 45 - 50, The code currently constructs parsed = new Date(year, month, day) which silently normalizes overflow dates (e.g., Feb 31 -> Mar 3); instead after creating parsed compare parsed.getFullYear(), parsed.getMonth(), and parsed.getDate() against the original year, month, and day inputs and if any component differs return toIsoDate(new Date(fallbackMs)); otherwise return toIsoDate(parsed). Update the block that sets parsed and the conditional to perform this strict component validation so invalid calendar inputs don't get normalized into wrong dates (referencing parsed, toIsoDate, and fallbackMs).
66-89:⚠️ Potential issue | 🟠 MajorStop exporting email addresses in the Bunkx payload.
Line 71 extracts email-like tokens from free text, and Line 127 exports them. Since this payload is sent to an external site, this creates a new PII disclosure path.
🩹 Minimal mitigation
const parseFacultyDetails = ( description: string, remarks?: string, ): { faculty: string; faculty_email: string } => { const source = `${description} ${remarks ?? ""}`.trim(); - const emailMatch = source.match(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/i); - const faculty_email = emailMatch?.[0] ?? ""; + const emailMatch = source.match(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/i); const facultyLabelMatch = source.match( /(?:faculty|teacher|staff|by)\s*[:\-]\s*([^,;|]+)/i, ); - const facultyFromLabel = facultyLabelMatch?.[1]?.trim(); + const facultyFromLabel = (facultyLabelMatch?.[1] ?? "") + .replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi, "") + .trim(); - const facultyFromEmail = faculty_email + const facultyFromEmail = emailMatch?.[0] ? faculty_email .split("@")[0] .replace(/[._-]+/g, " ") .trim() : ""; return { faculty: facultyFromLabel || facultyFromEmail || "Unknown", - faculty_email, + faculty_email: "", }; };Also applies to: 116-127
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/utils/bunkx-payload.ts` around lines 66 - 89, The function parseFacultyDetails currently extracts and returns an email (emailMatch -> faculty_email) and builds a fallback faculty name from it (facultyFromEmail); remove any email extraction/export to avoid PII leakage by eliminating the use of emailMatch and faculty_email, always returning faculty_email as an empty string, and stop deriving facultyFromEmail from an address—only use facultyLabelMatch (from description/remarks) as the source of faculty name and otherwise fall back to "Unknown". Update references in parseFacultyDetails and any callers that expect a non-empty faculty_email so they handle an empty string safely.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@src/utils/bunkx-payload.ts`:
- Around line 45-50: The code currently constructs parsed = new Date(year,
month, day) which silently normalizes overflow dates (e.g., Feb 31 -> Mar 3);
instead after creating parsed compare parsed.getFullYear(), parsed.getMonth(),
and parsed.getDate() against the original year, month, and day inputs and if any
component differs return toIsoDate(new Date(fallbackMs)); otherwise return
toIsoDate(parsed). Update the block that sets parsed and the conditional to
perform this strict component validation so invalid calendar inputs don't get
normalized into wrong dates (referencing parsed, toIsoDate, and fallbackMs).
- Around line 66-89: The function parseFacultyDetails currently extracts and
returns an email (emailMatch -> faculty_email) and builds a fallback faculty
name from it (facultyFromEmail); remove any email extraction/export to avoid PII
leakage by eliminating the use of emailMatch and faculty_email, always returning
faculty_email as an empty string, and stop deriving facultyFromEmail from an
address—only use facultyLabelMatch (from description/remarks) as the source of
faculty name and otherwise fall back to "Unknown". Update references in
parseFacultyDetails and any callers that expect a non-empty faculty_email so
they handle an empty string safely.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2bdc9ca6-3411-49c9-851b-f42ccdaae673
📒 Files selected for processing (1)
src/utils/bunkx-payload.ts
|
Preview |
|
Preview |
|
Preview |
|
Da tested... works |
Summary
Testing