mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-16 07:33:06 +08:00
The Responses WebSocket handler reads the API key auth snapshot once at connect and reuses it for every turn: RecordUsage takes the group pricing from that snapshot, and the profit gate reinstalled in BeforeTurn takes its selling price from the connect-time ctxkey.Group. A group price change therefore never reaches an open connection until the client reconnects, while HTTP requests pick it up once the auth cache entry is invalidated. Each later turn now re-reads the key through APIKeyService.GetByKey (the auth cache the middleware uses) in BeforeTurn. When the key ID, group ID, group platform and subscription type are unchanged, the fresh group is swapped into ctxkey.Group for the turn's profit gate and passed to that turn's RecordUsage. A failed lookup or a key moved to another group keeps the connection snapshot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>