diff --git a/lib/APIs/outbox_api.dart b/lib/APIs/outbox_api.dart index 2168d3c..ce813e2 100644 --- a/lib/APIs/outbox_api.dart +++ b/lib/APIs/outbox_api.dart @@ -7,15 +7,24 @@ import 'package:activitypub/config.dart'; class OutboxAPI { Future getFirstPage(String outboxUrl) async { + Config.logger.v("Getting first page with outboxUrl=$outboxUrl"); + Uri outboxUri = Uri.parse(outboxUrl); if (outboxUri.authority != Config.domainName) { outboxUri = outboxUri.asProxyUri(); } - http.Response pageResponse = await http.get(outboxUri); + http.Response pageResponse = await http.get( + outboxUri, + headers: {"Content-Type": "application/json"}, + ); + OrderedPagedCollection collection = OrderedPagedCollection.fromJson( jsonDecode(utf8.decode(pageResponse.bodyBytes))); + + Config.logger.v("Returning collection"); + return collection; } diff --git a/lib/config.dart b/lib/config.dart index 72a5962..7cf9d63 100644 --- a/lib/config.dart +++ b/lib/config.dart @@ -1,3 +1,5 @@ +import 'package:logger/logger.dart'; + class Config { static String? _accessToken; static String get accessToken { @@ -64,4 +66,15 @@ class Config { } static set asProxyUri(var value) => _asProxyUri = value; + + static Logger? _logger; + static Logger get logger { + if (_logger == null) { + throw ArgumentError("logger must be set!"); + } + + return _logger!; + } + + static set logger(var value) => _logger = value; } diff --git a/pubspec.yaml b/pubspec.yaml index f886a94..292b079 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: activitypub description: A library for the ActivityPub standard. Created an also used by Fedodo. -version: 1.2.1 +version: 1.2.2 repository: https://github.com/Fedodo/Fedodo.Pub.ActivityPub environment: @@ -9,6 +9,7 @@ environment: dependencies: jwt_decoder: ^2.0.1 http: ^0.13.5 + logger: ^1.4.0 dev_dependencies: lints: ^2.0.0