[Feature] ReadMeABook Admin Approvals + Request Notifications - #294
Draft
NichCodes wants to merge 7 commits into
Draft
[Feature] ReadMeABook Admin Approvals + Request Notifications#294NichCodes wants to merge 7 commits into
NichCodes wants to merge 7 commits into
Conversation
Adds an admin-only "Approvals" tab to the ReadMeABook config drawer so RMAB admins can review and approve/deny pending requests directly from Absorb instead of the RMAB web UI. - rmab_service: listPendingApprovals() + respondToApproval(), plus RmabPendingApproval/RmabApprovalRequester models. - rmab_config_sheet: cache the connected token's RMAB role (with a me() backfill for existing connections) and gate a third Approvals tab on it. New _ApprovalsTab with one-tap approve, deny-with-confirm, optimistic row removal, per-row spinners, and friendly forbidden/stale handling. The tab uses its own scroll controller to avoid sharing the sheet's. - l10n: new rmabApproval* strings. Requires the RMAB server to allowlist GET /api/admin/requests/ pending-approval and POST /api/admin/requests/:id/approve for API tokens (admin-gated).
The Approvals tab is gated on the connected token's RMAB role, cached at connect time. Refresh it via me() on every open so a server-side role change is reflected without reconnecting (demoted admin loses the tab, promoted user gains it). Fails closed on error.
Shows admins a count badge + subtitle on the ReadMeABook settings tile so pending approvals are visible without opening the drawer. The count comes from listPendingApprovals() (admin-only, so a 403 just clears the badge); refreshed on settings load and whenever the drawer closes.
Periodically polls pending approvals in the background (background_fetch: iOS BGTaskScheduler / Android WorkManager) and fires a local notification when new requests appear since the last check. Tapping it opens the RMAB drawer on the Approvals tab. Opt-in via a toggle on the ReadMeABook settings tile (shown only to RMAB admins); off by default. iOS background execution is throttled by the OS, so delivery is best-effort — the in-app badge and Approvals tab remain the reliable surface. - rmab_approvals_notifier: notifications init, background_fetch config + headless task, new-id baseline diff, and deep-link routing. - rmab_config_sheet: initialApprovals opens the drawer on the Approvals tab. - settings: admin-only toggle with permission handling. - ios: BGTaskSchedulerPermittedIdentifiers + static pod linkage for the TSBackgroundFetch xcframework.
Prevent path traversal via malformed ids in getRequest and respondToApproval, and replace the hardcoded English count string in the Approvals tab with the existing adminRmabApprovalsPending l10n entry.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NOTE:
I'm keeping this as a draft as it's dependent on ReadMeABook adding the request and approve API calls to the token allowlist. I've got a PR to add it (among other things) on their GitHub page, but this feature won't work until it's approved. I'll try to remember to come back and pull it out of draft if/when it's added.
Also I haven't been able to really put the notifications through their paces, especially on non-iOS platforms. I can cut the notifications stuff from this PR if you'd rather implement proper push notifications later (which this is not). Just lemme know either way.
Summary
me()each time the drawer opens, so promotions/demotions take effect without reconnectingbackground_fetch+flutter_local_notifications) that poll for new pending approvals and fire a local notification when new requests appear — tapping the notification opens the drawer directly on the Approvals tabDetails
Service Layer (
rmab_service.dart):listPendingApprovals()— GET/api/admin/requests/pending-approvalrespondToApproval(id, approve:)— POST/api/admin/requests/:id/approveRmabPendingApproval,RmabApprovalRequesterApprovals Tab (
rmab_config_sheet.dart):Background Notifier (
rmab_approvals_notifier.dart):Settings Screen:
_refreshRmabApprovalsBadge)SwitchListTile) conditionally shown for admin tokensScreenshot