🎨 Improve code structure
This commit is contained in:
@ -164,7 +164,7 @@ class AccountProvider extends GetxController {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (!await auth.isAuthorized) return;
|
||||
|
||||
final client = auth.configureClient(service: 'passport');
|
||||
final client = auth.configureClient('passport');
|
||||
|
||||
final resp = await client.get('/api/notifications?skip=0&take=100');
|
||||
if (resp.statusCode == 200) {
|
||||
@ -197,7 +197,7 @@ class AccountProvider extends GetxController {
|
||||
token = await FirebaseMessaging.instance.getToken();
|
||||
}
|
||||
|
||||
final client = auth.configureClient(service: 'passport');
|
||||
final client = auth.configureClient('passport');
|
||||
|
||||
final resp = await client.post('/api/notifications/subscribe', {
|
||||
'provider': provider,
|
||||
|
@ -58,8 +58,8 @@ class AuthProvider extends GetConnect {
|
||||
return request;
|
||||
}
|
||||
|
||||
GetConnect configureClient({
|
||||
String? service,
|
||||
GetConnect configureClient(
|
||||
String service, {
|
||||
timeout = const Duration(seconds: 5),
|
||||
}) {
|
||||
final client = GetConnect(
|
||||
@ -68,10 +68,7 @@ class AuthProvider extends GetConnect {
|
||||
allowAutoSignedCert: true,
|
||||
);
|
||||
client.httpClient.addAuthenticator(requestAuthenticator);
|
||||
|
||||
if (service != null) {
|
||||
client.httpClient.baseUrl = ServiceFinder.services[service];
|
||||
}
|
||||
client.httpClient.baseUrl = ServiceFinder.services[service];
|
||||
|
||||
return client;
|
||||
}
|
||||
@ -152,7 +149,7 @@ class AuthProvider extends GetConnect {
|
||||
return _cachedUserProfileResponse!;
|
||||
}
|
||||
|
||||
final client = configureClient(service: 'passport');
|
||||
final client = configureClient('passport');
|
||||
|
||||
final resp = await client.get('/api/users/me');
|
||||
if (resp.statusCode != 200) {
|
||||
|
@ -97,7 +97,7 @@ class AttachmentProvider extends GetConnect {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (!await auth.isAuthorized) throw Exception('unauthorized');
|
||||
|
||||
final client = auth.configureClient(service: 'paperclip');
|
||||
final client = auth.configureClient('paperclip');
|
||||
|
||||
var resp = await client.put('/api/attachments/$id', {
|
||||
'metadata': {
|
||||
@ -119,7 +119,7 @@ class AttachmentProvider extends GetConnect {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (!await auth.isAuthorized) throw Exception('unauthorized');
|
||||
|
||||
final client = auth.configureClient(service: 'paperclip');
|
||||
final client = auth.configureClient('paperclip');
|
||||
|
||||
var resp = await client.delete('/api/attachments/$id');
|
||||
if (resp.statusCode != 200) {
|
||||
|
@ -57,7 +57,7 @@ class ChatCallProvider extends GetxController {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (!await auth.isAuthorized) throw Exception('unauthorized');
|
||||
|
||||
final client = auth.configureClient(service: 'messaging');
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
final resp = await client.post(
|
||||
'/api/channels/global/${channel.value!.alias}/calls/ongoing/token',
|
||||
|
@ -9,7 +9,7 @@ class ChannelProvider extends GetxController {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (!await auth.isAuthorized) throw Exception('unauthorized');
|
||||
|
||||
final client = auth.configureClient(service: 'messaging');
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
final resp = await client.get('/api/channels/$realm/$alias');
|
||||
if (resp.statusCode != 200) {
|
||||
@ -23,7 +23,7 @@ class ChannelProvider extends GetxController {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (!await auth.isAuthorized) throw Exception('unauthorized');
|
||||
|
||||
final client = auth.configureClient(service: 'messaging');
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
final resp = await client.get('/api/channels/$realm/$alias/me');
|
||||
if (resp.statusCode != 200) {
|
||||
@ -38,7 +38,7 @@ class ChannelProvider extends GetxController {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (!await auth.isAuthorized) throw Exception('unauthorized');
|
||||
|
||||
final client = auth.configureClient(service: 'messaging');
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
final resp = await client.get('/api/channels/$realm/$alias/calls/ongoing');
|
||||
if (resp.statusCode == 404) {
|
||||
@ -54,7 +54,7 @@ class ChannelProvider extends GetxController {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (!await auth.isAuthorized) throw Exception('unauthorized');
|
||||
|
||||
final client = auth.configureClient(service: 'messaging');
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
final resp = await client.get('/api/channels/$scope');
|
||||
if (resp.statusCode != 200) {
|
||||
@ -68,7 +68,7 @@ class ChannelProvider extends GetxController {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (!await auth.isAuthorized) throw Exception('unauthorized');
|
||||
|
||||
final client = auth.configureClient(service: 'messaging');
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
final resp = await client.get('/api/channels/$realm/me/available');
|
||||
if (resp.statusCode != 200) {
|
||||
@ -82,7 +82,7 @@ class ChannelProvider extends GetxController {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (!await auth.isAuthorized) throw Exception('unauthorized');
|
||||
|
||||
final client = auth.configureClient(service: 'messaging');
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
final resp = await client.post('/api/channels/$scope', payload);
|
||||
if (resp.statusCode != 200) {
|
||||
@ -107,7 +107,7 @@ class ChannelProvider extends GetxController {
|
||||
if (related == null) return null;
|
||||
|
||||
final prof = await auth.getProfile();
|
||||
final client = auth.configureClient(service: 'messaging');
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
final resp = await client.post('/api/channels/$scope/dm', {
|
||||
'alias': const Uuid().v4().replaceAll('-', '').substring(0, 12),
|
||||
@ -128,7 +128,7 @@ class ChannelProvider extends GetxController {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (!await auth.isAuthorized) throw Exception('unauthorized');
|
||||
|
||||
final client = auth.configureClient(service: 'messaging');
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
final resp = await client.put('/api/channels/$scope/$id', payload);
|
||||
if (resp.statusCode != 200) {
|
||||
|
@ -6,7 +6,7 @@ class RealmProvider extends GetxController {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (!await auth.isAuthorized) throw Exception('unauthorized');
|
||||
|
||||
final client = auth.configureClient(service: 'passport');
|
||||
final client = auth.configureClient('passport');
|
||||
|
||||
final resp = await client.get('/api/realms/$alias');
|
||||
if (resp.statusCode != 200) {
|
||||
@ -20,7 +20,7 @@ class RealmProvider extends GetxController {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (!await auth.isAuthorized) throw Exception('unauthorized');
|
||||
|
||||
final client = auth.configureClient(service: 'passport');
|
||||
final client = auth.configureClient('passport');
|
||||
|
||||
final resp = await client.get('/api/realms/me/available');
|
||||
if (resp.statusCode != 200) {
|
||||
|
Reference in New Issue
Block a user