Skip to content

Commit

Permalink
πŸ”€ Merge pull request #8 from Fedodo/dev
Browse files Browse the repository at this point in the history
πŸ› Added Header
  • Loading branch information
LNA-DEV authored Jul 4, 2023
2 parents 28311dc + 797c7fb commit 3519a46
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
11 changes: 10 additions & 1 deletion lib/APIs/outbox_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,24 @@ import 'package:activitypub/config.dart';

class OutboxAPI {
Future<OrderedPagedCollection> 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;
}

Expand Down
13 changes: 13 additions & 0 deletions lib/config.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:logger/logger.dart';

class Config {
static String? _accessToken;
static String get accessToken {
Expand Down Expand Up @@ -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;
}
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand Down

0 comments on commit 3519a46

Please sign in to comment.