Skip to content

OSRS account types (game modes) on players - #48

Merged
joelhalen merged 1 commit into
new-apifrom
task-23-account-types
Aug 17, 2026
Merged

OSRS account types (game modes) on players#48
joelhalen merged 1 commit into
new-apifrom
task-23-account-types

Conversation

@yonnski

@yonnski yonnski commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds an optional account_type field (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.

  • Intake: apply_account_type() in data/submissions/common.py validates the wire string against the seven-mode enum and stores it last-write-wins (a de-ironed account downgrades to normal on 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.
  • Seasonal guard (judgment call): League/seasonal-world submissions never write account_type — a league account's varbit says nothing about the main account's mode. One-line gate to remove if undesired.
  • Storage: nullable Player.account_type (String(32)). Migration web91a_player_account_type is authored but not in this PRalembic/versions/ is gitignored per repo convention. Deploy step: create it on the deploy box (adds players.account_type VARCHAR(32) NULL) with down_revision pointed at the current alembic heads (web90a_site_page_css at authoring time). No backfill; populates organically.
  • Web API v1: GET /api/v1/players/{id} returns account_type when set, omits it when never reported.
  • OpenAPI: PlayerProfile gains the optional account_type enum property, matching the web repo's AccountTypeSchema.

Test plan

  • python -m pytest tests/unit/ -q — 4276 passed, 2 skipped, including 11 new tests in tests/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_rejected fails identically on a clean new-api checkout on this machine — timezone-dependent assertion.)
  • Author + run the web91a_player_account_type migration on the deploy box.
  • Web repo re-vendors openapi.json + pnpm gen:api-types; coordinate the RuneLite plugin release that sends the field.

🤖 Generated with Claude Code

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>
@yonnski yonnski changed the title Task 23: OSRS account types (game modes) on players OSRS account types (game modes) on players Aug 16, 2026
@joelhalen
joelhalen merged commit 32b37ae into new-api Aug 17, 2026
3 checks passed
@joelhalen
joelhalen deleted the task-23-account-types branch August 17, 2026 10:11
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.

2 participants