💥 Updated API routes

This commit is contained in:
2025-10-22 22:51:51 +08:00
parent 2a7d12de48
commit 1ae81794b1
49 changed files with 197 additions and 182 deletions

View File

@@ -14,7 +14,7 @@ part 'credits.g.dart';
@riverpod
Future<double> socialCredits(Ref ref) async {
final client = ref.watch(apiClientProvider);
final response = await client.get('/id/accounts/me/credits');
final response = await client.get('/pass/accounts/me/credits');
if (response.statusCode != 200) {
throw Exception('Failed to load social credits');
}
@@ -39,7 +39,7 @@ class SocialCreditHistoryNotifier extends _$SocialCreditHistoryNotifier
final queryParams = {'offset': offset, 'take': _pageSize};
final response = await client.get(
'/id/accounts/me/credits/history',
'/pass/accounts/me/credits/history',
queryParameters: queryParams,
);
final total = int.parse(response.headers.value('X-Total') ?? '0');

View File

@@ -6,7 +6,7 @@ part of 'credits.dart';
// RiverpodGenerator
// **************************************************************************
String _$socialCreditsHash() => r'2599844e892127ee4d315caced5c10e4dbaea142';
String _$socialCreditsHash() => r'a0284583e94bc97285c689ac2bc018536932da69';
/// See also [socialCredits].
@ProviderFor(socialCredits)
@@ -25,7 +25,7 @@ final socialCreditsProvider = AutoDisposeFutureProvider<double>.internal(
// ignore: unused_element
typedef SocialCreditsRef = AutoDisposeFutureProviderRef<double>;
String _$socialCreditHistoryNotifierHash() =>
r'950db020754160f835c64cedf3fa2175e61e4d64';
r'3e87af246cc5dc72a1f3a87b81d1c87169bdfb5b';
/// See also [SocialCreditHistoryNotifier].
@ProviderFor(SocialCreditHistoryNotifier)

View File

@@ -34,7 +34,7 @@ class LevelingHistoryNotifier extends _$LevelingHistoryNotifier
final queryParams = {'offset': offset, 'take': _pageSize};
final response = await client.get(
'/id/accounts/me/leveling',
'/pass/accounts/me/leveling',
queryParameters: queryParams,
);
final total = int.parse(response.headers.value('X-Total') ?? '0');

View File

@@ -7,7 +7,7 @@ part of 'leveling.dart';
// **************************************************************************
String _$levelingHistoryNotifierHash() =>
r'e795f9b7911c9e50f15c095ea237cb0e87bf1e89';
r'de51012e1590ac46388b6f3f2050b21cb96698d1';
/// See also [LevelingHistoryNotifier].
@ProviderFor(LevelingHistoryNotifier)

View File

@@ -28,14 +28,14 @@ part 'account_settings.g.dart';
@riverpod
Future<List<SnAuthFactor>> authFactors(Ref ref) async {
final client = ref.read(apiClientProvider);
final res = await client.get('/id/accounts/me/factors');
final res = await client.get('/pass/accounts/me/factors');
return res.data.map<SnAuthFactor>((e) => SnAuthFactor.fromJson(e)).toList();
}
@riverpod
Future<List<SnContactMethod>> contactMethods(Ref ref) async {
final client = ref.read(apiClientProvider);
final resp = await client.get('/id/accounts/me/contacts');
final resp = await client.get('/pass/accounts/me/contacts');
return resp.data
.map<SnContactMethod>((e) => SnContactMethod.fromJson(e))
.toList();
@@ -44,7 +44,7 @@ Future<List<SnContactMethod>> contactMethods(Ref ref) async {
@riverpod
Future<List<SnAccountConnection>> accountConnections(Ref ref) async {
final client = ref.read(apiClientProvider);
final resp = await client.get('/id/accounts/me/connections');
final resp = await client.get('/pass/accounts/me/connections');
return resp.data
.map<SnAccountConnection>((e) => SnAccountConnection.fromJson(e))
.toList();
@@ -67,7 +67,7 @@ class AccountSettingsScreen extends HookConsumerWidget {
try {
showLoadingModal(context);
final client = ref.read(apiClientProvider);
await client.delete('/id/accounts/me');
await client.delete('/pass/accounts/me');
if (context.mounted) {
showSnackBar('accountDeletionSent'.tr());
}
@@ -93,7 +93,7 @@ class AccountSettingsScreen extends HookConsumerWidget {
final userInfo = ref.read(userInfoProvider);
final client = ref.read(apiClientProvider);
await client.post(
'/id/accounts/recovery/password',
'/pass/accounts/recovery/password',
data: {'account': userInfo.value!.name, 'captcha_token': captchaTk},
);
if (context.mounted) {

View File

@@ -6,7 +6,7 @@ part of 'account_settings.dart';
// RiverpodGenerator
// **************************************************************************
String _$authFactorsHash() => r'24fe2f7b375b019d87fc3b85cbedbe857f399c0f';
String _$authFactorsHash() => r'ed87d7dbd421fef0a5620416727c3dc598c97ef5';
/// See also [authFactors].
@ProviderFor(authFactors)
@@ -25,7 +25,7 @@ final authFactorsProvider =
@Deprecated('Will be removed in 3.0. Use Ref instead')
// ignore: unused_element
typedef AuthFactorsRef = AutoDisposeFutureProviderRef<List<SnAuthFactor>>;
String _$contactMethodsHash() => r'76a1a93f61c51c44b32b4821f5112d58406155f0';
String _$contactMethodsHash() => r'1d3d03e9ffbf36126236558ead22cb7d88bb9cb2';
/// See also [contactMethods].
@ProviderFor(contactMethods)
@@ -45,7 +45,7 @@ final contactMethodsProvider =
// ignore: unused_element
typedef ContactMethodsRef = AutoDisposeFutureProviderRef<List<SnContactMethod>>;
String _$accountConnectionsHash() =>
r'9f69e7f23e3e53c528d38b93d76f0c9efc9a83db';
r'33c10b98962ede6c428d4028c0d5f2f12ff0eb22';
/// See also [accountConnections].
@ProviderFor(accountConnections)

View File

@@ -87,7 +87,7 @@ class UpdateProfileScreen extends HookConsumerWidget {
}
final client = ref.watch(apiClientProvider);
await client.patch(
'/id/accounts/me/profile',
'/pass/accounts/me/profile',
data: {'${position}_id': cloudFile.id},
);
final userNotifier = ref.read(userInfoProvider.notifier);
@@ -114,7 +114,7 @@ class UpdateProfileScreen extends HookConsumerWidget {
try {
final client = ref.watch(apiClientProvider);
await client.patch(
'/id/accounts/me',
'/pass/accounts/me',
data: {
'name': usernameController.text,
'nick': nicknameController.text,
@@ -194,7 +194,7 @@ class UpdateProfileScreen extends HookConsumerWidget {
};
await client.patch(
'/id/accounts/me/profile',
'/pass/accounts/me/profile',
data: {
'bio': bioController.text,
'first_name': firstNameController.text,

View File

@@ -31,7 +31,7 @@ class AuthFactorSheet extends HookConsumerWidget {
try {
showLoadingModal(context);
final client = ref.read(apiClientProvider);
await client.delete('/id/accounts/me/factors/${factor.id}');
await client.delete('/pass/accounts/me/factors/${factor.id}');
if (context.mounted) Navigator.pop(context, true);
} catch (err) {
showErrorAlert(err);
@@ -49,7 +49,7 @@ class AuthFactorSheet extends HookConsumerWidget {
try {
showLoadingModal(context);
final client = ref.read(apiClientProvider);
await client.post('/id/accounts/me/factors/${factor.id}/disable');
await client.post('/pass/accounts/me/factors/${factor.id}/disable');
if (context.mounted) Navigator.pop(context, true);
} catch (err) {
showErrorAlert(err);
@@ -106,7 +106,7 @@ class AuthFactorSheet extends HookConsumerWidget {
showLoadingModal(context);
final client = ref.read(apiClientProvider);
await client.post(
'/id/accounts/me/factors/${factor.id}/enable',
'/pass/accounts/me/factors/${factor.id}/enable',
data: jsonEncode(password),
);
if (context.mounted) Navigator.pop(context, true);
@@ -193,7 +193,7 @@ class AuthFactorNewSheet extends HookConsumerWidget {
showLoadingModal(context);
final apiClient = ref.read(apiClientProvider);
final resp = await apiClient.post(
'/id/accounts/me/factors',
'/pass/accounts/me/factors',
data: {'type': factorType.value, 'secret': secretController.text},
);
final factor = SnAuthFactor.fromJson(resp.data);

View File

@@ -77,7 +77,7 @@ class AccountConnectionSheet extends HookConsumerWidget {
try {
showLoadingModal(context);
final client = ref.read(apiClientProvider);
await client.delete('/id/accounts/me/connections/${connection.id}');
await client.delete('/pass/accounts/me/connections/${connection.id}');
if (context.mounted) Navigator.pop(context, true);
} catch (err) {
showErrorAlert(err);
@@ -175,7 +175,7 @@ class AccountConnectionNewSheet extends HookConsumerWidget {
if (context.mounted) showLoadingModal(context);
await client.post(
'/id/auth/connect/apple/mobile',
'/pass/auth/connect/apple/mobile',
data: {
'identity_token': credential.identityToken!,
'authorization_code': credential.authorizationCode,
@@ -200,7 +200,7 @@ class AccountConnectionNewSheet extends HookConsumerWidget {
final serverUrl = ref.watch(serverUrlProvider);
final accessToken = ref.watch(tokenProvider);
launchUrlString(
'$serverUrl/id/auth/login/${selectedProvider.value}?tk=${accessToken!.token}',
'$serverUrl/pass/auth/login/${selectedProvider.value}?tk=${accessToken!.token}',
);
} else {
await Navigator.of(context, rootNavigator: true).push(
@@ -345,7 +345,7 @@ class AccountConnectionsSheet extends HookConsumerWidget {
try {
final client = ref.read(apiClientProvider);
await client.delete(
'/id/accounts/me/connections/${connection.id}',
'/pass/accounts/me/connections/${connection.id}',
);
ref.invalidate(accountConnectionsProvider);
return true;

View File

@@ -25,7 +25,7 @@ class ContactMethodSheet extends HookConsumerWidget {
try {
showLoadingModal(context);
final client = ref.read(apiClientProvider);
await client.delete('/id/accounts/me/contacts/${contact.id}');
await client.delete('/pass/accounts/me/contacts/${contact.id}');
if (context.mounted) Navigator.pop(context, true);
} catch (err) {
showErrorAlert(err);
@@ -38,7 +38,7 @@ class ContactMethodSheet extends HookConsumerWidget {
try {
showLoadingModal(context);
final client = ref.read(apiClientProvider);
await client.post('/id/accounts/me/contacts/${contact.id}/verify');
await client.post('/pass/accounts/me/contacts/${contact.id}/verify');
if (context.mounted) {
showSnackBar('contactMethodVerificationSent'.tr());
}
@@ -53,7 +53,7 @@ class ContactMethodSheet extends HookConsumerWidget {
try {
showLoadingModal(context);
final client = ref.read(apiClientProvider);
await client.post('/id/accounts/me/contacts/${contact.id}/primary');
await client.post('/pass/accounts/me/contacts/${contact.id}/primary');
if (context.mounted) Navigator.pop(context, true);
} catch (err) {
showErrorAlert(err);
@@ -66,7 +66,7 @@ class ContactMethodSheet extends HookConsumerWidget {
try {
showLoadingModal(context);
final client = ref.read(apiClientProvider);
await client.post('/id/accounts/me/contacts/${contact.id}/public');
await client.post('/pass/accounts/me/contacts/${contact.id}/public');
if (context.mounted) Navigator.pop(context, true);
} catch (err) {
showErrorAlert(err);
@@ -79,7 +79,7 @@ class ContactMethodSheet extends HookConsumerWidget {
try {
showLoadingModal(context);
final client = ref.read(apiClientProvider);
await client.delete('/id/accounts/me/contacts/${contact.id}/public');
await client.delete('/pass/accounts/me/contacts/${contact.id}/public');
if (context.mounted) Navigator.pop(context, true);
} catch (err) {
showErrorAlert(err);
@@ -221,7 +221,7 @@ class ContactMethodNewSheet extends HookConsumerWidget {
showLoadingModal(context);
final apiClient = ref.read(apiClientProvider);
await apiClient.post(
'/id/accounts/me/contacts',
'/pass/accounts/me/contacts',
data: {'type': contactType.value, 'content': contentController.text},
);
if (context.mounted) {

View File

@@ -561,14 +561,14 @@ Future<SnAccount> account(Ref ref, String uname) async {
}
}
final apiClient = ref.watch(apiClientProvider);
final resp = await apiClient.get("/id/accounts/$uname");
final resp = await apiClient.get("/pass/accounts/$uname");
return SnAccount.fromJson(resp.data);
}
@riverpod
Future<List<SnAccountBadge>> accountBadges(Ref ref, String uname) async {
final apiClient = ref.watch(apiClientProvider);
final resp = await apiClient.get("/id/accounts/$uname/badges");
final resp = await apiClient.get("/pass/accounts/$uname/badges");
return List<SnAccountBadge>.from(
resp.data.map((x) => SnAccountBadge.fromJson(x)),
);
@@ -617,7 +617,7 @@ Future<SnRelationship?> accountRelationship(Ref ref, String uname) async {
final account = await ref.watch(accountProvider(uname).future);
final apiClient = ref.watch(apiClientProvider);
try {
final resp = await apiClient.get("/id/relationships/${account.id}");
final resp = await apiClient.get("/pass/relationships/${account.id}");
return SnRelationship.fromJson(resp.data);
} catch (err) {
if (err is DioException && err.response?.statusCode == 404) {
@@ -690,7 +690,7 @@ class AccountProfileScreen extends HookConsumerWidget {
showLoadingModal(context);
try {
final client = ref.watch(apiClientProvider);
await client.post('/id/relationships/${account.value!.id}/friends');
await client.post('/pass/relationships/${account.value!.id}/friends');
ref.invalidate(accountRelationshipProvider(name));
} catch (err) {
showErrorAlert(err);
@@ -704,9 +704,9 @@ class AccountProfileScreen extends HookConsumerWidget {
try {
final client = ref.watch(apiClientProvider);
if (accountRelationship.value == null) {
await client.post('/id/relationships/${account.value!.id}/block');
await client.post('/pass/relationships/${account.value!.id}/block');
} else {
await client.delete('/id/relationships/${account.value!.id}/block');
await client.delete('/pass/relationships/${account.value!.id}/block');
}
ref.invalidate(accountRelationshipProvider(name));
} catch (err) {

View File

@@ -6,7 +6,7 @@ part of 'profile.dart';
// RiverpodGenerator
// **************************************************************************
String _$accountHash() => r'ce7264a04f69e32a5cb07bc10ca5fa47ae1fddaa';
String _$accountHash() => r'5e2b7bd59151b4638a5561f495537c259f767123';
/// Copied from Dart SDK
class _SystemHash {
@@ -145,7 +145,7 @@ class _AccountProviderElement
String get uname => (origin as AccountProvider).uname;
}
String _$accountBadgesHash() => r'1de05e122c23ff2c6ac6d318977165761e2ad177';
String _$accountBadgesHash() => r'68db63f49827020beecbdbf20529520d0cd14a7d';
/// See also [accountBadges].
@ProviderFor(accountBadges)
@@ -517,7 +517,7 @@ class _AccountDirectChatProviderElement
}
String _$accountRelationshipHash() =>
r'9a3a4e8c6c6706f73df95feccb86736fcad33f30';
r'319f743261b113a1d3c6a397d48d13c858312669';
/// See also [accountRelationship].
@ProviderFor(accountRelationship)

View File

@@ -21,7 +21,7 @@ part 'relationship.g.dart';
@riverpod
Future<List<SnRelationship>> sentFriendRequest(Ref ref) async {
final client = ref.read(apiClientProvider);
final resp = await client.get('/id/relationships/requests');
final resp = await client.get('/pass/relationships/requests');
return resp.data
.map((e) => SnRelationship.fromJson(e))
.cast<SnRelationship>()
@@ -43,7 +43,7 @@ class RelationshipListNotifier extends _$RelationshipListNotifier
final take = 20;
final response = await client.get(
'/id/relationships',
'/pass/relationships',
queryParameters: {'offset': offset, 'take': take},
);
@@ -226,7 +226,7 @@ class RelationshipScreen extends HookConsumerWidget {
if (result == null) return;
final client = ref.read(apiClientProvider);
await client.post('/id/relationships/${result.id}/friends');
await client.post('/pass/relationships/${result.id}/friends');
ref.invalidate(sentFriendRequestProvider);
}
@@ -240,7 +240,7 @@ class RelationshipScreen extends HookConsumerWidget {
submitting.value = true;
final client = ref.read(apiClientProvider);
await client.post(
'/id/relationships/${relationship.accountId}/friends/${isAccept ? 'accept' : 'decline'}',
'/pass/relationships/${relationship.accountId}/friends/${isAccept ? 'accept' : 'decline'}',
);
relationshipNotifier.forceRefresh();
if (!context.mounted) return;
@@ -267,7 +267,7 @@ class RelationshipScreen extends HookConsumerWidget {
) async {
final client = ref.read(apiClientProvider);
await client.patch(
'/id/relationships/${relationship.accountId}',
'/pass/relationships/${relationship.accountId}',
data: {'status': newStatus},
);
relationshipNotifier.forceRefresh();
@@ -350,7 +350,7 @@ class _SentFriendRequestsSheet extends HookConsumerWidget {
Future<void> cancelRequest(SnRelationship request) async {
try {
final client = ref.read(apiClientProvider);
await client.delete('/id/relationships/${request.relatedId}/friends');
await client.delete('/pass/relationships/${request.relatedId}/friends');
ref.invalidate(sentFriendRequestProvider);
} catch (err) {
showErrorAlert(err);

View File

@@ -6,7 +6,7 @@ part of 'relationship.dart';
// RiverpodGenerator
// **************************************************************************
String _$sentFriendRequestHash() => r'dc02ace6cb755a01ab862c9fcff3b26de7f946cb';
String _$sentFriendRequestHash() => r'0c52813eb6f86c05f6e0b1e4e840d0d9c350aa9e';
/// See also [sentFriendRequest].
@ProviderFor(sentFriendRequest)
@@ -27,7 +27,7 @@ final sentFriendRequestProvider =
typedef SentFriendRequestRef =
AutoDisposeFutureProviderRef<List<SnRelationship>>;
String _$relationshipListNotifierHash() =>
r'0a134ce69489a4f2002d2223853855b6f22e4e9f';
r'fc46920256f7c48445c00652165e879890f2c9a3';
/// See also [RelationshipListNotifier].
@ProviderFor(RelationshipListNotifier)