OSRS account types (game modes) on players - #48
Merged
Conversation
Accept an optional account_type field (RuneLite varbit 1777 wire string)
on intake submissions, persist it last-write-wins on the player row, and
expose it on GET /api/v1/players/{id}.
- data/submissions/common.py: VALID_ACCOUNT_TYPES + apply_account_type()
— validates against the seven-mode enum, normalizes case/whitespace,
and silently ignores invalid/absent values so intake never fails on it.
Seasonal (League) worlds never write: separate game accounts whose mode
says nothing about the main account.
- All eight processors call it right after the auth check passes, so
unauthenticated submissions cannot flip a player's mode. Covers direct
intake, queue mode, the legacy webhook bot, and manual submissions.
- Player.account_type column (String(32), nullable). Migration
web91a_player_account_type lives untracked in alembic/versions/ per
repo convention; verify `alembic heads` on the deploy box first.
- Web API v1: profile payload includes account_type when set, omits it
when never reported. OpenAPI PlayerProfile gains the optional enum
property matching the web repo's AccountTypeSchema.
- tests/unit/test_account_types.py: helper validation, de-iron
overwrite, profile exposure/omission, OpenAPI contract pin.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
Adds an optional
account_typefield (OSRS game mode from RuneLite varbit 1777) that flows from intake submissions to the player row to the Web API v1 profile payload. The frontend (droptracker-web PR #18) is already built against this contract and tolerates the field being absent.apply_account_type()indata/submissions/common.pyvalidates the wire string against the seven-mode enum and stores it last-write-wins (a de-ironed account downgrades tonormalon its next submission). Invalid or absent values are ignored and can never fail a submission. Each of the eight processors calls it in one added line after the auth check, so spoofed submissions can't flip a player's mode. Covers direct intake, queue mode, the legacy webhook bot, and manual submissions.account_type— a league account's varbit says nothing about the main account's mode. One-line gate to remove if undesired.Player.account_type(String(32)). Migrationweb91a_player_account_typeis authored but not in this PR —alembic/versions/is gitignored per repo convention. Deploy step: create it on the deploy box (addsplayers.account_type VARCHAR(32) NULL) withdown_revisionpointed at the currentalembic heads(web90a_site_page_cssat authoring time). No backfill; populates organically.GET /api/v1/players/{id}returnsaccount_typewhen set, omits it when never reported.PlayerProfilegains the optionalaccount_typeenum property, matching the web repo'sAccountTypeSchema.Test plan
python -m pytest tests/unit/ -q— 4276 passed, 2 skipped, including 11 new tests intests/unit/test_account_types.py(written TDD-first): helper validation/normalization, last-write-wins de-iron overwrite, invalid/absent/seasonal ignored, never-raises, profile route returning vs. omitting the field, OpenAPI enum pinned to the spec's seven values. (One unrelated pre-existing failure locally:test_submission_received_at.py::test_tz_aware_stamps_are_converted_not_rejectedfails identically on a cleannew-apicheckout on this machine — timezone-dependent assertion.)web91a_player_account_typemigration on the deploy box.openapi.json+pnpm gen:api-types; coordinate the RuneLite plugin release that sends the field.🤖 Generated with Claude Code