⬆️ Upgrade to support latest version of server

This commit is contained in:
2024-07-16 19:46:53 +08:00
parent 286dd8193d
commit da265da61d
42 changed files with 221 additions and 297 deletions

View File

@ -58,7 +58,7 @@ class AttachmentProvider extends GetConnect {
@override
void onInit() {
httpClient.baseUrl = ServiceFinder.services['paperclip'];
httpClient.baseUrl = ServiceFinder.buildUrl('files', null);
}
final Map<int, Response> _cachedResponses = {};
@ -68,7 +68,7 @@ class AttachmentProvider extends GetConnect {
return _cachedResponses[id]!;
}
final resp = await get('/api/attachments/$id/meta');
final resp = await get('/attachments/$id/meta');
_cachedResponses[id] = resp;
return resp;
@ -81,7 +81,7 @@ class AttachmentProvider extends GetConnect {
if (!await auth.isAuthorized) throw Exception('unauthorized');
final client = auth.configureClient(
'paperclip',
'files',
timeout: const Duration(minutes: 3),
);
@ -108,7 +108,7 @@ class AttachmentProvider extends GetConnect {
if (ratio != null) 'ratio': ratio,
}),
});
final resp = await client.post('/api/attachments', payload);
final resp = await client.post('/attachments', payload);
if (resp.statusCode != 200) {
throw Exception(resp.bodyString);
}
@ -126,9 +126,9 @@ class AttachmentProvider extends GetConnect {
final AuthProvider auth = Get.find();
if (!await auth.isAuthorized) throw Exception('unauthorized');
final client = auth.configureClient('paperclip');
final client = auth.configureClient('files');
var resp = await client.put('/api/attachments/$id', {
var resp = await client.put('/attachments/$id', {
'metadata': {
if (ratio != null) 'ratio': ratio,
},
@ -148,9 +148,9 @@ class AttachmentProvider extends GetConnect {
final AuthProvider auth = Get.find();
if (!await auth.isAuthorized) throw Exception('unauthorized');
final client = auth.configureClient('paperclip');
final client = auth.configureClient('files');
var resp = await client.delete('/api/attachments/$id');
var resp = await client.delete('/attachments/$id');
if (resp.statusCode != 200) {
throw Exception(resp.bodyString);
}

View File

@ -60,7 +60,7 @@ class ChatCallProvider extends GetxController {
final client = auth.configureClient('messaging');
final resp = await client.post(
'/api/channels/global/${channel.value!.alias}/calls/ongoing/token',
'/channels/global/${channel.value!.alias}/calls/ongoing/token',
{},
);
if (resp.statusCode == 200) {

View File

@ -33,7 +33,7 @@ class ChannelProvider extends GetxController {
final client = auth.configureClient('messaging');
final resp = await client.get('/api/channels/$realm/$alias');
final resp = await client.get('/channels/$realm/$alias');
if (resp.statusCode != 200) {
throw Exception(resp.bodyString);
}
@ -48,7 +48,7 @@ class ChannelProvider extends GetxController {
final client = auth.configureClient('messaging');
final resp = await client.get('/api/channels/$realm/$alias/me');
final resp = await client.get('/channels/$realm/$alias/me');
if (resp.statusCode != 200) {
throw Exception(resp.bodyString);
}
@ -63,7 +63,7 @@ class ChannelProvider extends GetxController {
final client = auth.configureClient('messaging');
final resp = await client.get('/api/channels/$realm/$alias/calls/ongoing');
final resp = await client.get('/channels/$realm/$alias/calls/ongoing');
if (resp.statusCode == 404) {
return null;
} else if (resp.statusCode != 200) {
@ -79,7 +79,7 @@ class ChannelProvider extends GetxController {
final client = auth.configureClient('messaging');
final resp = await client.get('/api/channels/$scope');
final resp = await client.get('/channels/$scope');
if (resp.statusCode != 200) {
throw Exception(resp.bodyString);
}
@ -93,7 +93,7 @@ class ChannelProvider extends GetxController {
final client = auth.configureClient('messaging');
final resp = await client.get('/api/channels/$realm/me/available');
final resp = await client.get('/channels/$realm/me/available');
if (resp.statusCode != 200) {
throw Exception(resp.bodyString);
}
@ -107,7 +107,7 @@ class ChannelProvider extends GetxController {
final client = auth.configureClient('messaging');
final resp = await client.post('/api/channels/$scope', payload);
final resp = await client.post('/channels/$scope', payload);
if (resp.statusCode != 200) {
throw Exception(resp.bodyString);
}
@ -132,7 +132,7 @@ class ChannelProvider extends GetxController {
final prof = await auth.getProfile();
final client = auth.configureClient('messaging');
final resp = await client.post('/api/channels/$scope/dm', {
final resp = await client.post('/channels/$scope/dm', {
'alias': const Uuid().v4().replaceAll('-', '').substring(0, 12),
'name': 'DM',
'description':
@ -153,7 +153,7 @@ class ChannelProvider extends GetxController {
final client = auth.configureClient('messaging');
final resp = await client.put('/api/channels/$scope/$id', payload);
final resp = await client.put('/channels/$scope/$id', payload);
if (resp.statusCode != 200) {
throw Exception(resp.bodyString);
}

View File

@ -5,7 +5,7 @@ import 'package:solian/services.dart';
class FeedProvider extends GetConnect {
@override
void onInit() {
httpClient.baseUrl = ServiceFinder.services['interactive'];
httpClient.baseUrl = ServiceFinder.buildUrl('interactive', null);
}
Future<Response> listFeed(int page,
@ -17,7 +17,7 @@ class FeedProvider extends GetConnect {
if (category != null) 'category=$category',
if (realm != null) 'realmId=$realm',
];
final resp = await get('/api/feed?${queries.join('&')}');
final resp = await get('/feed?${queries.join('&')}');
if (resp.statusCode != 200) {
throw Exception(resp.body);
}
@ -34,7 +34,7 @@ class FeedProvider extends GetConnect {
'offset=$page',
];
final client = auth.configureClient('interactive');
final resp = await client.get('/api/drafts?${queries.join('&')}');
final resp = await client.get('/drafts?${queries.join('&')}');
if (resp.statusCode != 200) {
throw Exception(resp.body);
}
@ -48,7 +48,7 @@ class FeedProvider extends GetConnect {
'offset=$page',
if (realm != null) 'realmId=$realm',
];
final resp = await get('/api/posts?${queries.join('&')}');
final resp = await get('/posts?${queries.join('&')}');
if (resp.statusCode != 200) {
throw Exception(resp.body);
}
@ -57,7 +57,7 @@ class FeedProvider extends GetConnect {
}
Future<Response> listPostReplies(String alias, int page) async {
final resp = await get('/api/posts/$alias/replies?take=${10}&offset=$page');
final resp = await get('/posts/$alias/replies?take=${10}&offset=$page');
if (resp.statusCode != 200) {
throw Exception(resp.body);
}
@ -66,7 +66,7 @@ class FeedProvider extends GetConnect {
}
Future<Response> getPost(String alias) async {
final resp = await get('/api/posts/$alias');
final resp = await get('/posts/$alias');
if (resp.statusCode != 200) {
throw Exception(resp.body);
}
@ -75,7 +75,7 @@ class FeedProvider extends GetConnect {
}
Future<Response> getArticle(String alias) async {
final resp = await get('/api/articles/$alias');
final resp = await get('/articles/$alias');
if (resp.statusCode != 200) {
throw Exception(resp.body);
}

View File

@ -6,9 +6,9 @@ class RealmProvider extends GetxController {
final AuthProvider auth = Get.find();
if (!await auth.isAuthorized) throw Exception('unauthorized');
final client = auth.configureClient('passport');
final client = auth.configureClient('auth');
final resp = await client.get('/api/realms/$alias');
final resp = await client.get('/realms/$alias');
if (resp.statusCode != 200) {
throw Exception(resp.bodyString);
}
@ -20,9 +20,9 @@ class RealmProvider extends GetxController {
final AuthProvider auth = Get.find();
if (!await auth.isAuthorized) throw Exception('unauthorized');
final client = auth.configureClient('passport');
final client = auth.configureClient('auth');
final resp = await client.get('/api/realms/me/available');
final resp = await client.get('/realms/me/available');
if (resp.statusCode != 200) {
throw Exception(resp.bodyString);
}