line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/env perl |
2
|
|
|
|
|
|
|
# AP-Client: CLI-based client / toolbox for ActivityPub |
3
|
|
|
|
|
|
|
# Copyright © 2020-2023 AP-Client Authors |
4
|
|
|
|
|
|
|
# SPDX-License-Identifier: BSD-3-Clause |
5
|
|
|
|
|
|
|
package App::ActivityPubClient; |
6
|
|
|
|
|
|
|
our $VERSION = 'v0.1.2'; |
7
|
1
|
|
|
1
|
|
132779
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
8
|
1
|
|
|
1
|
|
6
|
use utf8; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
9
|
1
|
|
|
1
|
|
28
|
use open ":std", ":encoding(UTF-8)"; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
652
|
use Scalar::Util qw(reftype); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
6
|
use Exporter 'import'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
432
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @EXPORT_OK = qw(print_object); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub print_object_key { |
18
|
100
|
|
|
100
|
0
|
154
|
my ($indent, $object, $key) = @_; |
19
|
|
|
|
|
|
|
|
20
|
100
|
100
|
|
|
|
215
|
if ($object->{$key}) { |
21
|
10
|
|
|
|
|
23
|
print_ref($indent, $object->{$key}, $key); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub print_object { |
26
|
5
|
|
|
5
|
0
|
2436
|
my ($indent, $object) = @_; |
27
|
|
|
|
|
|
|
|
28
|
5
|
|
|
|
|
26
|
my @regular_keys = |
29
|
|
|
|
|
|
|
qw{url subtitleLanguage context inbox outbox prev next published updated summary content bcc bto cc to object attachment tag orderedItems mediaType}; |
30
|
|
|
|
|
|
|
|
31
|
5
|
|
|
|
|
146
|
printf "%*s %s", $indent, '⇒', $object->{"type"}; |
32
|
5
|
50
|
|
|
|
106
|
printf ' id:<%s>', $object->{"id"} if $object->{"id"}; |
33
|
5
|
50
|
|
|
|
23
|
printf ' href:<%s>', $object->{"href"} if $object->{"href"}; |
34
|
5
|
50
|
|
|
|
83
|
printf ' “%s”', $object->{"name"} if $object->{"name"}; |
35
|
|
|
|
|
|
|
printf ' @%s', $object->{"preferredUsername"} |
36
|
5
|
100
|
|
|
|
38
|
if $object->{"preferredUsername"}; |
37
|
5
|
50
|
|
|
|
26
|
printf ' ⚠' if ($object->{"sensitive"} eq JSON->true); |
38
|
5
|
|
|
|
|
89
|
foreach (@regular_keys) { |
39
|
100
|
|
|
|
|
170
|
print_object_key($indent, $object, $_); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub print_ref { |
44
|
10
|
|
|
10
|
0
|
19
|
my ($indent, $object, $name) = @_; |
45
|
|
|
|
|
|
|
|
46
|
10
|
|
|
|
|
24
|
my $ref_type = reftype($object); |
47
|
|
|
|
|
|
|
|
48
|
10
|
50
|
|
|
|
25
|
if ($ref_type eq 'HASH') { |
|
|
100
|
|
|
|
|
|
49
|
0
|
|
|
|
|
0
|
printf "\n%*s%s: \n", $indent, ' ', $name; |
50
|
0
|
|
|
|
|
0
|
print_object($indent + 4, $object); |
51
|
|
|
|
|
|
|
} elsif ($ref_type eq 'ARRAY') { |
52
|
2
|
100
|
|
|
|
3
|
printf "\n%*s%s: ", $indent, ' ', $name if @{$object}; |
|
2
|
|
|
|
|
23
|
|
53
|
2
|
|
|
|
|
5
|
foreach (@{$object}) { |
|
2
|
|
|
|
|
7
|
|
54
|
4
|
50
|
|
|
|
15
|
if (reftype($_) eq 'HASH') { |
55
|
4
|
|
|
|
|
59
|
print "\n"; |
56
|
4
|
|
|
|
|
21
|
print_object($indent + 4, $_); |
57
|
|
|
|
|
|
|
} else { |
58
|
0
|
|
|
|
|
0
|
printf "%s ; ", $_; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} else { |
62
|
8
|
|
|
|
|
182
|
printf "\n%*s%s: %s", $indent, ' ', $name, $object; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |