🐛 Fix post visibility issue
This commit is contained in:
parent
ca18d6ade4
commit
52312662fb
@ -125,7 +125,7 @@ class AuthProvider extends GetConnect {
|
|||||||
userAgent: await ServiceFinder.getUserAgent(),
|
userAgent: await ServiceFinder.getUserAgent(),
|
||||||
sendUserAgent: true,
|
sendUserAgent: true,
|
||||||
);
|
);
|
||||||
client.httpClient.addAuthenticator(requestAuthenticator);
|
client.httpClient.addRequestModifier(requestAuthenticator);
|
||||||
client.httpClient.baseUrl = ServiceFinder.buildUrl(service, null);
|
client.httpClient.baseUrl = ServiceFinder.buildUrl(service, null);
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
|
@ -41,6 +41,7 @@ class AttachmentProvider extends GetConnect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pendingQuery.isNotEmpty) {
|
||||||
final resp = await get(
|
final resp = await get(
|
||||||
'/attachments?take=${pendingQuery.length}&id=${pendingQuery.join(',')}',
|
'/attachments?take=${pendingQuery.length}&id=${pendingQuery.join(',')}',
|
||||||
);
|
);
|
||||||
@ -63,6 +64,7 @@ class AttachmentProvider extends GetConnect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -3,22 +3,11 @@ import 'package:solian/exceptions/request.dart';
|
|||||||
import 'package:solian/exceptions/unauthorized.dart';
|
import 'package:solian/exceptions/unauthorized.dart';
|
||||||
import 'package:solian/models/post.dart';
|
import 'package:solian/models/post.dart';
|
||||||
import 'package:solian/providers/auth.dart';
|
import 'package:solian/providers/auth.dart';
|
||||||
import 'package:solian/services.dart';
|
|
||||||
|
|
||||||
class PostProvider extends GetConnect {
|
|
||||||
@override
|
|
||||||
void onInit() {
|
|
||||||
httpClient.baseUrl = ServiceFinder.buildUrl('interactive', null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
class PostProvider extends GetxController {
|
||||||
Future<Response> seeWhatsNew(int pivot) async {
|
Future<Response> seeWhatsNew(int pivot) async {
|
||||||
GetConnect client;
|
|
||||||
final AuthProvider auth = Get.find();
|
final AuthProvider auth = Get.find();
|
||||||
if (auth.isAuthorized.value) {
|
final client = await auth.configureClient('co');
|
||||||
client = await auth.configureClient('co');
|
|
||||||
} else {
|
|
||||||
client = await ServiceFinder.configureClient('co');
|
|
||||||
}
|
|
||||||
final resp = await client.get('/whats-new?pivot=$pivot');
|
final resp = await client.get('/whats-new?pivot=$pivot');
|
||||||
if (resp.statusCode != 200) {
|
if (resp.statusCode != 200) {
|
||||||
throw RequestException(resp);
|
throw RequestException(resp);
|
||||||
@ -29,18 +18,13 @@ class PostProvider extends GetConnect {
|
|||||||
|
|
||||||
Future<Response> listRecommendations(int page,
|
Future<Response> listRecommendations(int page,
|
||||||
{String? realm, String? channel, int take = 10}) async {
|
{String? realm, String? channel, int take = 10}) async {
|
||||||
GetConnect client;
|
|
||||||
final AuthProvider auth = Get.find();
|
|
||||||
final queries = [
|
final queries = [
|
||||||
'take=$take',
|
'take=$take',
|
||||||
'offset=$page',
|
'offset=$page',
|
||||||
if (realm != null) 'realm=$realm',
|
if (realm != null) 'realm=$realm',
|
||||||
];
|
];
|
||||||
if (auth.isAuthorized.value) {
|
final AuthProvider auth = Get.find();
|
||||||
client = await auth.configureClient('co');
|
final client = await auth.configureClient('interactive');
|
||||||
} else {
|
|
||||||
client = await ServiceFinder.configureClient('co');
|
|
||||||
}
|
|
||||||
final resp = await client.get(
|
final resp = await client.get(
|
||||||
channel == null
|
channel == null
|
||||||
? '/recommendations?${queries.join('&')}'
|
? '/recommendations?${queries.join('&')}'
|
||||||
@ -80,7 +64,9 @@ class PostProvider extends GetConnect {
|
|||||||
if (author != null) 'author=$author',
|
if (author != null) 'author=$author',
|
||||||
if (realm != null) 'realm=$realm',
|
if (realm != null) 'realm=$realm',
|
||||||
];
|
];
|
||||||
final resp = await get('/posts?${queries.join('&')}');
|
final AuthProvider auth = Get.find();
|
||||||
|
final client = await auth.configureClient('co');
|
||||||
|
final resp = await client.get('/posts?${queries.join('&')}');
|
||||||
if (resp.statusCode != 200) {
|
if (resp.statusCode != 200) {
|
||||||
throw RequestException(resp);
|
throw RequestException(resp);
|
||||||
}
|
}
|
||||||
@ -89,7 +75,10 @@ class PostProvider extends GetConnect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<Response> listPostReplies(String alias, int page) async {
|
Future<Response> listPostReplies(String alias, int page) async {
|
||||||
final resp = await get('/posts/$alias/replies?take=${10}&offset=$page');
|
final AuthProvider auth = Get.find();
|
||||||
|
final client = await auth.configureClient('co');
|
||||||
|
final resp =
|
||||||
|
await client.get('/posts/$alias/replies?take=${10}&offset=$page');
|
||||||
if (resp.statusCode != 200) {
|
if (resp.statusCode != 200) {
|
||||||
throw RequestException(resp);
|
throw RequestException(resp);
|
||||||
}
|
}
|
||||||
@ -98,7 +87,9 @@ class PostProvider extends GetConnect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Post>> listPostFeaturedReply(String alias, {int take = 1}) async {
|
Future<List<Post>> listPostFeaturedReply(String alias, {int take = 1}) async {
|
||||||
final resp = await get('/posts/$alias/replies/featured?take=$take');
|
final AuthProvider auth = Get.find();
|
||||||
|
final client = await auth.configureClient('co');
|
||||||
|
final resp = await client.get('/posts/$alias/replies/featured?take=$take');
|
||||||
if (resp.statusCode != 200) {
|
if (resp.statusCode != 200) {
|
||||||
throw RequestException(resp);
|
throw RequestException(resp);
|
||||||
}
|
}
|
||||||
@ -107,16 +98,9 @@ class PostProvider extends GetConnect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<Response> getPost(String alias) async {
|
Future<Response> getPost(String alias) async {
|
||||||
final resp = await get('/posts/$alias');
|
final AuthProvider auth = Get.find();
|
||||||
if (resp.statusCode != 200) {
|
final client = await auth.configureClient('co');
|
||||||
throw RequestException(resp);
|
final resp = await client.get('/posts/$alias');
|
||||||
}
|
|
||||||
|
|
||||||
return resp;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<Response> getArticle(String alias) async {
|
|
||||||
final resp = await get('/articles/$alias');
|
|
||||||
if (resp.statusCode != 200) {
|
if (resp.statusCode != 200) {
|
||||||
throw RequestException(resp);
|
throw RequestException(resp);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user