Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions lib/config/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ class AppConstants {
'$apiBase/settings/ai-providers/keys/$provider';
static String settingsAiSelection(String role) =>
'$apiBase/settings/ai-providers/selection/$role';
static const String settingsChatgptLogin = '$apiBase/settings/chatgpt-login';
static const String settingsChatgptLoginPoll =
'$apiBase/settings/chatgpt-login/poll';
static const String channels = '$apiBase/channels';
static const String channelSubscribe = '$apiBase/channels/subscribe';
static const String channelSubscribeBulk = '$apiBase/channels/subscribe-bulk';
Expand Down
54 changes: 1 addition & 53 deletions lib/models/ai_providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class AiProvidersStatus {
final AiSelection embed;
final AiSelection rank;

/// Per-provider "usable right now", including `chatgpt` (sign-in based).
/// Per-provider "usable right now" (anthropic / gemini / openai).
final Map<String, bool> availability;

factory AiProvidersStatus.fromJson(Map<String, dynamic> json) {
Expand All @@ -104,55 +104,3 @@ class AiProvidersStatus {
);
}
}

/// Status of the ChatGPT (Codex OAuth) sign-in.
class ChatgptLoginStatus {
const ChatgptLoginStatus({
required this.connected,
required this.needsReauth,
required this.pending,
required this.userCode,
required this.verificationUrl,
});

final bool connected;
final bool needsReauth;
final bool pending;

/// Device code to enter (only while a sign-in is pending).
final String? userCode;
final String? verificationUrl;

factory ChatgptLoginStatus.fromJson(Map<String, dynamic> json) =>
ChatgptLoginStatus(
connected: json['connected'] == true,
needsReauth: json['needs_reauth'] == true,
pending: json['pending'] == true,
userCode: json['user_code'] as String?,
verificationUrl: json['verification_url'] as String?,
);
}

/// One poll of the device sign-in.
class ChatgptPollResult {
const ChatgptPollResult({
required this.status,
required this.detail,
required this.userCode,
required this.verificationUrl,
});

/// idle | pending | connected | expired | error
final String status;
final String? detail;
final String? userCode;
final String? verificationUrl;

factory ChatgptPollResult.fromJson(Map<String, dynamic> json) =>
ChatgptPollResult(
status: (json['status'] as String?) ?? 'idle',
detail: json['detail'] as String?,
userCode: json['user_code'] as String?,
verificationUrl: json['verification_url'] as String?,
);
}
30 changes: 0 additions & 30 deletions lib/services/api_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -531,36 +531,6 @@ class ApiService {
return AiProvidersStatus.fromJson(r.data as Map<String, dynamic>);
});

// --- ChatGPT (Codex OAuth) sign-in (admin) --------------------------------

Future<ChatgptLoginStatus> getChatgptLogin() => _guard(() async {
final r = await _dio.get('$_baseUrl${AppConstants.settingsChatgptLogin}');
return ChatgptLoginStatus.fromJson(r.data as Map<String, dynamic>);
});

Future<ChatgptPollResult> startChatgptLogin() => _guard(() async {
final r = await _dio.post('$_baseUrl${AppConstants.settingsChatgptLogin}');
// The start response has the same shape as a pending poll.
final data = r.data as Map<String, dynamic>;
return ChatgptPollResult(
status: 'pending',
detail: null,
userCode: data['user_code'] as String?,
verificationUrl: data['verification_url'] as String?,
);
});

Future<ChatgptPollResult> pollChatgptLogin() => _guard(() async {
final r = await _dio.post(
'$_baseUrl${AppConstants.settingsChatgptLoginPoll}',
);
return ChatgptPollResult.fromJson(r.data as Map<String, dynamic>);
});

Future<void> clearChatgptLogin() => _guard(() async {
await _dio.delete('$_baseUrl${AppConstants.settingsChatgptLogin}');
});

/// Records an evictable cache claim on [videoId] and (server-side) kicks off
/// its HQ download, without it showing in the Downloads tab. Called when the
/// user starts instant playback of a not-yet-downloaded video so the player
Expand Down
Loading
Loading