Skip to content

Staging -> Main - #514

Merged
gamatraindev merged 11 commits into
mainfrom
staging
Jul 17, 2026
Merged

Staging -> Main#514
gamatraindev merged 11 commits into
mainfrom
staging

Conversation

@sanaderi

Copy link
Copy Markdown
Collaborator

No description provided.

sanaderi and others added 11 commits July 13, 2026 11:13
GET legacy-auth/logout proxies gama-api's own GET /users/logout, relaying
the caller's raw legacy JWT from the Authorization header. Pure passthrough
like register/recovery - this backend never stored the token, so gama-api
is the one actually invalidating the session, closing the gap where
tokens/revoke couldn't touch a legacy-bridge session.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
New POST downloads/tests resolves a gama-api legacy test-file download URL
through a new IContentDeliveryProvider (ContentSource-keyed, mirroring the
payment-gateway provider pattern), charges the downloader via the existing
quota-then-points path only when gama-api hasn't already marked the download
paid, and accrues a commission to the content's owner (resolved from
gama-api's CoreId) only if that charge succeeds - a new ContentOwnerCommission
ledger, deliberately kept separate from the points wallet and subscription
quota. Commission percent and payout threshold are admin-configurable via
ApplicationSettings; the points-to-USD rate is a fixed first-phase constant.
Payout itself is out of scope for this phase.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…tPaper

POST downloads (renamed from downloads/tests) now dispatches on ContentType
to one of gama-api's three download endpoints: PastPaper/Test -> tests/download
(unchanged), Multimedia -> files/download, Exam -> exams/download. Confirmed
live that the latter two report neither a price nor an owner, so charging and
commission accrual are skipped entirely for those two types - only
PastPaper/Test involve SpendPointsAsync/ContentOwnerCommission.

Also collapses GameService.SpendPointsAsync's PastPaper/Test branch: both are
the same gama-api content (/tests/download), so both now charge
FeatureCodes.PastpaperDownload/TransactionType.DownloadPastPaper. The old
TestDownload/DownloadTest members stay defined for historical data but are no
longer written by any code path.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…feature

Reverts the earlier collapse of GameService.SpendPointsAsync's PastPaper/Test
branch - that endpoint is unrelated to this feature and its separate
FeatureCodes.TestDownload/TransactionType.DownloadTest entitlement (already
live on a subscription plan) stays untouched.

GamaApiContentDeliveryProvider now explicitly rejects any ContentType other
than PastPaper/Multimedia/Exam (notably ContentType.Test) with a clear
validation error before attempting a gama-api call. ContentType.Test and
TransactionType.DownloadTest remain defined in their enums only because
migration 20260621193350_TransactionType.cs compiles a reference to both in
a historical data-backfill statement - migrations are immutable, so neither
member can be removed even though this feature no longer accepts Test.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…reality

The broader ContentType enum (shared with the unrelated games/spends
endpoint) still has a Test member, so reusing it here meant Swagger kept
advertising Test as a valid value for POST downloads even after runtime
rejection was added - a client reading the schema had no way to know it
would always fail.

DownloadContentType is a new 3-member enum (PastPaper/Multimedia/Exam) used
only by this feature's request/provider DTOs and ViewModel. A request naming
Test now fails cleanly at model binding (Required on an unparseable enum)
instead of via a bespoke validation message. ContentOwnerCommission and
GameService.SpendPointsAsync are untouched - ContentDeliveryService maps the
one case that ever reaches them (DownloadContentType.PastPaper, the only
type gama-api reports a price for) to ContentType.PastPaper directly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
A real gama-api download can report price.price: 0 with paid: false (e.g.
some extra-file downloads) - the previous logic only skipped the charge for
Paid == true or a missing Points field, so a zero-price item still went
through SpendPointsAsync and wrote a pointless zero-amount Transaction row.
Confirmed live (id 39204/extra/5222): before the fix a Transaction row with
Points: 0 was written on every call; after, none is.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Add legacy-auth-bridge logout endpoint
…sions

Add content delivery + owner commission accounting
…auth login/google/register/recovery

The legacy-auth bridge proxies these calls straight through to gama-api, so
gama-api's own rate-limiting/fraud checks only ever saw this server's IP,
never the actual end user's. IdentityService now reads the caller's IP off
the inbound request (X-Forwarded-For if present, else the raw connection
IP) and CoreProvider sends it as a TRUSTED_FORWARDED_IP header on those four
outgoing calls. logout is unaffected -- gama-api didn't ask for it there.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Forward real client IP to gama-api on legacy-auth login/google/register/recovery
@gamatraindev
gamatraindev merged commit b2cdb2f into main Jul 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants