refactor: move the Plex switch-token parser in with the Plex models
user_switch_response.dart was left holding a single 13-line function after UserSwitchResponse's decorative fields were dropped, so the filename no longer described its contents and it sat at lib/models/ root while every other Plex model lives in lib/models/plex/. Renamed to lib/models/plex/plex_switch_response.dart, with the test moved alongside the other plex_*_test.dart files. The parser stays public so the #1488 drift characterization tests keep exercising it directly.
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
/// INVARIANT (#1488): a successful token mint must never be lost to parsing
|
||||
/// of decorative fields. `authToken` is the only field any caller consumes
|
||||
/// (see plex_home_switch.dart), so nothing else on the `/switch` body is
|
||||
/// read. Plex has changed field shapes on this endpoint before (July 2026:
|
||||
/// profile language lists became CSV strings), and each drift used to brick
|
||||
/// token minting outright.
|
||||
String parsePlexSwitchAuthToken(Map<String, dynamic> json) {
|
||||
final authToken = json['authToken'];
|
||||
if (authToken is! String || authToken.isEmpty) {
|
||||
throw const FormatException('Plex /switch response has no usable authToken');
|
||||
}
|
||||
return authToken;
|
||||
}
|
||||
Reference in New Issue
Block a user