fix: contributeToEvent computed XP but never awarded it — call award_xp_secure (#220) - #232
Open
vedant7007 wants to merge 2 commits into
Open
fix: contributeToEvent computed XP but never awarded it — call award_xp_secure (#220)#232vedant7007 wants to merge 2 commits into
vedant7007 wants to merge 2 commits into
Conversation
…rzoo0511#220) contributeToEvent computed `totalToAward = totalXpAwarded + baseXp`, labelled the block "Award XP via secure RPC", then returned the number as `xpAwarded` without ever calling the RPC. Users saw a "+N XP" toast on every event contribution but nothing landed in xp_ledger, user_stats stayed stale, streaks didn't advance, and event_participation-gated badges never unlocked. Route the award through supabase.rpc('award_xp_secure', ...) — same RPC every other client-side award (save_game_score_secure siblings, gamification.awardXP) uses — with the event context passed through p_metadata so the ledger row is queryable. Prefer the RPC's returned final_xp so what the UI shows matches what's persisted; fall back to the client-computed value if the RPC omits it. If the RPC call errors, keep the contribution row committed (it was already written a few steps earlier and rolling it back risks losing user progress) and log the failure — a subsequent retry can catch up. Fixes arzoo0511#220
|
@vedant7007 is attempting to deploy a commit to the arzoorai0207-5745's projects Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Author
|
hey! heads up — the failing this PR doesn't touch |
3 tasks
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.
Summary
`contributeToEvent` computed `totalToAward = totalXpAwarded + baseXp`, labelled the block "Award XP via secure RPC", then returned the number as `xpAwarded` without ever calling any RPC. Every event contribution showed the user a "+N XP" toast for XP that was never actually persisted:
What changed
Test plan
Fixes #220