| 1 | 3 | package Bluesky 1.01 { | |||||||||||||||||||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use v5.40; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use Carp qw[carp]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use bytes; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use feature 'class'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | no warnings 'experimental::class', 'experimental::try'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use At; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Path::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use HTTP::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use JSON::PP; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | class Bluesky { | |||||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | field $service : param //= 'https://bsky.social'; | |||||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | field $chat_service : param //= 'https://api.bsky.chat'; | |||||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | field $at : reader = At->new( host => $service ); | |||||||||||||||||||||||||||||||||||||||||||||
| 17 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 5 | ▶ | method _at_for ($method) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_at_for: called CC=3 SCAR=12.7
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 5 | ▶ | if ( $method =~ /^chat\.bsky\./ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # Chat requests are proxied via the PDS. | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # Service ID fragment (#bsky_chat) is required. | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 5 | ▶ | say '[DEBUG] [Bluesky] Proxying chat request...' if $ENV{DEBUG}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 5 | $self->at->http->at_protocol_proxy('did:web:api.bsky.chat#bsky_chat'); | |||||||||||||||||||||||||||||||||||||||||||||
| 25 | 5 | return $at; | |||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # Ensure proxy is NOT used for standard repo/feed calls | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | $self->at->http->at_protocol_proxy(undef); | |||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | return $at; | |||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | method login ( $identifier, $password ) { $self->at->login( $identifier, $password ); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
login: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | method resume( $accessJwt, $refreshJwt, $token_type = 'Bearer', $dpop_key_jwk = (), $client_id = (), $handle = (), $pds = (), $scope = () ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resume: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | $self->at->resume( $accessJwt, $refreshJwt, $token_type, $dpop_key_jwk, $client_id, $handle, $pds, $scope ); | |||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | method oauth_start( $handle, $client_id, $redirect_uri, $scope = 'atproto' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
oauth_start: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | return $self->at->oauth_start( $handle, $client_id, $redirect_uri, $scope ); | |||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | method oauth_callback( $code, $state ) { return $self->at->oauth_callback( $code, $state ); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
oauth_callback: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | method oauth_helper (%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
oauth_helper: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | my $handle = $args{handle} or die 'Handle is required for oauth_helper'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # client_id base MUST be localhost for the PDS to recognize it as metadata-less | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | my $client_id_base = $args{client_id} // 'http://localhost'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{"client_id"} // "http://localhost"
MC/DC0%0/1
$args{"client_id"} // "http://localhost"
$args{"client_id"}
Truth table0%0/2
A
A= $args{"client_id"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # RFC 8252 requires loopback IP (127.0.0.1) for the actual redirect | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | my $redirect_uri = $args{redirect} // 'http://127.0.0.1:8888/callback'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{"redirect"} // "http://127.0.0.1:8888/callback"
MC/DC0%0/1
$args{"redirect"} // "http://127.0.0.1:8888/callback"
$args{"redirect"}
Truth table0%0/2
A
A= $args{"redirect"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # Transitional scopes for chat access via PDS proxy | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | my $scope = $args{scope} // 'atproto transition:generic transition:chat.bsky'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{"scope"} // "atproto transition:generic transition:chat.bsky"
MC/DC0%0/1
$args{"scope"} // "atproto transition:generic transition:chat.bsky"
$args{"scope"}
Truth table0%0/2
A
A= $args{"scope"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | my $on_success = $args{on_success} // sub { say 'Success! Session established.' }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$args{"on_success"} // sub {
say "Success! Session established.";
}
MC/DC0%0/2
$args{"on_success"} // sub {
say "Success! Session established.";
}
$args{"on_success"}
sub {
say "Success! Session established.";
}
Truth table0%0/3
A // B
A= $args{"on_success"}B= sub {
say "Success! Session established.";
}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # Build the magic localhost Client ID manually to ensure %20 encoding for spaces | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | require URI::Escape; | |||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my $scope_encoded = URI::Escape::uri_escape($scope); | |||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my $redirect_encoded = URI::Escape::uri_escape($redirect_uri); | |||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $client_id = "$client_id_base?scope=$scope_encoded&redirect_uri=$redirect_encoded"; | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | say "Starting OAuth flow for $handle..."; | |||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my $auth_url = $self->oauth_start( $handle, $client_id, $redirect_uri, $scope ); | |||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | say 'Please open the following URL in your browser:'; | |||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | say "\n $auth_url\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ( $args{listen} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # Attempt to start a local server to catch the callback | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | try { | |||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | require Mojolicious; | |||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my $app = Mojolicious->new(); | |||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my $port = 8888; | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | $port = $1 if $redirect_uri =~ /:(\d+)/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | my $path = URI->new($redirect_uri)->path || '/'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
'URI'->new($redirect_uri)->path || '/'
MC/DC0%0/1
'URI'->new($redirect_uri)->path || '/'
'URI'->new($redirect_uri)->path
Truth table0%0/2
A
A= 'URI'->new($redirect_uri)->path
| |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | $app->routes->get($path)->to( | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | cb => sub ($c) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | my $code = $c->param('code'); | |||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my $state = $c->param('state'); | |||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | if ( $code && $state ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$code and $state
MC/DC0%0/2
$code and $state
$code
$state
Truth table0%0/3
A and B
A= $codeB= $state
| |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | say 'Exchanging code for tokens...'; | |||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | try { | |||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $self->oauth_callback( $code, $state ); | |||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $on_success->($self); | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $c->render( text => '<h1>Success!</h1><p>You can close this window and return to the terminal.</p>' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # Stop loop after response | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | require Mojo::IOLoop; | |||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | Mojo::IOLoop->timer( 1 => sub { exit 0 } ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 90 | catch ($e) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | $c->render( text => 'OAuth Callback failed: ' . $e, status => 500 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | die $e; | |||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | $c->render( text => 'Error: Missing code or state.', status => 400 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | say "Starting local server on port $port to catch the callback..."; | |||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $app->log->level('error'); | |||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | require Mojo::Server::Daemon; | |||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # Listen on all interfaces but specific to the redirect_uri port | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my $daemon = Mojo::Server::Daemon->new( app => $app, listen => [ 'http://127.0.0.1:' . $port ] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $daemon->run(); | |||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | return; # Exit method if listener ran (it blocks until finished or exits) | |||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | catch ($e) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | warn "Could not start listener: $e\nFalling back to manual input.\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # Manual fallback (only reached if listen is false or failed) | ||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | say 'After authorizing, you will be redirected to a URL that looks like:'; | |||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | say "$redirect_uri?code=...&state=..."; | |||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | say "\nPlease paste the FULL redirect URL here:"; | |||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my $callback_url = <STDIN>; | |||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | chomp $callback_url; | |||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | my ($code) = $callback_url =~ /[?&]code=([^&]+)/; | |||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my ($state) = $callback_url =~ /[?&]state=([^&]+)/; | |||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | if ( $code && $state ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$code and $state
MC/DC0%0/2
$code and $state
$code
$state
Truth table0%0/3
A and B
A= $codeB= $state
| |||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $self->oauth_callback( $code, $state ); | |||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $on_success->($self); | |||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | die "Could not find code and state in the provided URL.\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | method firehose( $callback, $url = () ) { $self->at->firehose( $callback, $url ); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
firehose: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | method session () { $self->at->session; } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
session: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | method did() { $self->at->did } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
did: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # Feeds and content | ||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | method getTrendingTopics(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getTrendingTopics: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $self->_at_for('app.bsky.unspecced.getTrendingTopics')->get( 'app.bsky.unspecced.getTrendingTopics' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | method getTimeline(%args) { $self->_at_for('app.bsky.feed.getTimeline')->get( 'app.bsky.feed.getTimeline' => \%args ); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getTimeline: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | method getAuthorFeed(%args) { $self->_at_for('app.bsky.feed.getAuthorFeed')->get( 'app.bsky.feed.getAuthorFeed' => \%args ); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getAuthorFeed: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | method getPostThread(%args) { $self->_at_for('app.bsky.feed.getPostThread')->get( 'app.bsky.feed.getPostThread' => \%args ); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getPostThread: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | method getFeed( $feed, %args ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getFeed: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my $res = $self->_at_for('app.bsky.feed.getFeed')->get( 'app.bsky.feed.getFeed' => { feed => $feed, %args } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | $res ? $res->{feed} // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"feed"} // ()
MC/DC0%0/2
$res->{"feed"} // ()
$res->{"feed"}
()
Truth table0%0/3
A // B
A= $res->{"feed"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | method getFeedSkeleton( $feed, %args ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getFeedSkeleton: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my $res = $self->_at_for('app.bsky.feed.getFeedSkeleton')->get( 'app.bsky.feed.getFeedSkeleton' => { feed => $feed, %args } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | $res ? $res->{feed} // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"feed"} // ()
MC/DC0%0/2
$res->{"feed"} // ()
$res->{"feed"}
()
Truth table0%0/3
A // B
A= $res->{"feed"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | method getPost($uri) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getPost: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | my $res = $self->_at_for('app.bsky.feed.getPosts') | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 156 | ->get( 'app.bsky.feed.getPosts' => { uris => [ builtin::blessed $uri ? $uri->as_string : $uri ] } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | $res ? $res->{posts}[0] // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"posts"}[0] // ()
MC/DC0%0/2
$res->{"posts"}[0] // ()
$res->{"posts"}[0]
()
Truth table0%0/3
A // B
A= $res->{"posts"}[0]B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | method getPosts(@uris) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getPosts: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | my $res = $self->_at_for('app.bsky.feed.getPosts') | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | ->get( 'app.bsky.feed.getPosts' => { uris => [ map { builtin::blessed $_ ? $_->as_string : $_ } @uris ] } ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | $res ? $res->{posts} // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"posts"} // ()
MC/DC0%0/2
$res->{"posts"} // ()
$res->{"posts"}
()
Truth table0%0/3
A // B
A= $res->{"posts"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | method getLikes(%args) { $self->_at_for('app.bsky.feed.getLikes')->get( 'app.bsky.feed.getLikes' => \%args ); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getLikes: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | method getBookmarks(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getBookmarks: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my $res = $self->_at_for('app.bsky.bookmark.getBookmarks')->get( 'app.bsky.bookmark.getBookmarks' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | $res ? $res->{bookmarks} // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"bookmarks"} // ()
MC/DC0%0/2
$res->{"bookmarks"} // ()
$res->{"bookmarks"}
()
Truth table0%0/3
A // B
A= $res->{"bookmarks"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | method createBookmark( $uri, $cid //= () ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
createBookmark: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | if ( !defined $cid ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | my $post = $self->_at_for('app.bsky.feed.getPosts')->get( 'app.bsky.feed.getPosts' => { uris => [$uri] } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | $post || $post->throw; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $cid = $post->{posts}[0]{cid}; | |||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $self->_at_for('app.bsky.bookmark.createBookmark')->post( 'app.bsky.bookmark.createBookmark' => { uri => $uri, cid => $cid } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | method deleteBookmark($uri) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deleteBookmark: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $self->_at_for('app.bsky.bookmark.deleteBookmark')->post( 'app.bsky.bookmark.deleteBookmark' => { uri => $uri } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | method getQuotes(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getQuotes: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my $res = $self->_at_for('app.bsky.feed.getQuotes')->get( 'app.bsky.feed.getQuotes' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | $res ? $res->{quotes} // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"quotes"} // ()
MC/DC0%0/2
$res->{"quotes"} // ()
$res->{"quotes"}
()
Truth table0%0/3
A // B
A= $res->{"quotes"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | method getActorLikes(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getActorLikes: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | my $res = $self->_at_for('app.bsky.feed.getActorLikes')->get( 'app.bsky.feed.getActorLikes' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | $res ? $res->{feed} // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"feed"} // ()
MC/DC0%0/2
$res->{"feed"} // ()
$res->{"feed"}
()
Truth table0%0/3
A // B
A= $res->{"feed"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | method searchPosts(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
searchPosts: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | my $res = $self->_at_for('app.bsky.feed.searchPosts')->get( 'app.bsky.feed.searchPosts' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | $res ? $res->{posts} // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"posts"} // ()
MC/DC0%0/2
$res->{"posts"} // ()
$res->{"posts"}
()
Truth table0%0/3
A // B
A= $res->{"posts"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | method getSuggestedFeeds(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getSuggestedFeeds: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | my $res = $self->_at_for('app.bsky.feed.getSuggestedFeeds')->get( 'app.bsky.feed.getSuggestedFeeds' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | $res ? $res->{feeds} // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"feeds"} // ()
MC/DC0%0/2
$res->{"feeds"} // ()
$res->{"feeds"}
()
Truth table0%0/3
A // B
A= $res->{"feeds"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | method describeFeedGenerator() { $self->_at_for('app.bsky.feed.describeFeedGenerator')->get('app.bsky.feed.describeFeedGenerator') } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describeFeedGenerator: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | method getFeedGenerator($generator) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getFeedGenerator: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $self->_at_for('app.bsky.feed.getFeedGenerator')->get( 'app.bsky.feed.getFeedGenerator' => { feed => $generator } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | method getFeedGenerators(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getFeedGenerators: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | my $res = $self->_at_for('app.bsky.feed.getFeedGenerators')->get( 'app.bsky.feed.getFeedGenerators' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | $res ? $res->{feeds} // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"feeds"} // ()
MC/DC0%0/2
$res->{"feeds"} // ()
$res->{"feeds"}
()
Truth table0%0/3
A // B
A= $res->{"feeds"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | method getActorFeeds(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getActorFeeds: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | my $res = $self->_at_for('app.bsky.feed.getActorFeeds')->get( 'app.bsky.feed.getActorFeeds' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | $res ? $res->{feeds} // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"feeds"} // ()
MC/DC0%0/2
$res->{"feeds"} // ()
$res->{"feeds"}
()
Truth table0%0/3
A // B
A= $res->{"feeds"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | method getRepostedBy(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getRepostedBy: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | my $res = $self->_at_for('app.bsky.feed.getRepostedBy')->get( 'app.bsky.feed.getRepostedBy' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | $res ? $res->{repostedBy} // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"repostedBy"} // ()
MC/DC0%0/2
$res->{"repostedBy"} // ()
$res->{"repostedBy"}
()
Truth table0%0/3
A // B
A= $res->{"repostedBy"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | method repost( $uri, $cid //= () ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repost: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | if ( !defined $cid ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | my $post = $self->_at_for('app.bsky.feed.getPosts')->get( 'app.bsky.feed.getPosts' => { uris => [$uri] } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | $post || $post->throw; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | $cid = $post->{posts}[0]{cid}; | |||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | $self->at->create_record( 'app.bsky.feed.repost', { subject => { uri => $uri, cid => $cid }, createdAt => $self->at->_now->to_string } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | method deleteRepost($url) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deleteRepost: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | $url = At::Protocol::URI->new($url) unless builtin::blessed $url; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | if ( $url->collection eq 'app.bsky.feed.post' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my $post = $self->getPost($url); | |||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | $url = $post->{viewer}{repost} // return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$post->{"viewer"}{"repost"} // (return)
MC/DC0%0/1
$post->{"viewer"}{"repost"} // (return)
$post->{"viewer"}{"repost"}
Truth table0%0/2
A
A= $post->{"viewer"}{"repost"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | $self->at->delete_record( 'app.bsky.feed.repost', $url->rkey ); | |||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | method uploadBlob( $data, %opts ) { $self->at->upload_blob( $data, $opts{mime_type} // () ) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uploadBlob: not called CC=2 SCAR=17.9
Pod
documented
Condition0%0/3
$opts{"mime_type"} // ()
MC/DC0%0/2
$opts{"mime_type"} // ()
$opts{"mime_type"}
()
Truth table0%0/3
A // B
A= $opts{"mime_type"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 2 | ▶ | method createPost(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
createPost: called CC=34 SCAR=51.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||
| 246 | # TODO: | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # - recordWithMedia embed | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 249 | my %post = ( # these are the required fields which every post must include | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | '$type' => 'app.bsky.feed.post', | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | text => $args{text} // '', | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 2 | ▶ | createdAt => $args{timestamp} // $self->at->_now->to_string # trailing "Z" is preferred over "+00:00" | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$args{"text"} // ""
$args{"timestamp"} // $self->at->_now->to_string
MC/DC0%0/1
$args{"text"} // ""
$args{"text"}
MC/DC0%0/2
$args{"timestamp"} // $self->at->_now->to_string
$args{"timestamp"}
$self->at->_now->to_string
Truth table50%1/2
A
A= $args{"text"}
Truth table33%1/3
A // B
A= $args{"timestamp"}B= $self->at->_now->to_string
| |||||||||||||||||||||||||||||||||||||||||||||||
| 253 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||
| 255 | # indicate included languages (optional) | ||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 2 | ▶ | $post{langs} = [ ( ( builtin::reftype( $args{lang} ) // '' ) eq 'ARRAY' ) ? @{ $args{lang} } : $args{lang} ] if defined $args{lang}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/2
builtin::reftype($args{"lang"}) // ""
MC/DC0%0/1
builtin::reftype($args{"lang"}) // ""
builtin::reftype($args{"lang"})
Truth table0%0/2
A
A= builtin::reftype($args{"lang"})
| |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||
| 258 | # parse out mentions and URLs as "facets" | ||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 2 | ▶ | if ( length $post{text} > 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 2 | my @facets = $self->parse_facets( $post{text} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 261 | 2 | ▶ | $post{facets} = \@facets if @facets; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||
| 264 | # additional tags (up to 8) | ||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 2 | ▶ | $post{tags} = [ ( builtin::reftype( $args{tags} ) // '' ) eq 'ARRAY' ? @{ $args{tags} } : $args{tags} ] if defined $args{tags}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/2
builtin::reftype($args{"tags"}) // ""
MC/DC0%0/1
builtin::reftype($args{"tags"}) // ""
builtin::reftype($args{"tags"})
Truth table0%0/2
A
A= builtin::reftype($args{"tags"})
| |||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||
| 267 | # metadata tags on an atproto record, published by the author within the record (up to 10) | ||||||||||||||||||||||||||||||||||||||||||||||
| 268 | $post{labels} = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 269 | '$type' => 'com.atproto.label.defs#selfLabels', | ||||||||||||||||||||||||||||||||||||||||||||||
| 270 | values => [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | map { { '$type' => 'com.atproto.label.defs#selfLabel', val => $_ } } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
builtin::reftype($args{"labels"}) // ""
MC/DC0%0/1
builtin::reftype($args{"labels"}) // ""
builtin::reftype($args{"labels"})
Truth table0%0/2
A
A= builtin::reftype($args{"labels"})
| |||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ( ( builtin::reftype( $args{labels} ) // '' ) eq 'ARRAY' ? @{ $args{labels} } : $args{labels} ) | |||||||||||||||||||||||||||||||||||||||||||||
| 273 | ] | ||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 2 | ▶ | if defined $args{labels}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | #~ com.atproto.label.defs#selfLabels | ||||||||||||||||||||||||||||||||||||||||||||||
| 278 | # if this is a reply, get references to the parent and root | ||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 2 | ▶ | $post{reply} = $self->getReplyRefs( $args{reply_to} ) if defined $args{reply_to}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||
| 281 | # embeds | ||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 2 | ▶ | if ( defined $args{embed} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | if ( defined $args{embed}{images} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | $post{embed} = $self->uploadImages( @{ $args{embed}{images} } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 286 | elsif ( defined $args{embed}{video} ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | $post{embed} = $self->uploadVideo( $args{embed}{video} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 289 | elsif ( defined $args{embed}{url} ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | $post{embed} = $self->fetch_embed_url_card( $args{embed}{url} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 292 | elsif ( defined $args{embed}{ref} ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $post{embed} = $self->getEmbedRef( $args{embed}{ref} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 2 | my $res = $self->at->create_record( 'app.bsky.feed.post', \%post ); | |||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||
| 298 | # If reply_gate is requested, create a threadgate record | ||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 2 | ▶ | if ( $res && $res->{uri} && $args{reply_gate} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$res and $res->{"uri"} and $args{"reply_gate"}
$res and $res->{"uri"}
MC/DC33%1/3
$res and $res->{"uri"} and $args{"reply_gate"}
$res
$res->{"uri"}
$args{"reply_gate"}
Truth table50%2/4
A and B and C
A= $resB= $res->{"uri"}C= $args{"reply_gate"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 1 | my $post_uri = At::Protocol::URI->new( $res->{uri} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 301 | 1 | my @allow; | |||||||||||||||||||||||||||||||||||||||||||||
| 302 | 1 | ▶ | if ( ref $args{reply_gate} eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 1 | for my $type ( @{ $args{reply_gate} } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 304 | 2 | ▶ | if ( $type eq 'mention' ) { push @allow, { '$type' => 'app.bsky.feed.threadgate#mentionRule' }; } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 1 | elsif ( $type eq 'following' ) { push @allow, { '$type' => 'app.bsky.feed.threadgate#followingRule' }; } | |||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | elsif ( $type eq 'list' ) { push @allow, { '$type' => 'app.bsky.feed.threadgate#listRule', list => $args{reply_gate_list} }; } | |||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 1 | $self->at->create_record( 'app.bsky.feed.threadgate', | |||||||||||||||||||||||||||||||||||||||||||||
| 310 | { post => $post_uri->as_string, allow => \@allow, createdAt => $self->at->_now->to_string, }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 311 | $post_uri->rkey ); # Must match post rkey | ||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||
| 314 | # If post_gate is requested, create a postgate record | ||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 2 | ▶ | if ( $res && $res->{uri} && $args{post_gate} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$res and $res->{"uri"} and $args{"post_gate"}
$res and $res->{"uri"}
MC/DC33%1/3
$res and $res->{"uri"} and $args{"post_gate"}
$res
$res->{"uri"}
$args{"post_gate"}
Truth table50%2/4
A and B and C
A= $resB= $res->{"uri"}C= $args{"post_gate"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 1 | my $post_uri = At::Protocol::URI->new( $res->{uri} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 317 | 1 | my @embedding_rules; | |||||||||||||||||||||||||||||||||||||||||||||
| 318 | 1 | ▶ | if ( ref $args{post_gate} eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 1 | for my $rule ( @{ $args{post_gate} } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 320 | 1 | ▶ | if ( $rule eq 'disable' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 1 | push @embedding_rules, { '$type' => 'app.bsky.feed.postgate#disableRule' }; | |||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 1 | $self->at->create_record( 'app.bsky.feed.postgate', | |||||||||||||||||||||||||||||||||||||||||||||
| 326 | { post => $post_uri->as_string, embeddingRules => \@embedding_rules, createdAt => $self->at->_now->to_string, }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 327 | $post_uri->rkey ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 2 | return $res; | |||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | method deletePost($at_uri) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deletePost: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | $at_uri = At::Protocol::URI->new($at_uri) unless builtin::blessed $at_uri; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $self->at->delete_record( 'app.bsky.feed.post', $at_uri->rkey ); | |||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||
| 336 | # Automatically try to delete gates too | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | $self->at->delete_record( 'app.bsky.feed.threadgate', $at_uri->rkey ); | |||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $self->at->delete_record( 'app.bsky.feed.postgate', $at_uri->rkey ); | |||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | method like( $uri, $cid //= () ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
like: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | if ( !defined $cid ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my $post = $self->_at_for('app.bsky.feed.getPosts')->get( 'app.bsky.feed.getPosts' => { uris => [$uri] } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | $post || $post->throw; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | $cid = $post->{posts}[0]{cid}; | |||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 347 | $self->at->create_record( | ||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | 'app.bsky.feed.like', | |||||||||||||||||||||||||||||||||||||||||||||
| 349 | { '$type' => 'app.bsky.feed.like', | ||||||||||||||||||||||||||||||||||||||||||||||
| 350 | subject => { # com.atproto.repo.strongRef | ||||||||||||||||||||||||||||||||||||||||||||||
| 351 | uri => $uri, | ||||||||||||||||||||||||||||||||||||||||||||||
| 352 | cid => $cid | ||||||||||||||||||||||||||||||||||||||||||||||
| 353 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 354 | createdAt => $self->at->_now->to_string | ||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 356 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | method deleteLike($url) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deleteLike: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | $url = At::Protocol::URI->new($url) unless builtin::blessed $url; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | if ( $url->collection eq 'app.bsky.feed.post' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | my $post = $self->getPost($url); | |||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | $url = $post->{viewer}{like} // return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$post->{"viewer"}{"like"} // (return)
MC/DC0%0/1
$post->{"viewer"}{"like"} // (return)
$post->{"viewer"}{"like"}
Truth table0%0/2
A
A= $post->{"viewer"}{"like"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | $self->at->delete_record( 'app.bsky.feed.like', $url->rkey ); | |||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||
| 368 | # Social graph | ||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | method block($actor) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
block: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my $profile = $self->getProfile($actor); | |||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | $profile->{did} // return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$profile->{"did"} // (return)
MC/DC0%0/1
$profile->{"did"} // (return)
$profile->{"did"}
Truth table0%0/2
A
A= $profile->{"did"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | $self->at->create_record( 'app.bsky.graph.block', { createdAt => $self->at->_now->to_string, subject => $profile->{did} } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | method getBlocks(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getBlocks: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | my $res = $self->_at_for('app.bsky.graph.getBlocks')->get( 'app.bsky.graph.getBlocks' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | $res ? $res->{blocks} : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | method deleteBlock($url) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deleteBlock: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | $url = At::Protocol::URI->new($url) unless builtin::blessed $url; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | $self->at->delete_record( 'app.bsky.graph.block', $url->rkey ); | |||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | method follow($subject) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
follow: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | my $profile = $self->getProfile($subject); | |||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | $profile->{did} // return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$profile->{"did"} // (return)
MC/DC0%0/1
$profile->{"did"} // (return)
$profile->{"did"}
Truth table0%0/2
A
A= $profile->{"did"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 388 | $self->at->create_record( 'app.bsky.graph.follow', | ||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | { '$type' => 'app.bsky.graph.follow', subject => $profile->{did}, createdAt => $self->at->_now->to_string } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | method deleteFollow($url) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deleteFollow: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | $url = At::Protocol::URI->new($url) unless builtin::blessed $url; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | $self->at->delete_record( 'app.bsky.graph.follow', $url->rkey ); | |||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | method getFollows( $actor, %args ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getFollows: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | my $res = $self->_at_for('app.bsky.graph.getFollows')->get( 'app.bsky.graph.getFollows' => { actor => $actor, %args } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | $res ? $res->{follows} : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | method getFollowers( $actor, %args ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getFollowers: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | my $res = $self->_at_for('app.bsky.graph.getFollowers')->get( 'app.bsky.graph.getFollowers' => { actor => $actor, %args } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | $res ? $res->{followers} : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 1 | ▶ | method getKnownFollowers( $actor, %args ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getKnownFollowers: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 1 | my $res = $self->_at_for('app.bsky.graph.getKnownFollowers')->get( 'app.bsky.graph.getKnownFollowers' => { actor => $actor, %args } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 409 | 1 | ▶ | $res ? $res->{followers} : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | method getRelationships(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getRelationships: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | $args{actor} //= $self->at->did; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$args{"actor"} //= $self->at->did
MC/DC0%0/2
$args{"actor"} //= $self->at->did
$args{"actor"}
$self->at->did
Truth table0%0/3
A //= B
A= $args{"actor"}B= $self->at->did
| |||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | if ( exists $args{actors} && !exists $args{others} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $args{"actors"} and not exists $args{"others"}
MC/DC0%0/2
exists $args{"actors"} and not exists $args{"others"}
exists $args{"actors"}
not exists $args{"others"}
Truth table0%0/3
A and not(B)
A= exists $args{"actors"}B= not exists $args{"others"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $args{others} = delete $args{actors}; | |||||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | my $res = $self->_at_for('app.bsky.graph.getRelationships')->get( 'app.bsky.graph.getRelationships' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | $res ? $res->{relationships} : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | method getMutes(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getMutes: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | my $res = $self->_at_for('app.bsky.graph.getMutes')->get( 'app.bsky.graph.getMutes' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | $res ? $res->{mutes} // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"mutes"} // ()
MC/DC0%0/2
$res->{"mutes"} // ()
$res->{"mutes"}
()
Truth table0%0/3
A // B
A= $res->{"mutes"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | method muteThread($uri) { $self->_at_for('app.bsky.graph.muteThread')->post( 'app.bsky.graph.muteThread' => { root => $uri } ) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
muteThread: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | method unmuteThread($uri) { $self->_at_for('app.bsky.graph.unmuteThread')->post( 'app.bsky.graph.unmuteThread' => { root => $uri } ) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unmuteThread: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | method getLists( $actor, %args ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getLists: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | my $res = $self->_at_for('app.bsky.graph.getLists')->get( 'app.bsky.graph.getLists' => { actor => $actor, %args } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | $res ? $res->{lists} // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"lists"} // ()
MC/DC0%0/2
$res->{"lists"} // ()
$res->{"lists"}
()
Truth table0%0/3
A // B
A= $res->{"lists"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | ▶ | method getList( $list, %args ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getList: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my $res = $self->_at_for('app.bsky.graph.getList')->get( 'app.bsky.graph.getList' => { list => $list, %args } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | $res ? $res->{items} // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"items"} // ()
MC/DC0%0/2
$res->{"items"} // ()
$res->{"items"}
()
Truth table0%0/3
A // B
A= $res->{"items"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | method getStarterPack($uri) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getStarterPack: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | $self->_at_for('app.bsky.graph.getStarterPack')->get( 'app.bsky.graph.getStarterPack' => { starterPack => $uri } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | method getStarterPacks(@uris) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getStarterPacks: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | my $res = $self->_at_for('app.bsky.graph.getStarterPacks')->get( 'app.bsky.graph.getStarterPacks' => { uris => \@uris } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | $res ? $res->{starterPacks} // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"starterPacks"} // ()
MC/DC0%0/2
$res->{"starterPacks"} // ()
$res->{"starterPacks"}
()
Truth table0%0/3
A // B
A= $res->{"starterPacks"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | method getActorStarterPacks( $actor, %args ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getActorStarterPacks: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | my $res | |||||||||||||||||||||||||||||||||||||||||||||
| 449 | = $self->_at_for('app.bsky.graph.getActorStarterPacks')->get( 'app.bsky.graph.getActorStarterPacks' => { actor => $actor, %args } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | $res ? $res->{starterPacks} // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"starterPacks"} // ()
MC/DC0%0/2
$res->{"starterPacks"} // ()
$res->{"starterPacks"}
()
Truth table0%0/3
A // B
A= $res->{"starterPacks"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||
| 453 | # Actors | ||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | method getProfile($actor) { $self->_at_for('app.bsky.actor.getProfile')->get( 'app.bsky.actor.getProfile' => { actor => $actor } ) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getProfile: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | method getPreferences() { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getPreferences: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | my $res = $self->_at_for('app.bsky.actor.getPreferences')->get('app.bsky.actor.getPreferences'); | |||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | $res ? $res->{preferences} : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | method putPreferences($preferences) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
putPreferences: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | $self->_at_for('app.bsky.actor.putPreferences')->post( 'app.bsky.actor.putPreferences' => { preferences => $preferences } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | method upsertProfile($cb) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
upsertProfile: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | my $profile = $self->_at_for('com.atproto.repo.getRecord') | |||||||||||||||||||||||||||||||||||||||||||||
| 467 | ->get( 'com.atproto.repo.getRecord' => { repo => $self->at->did, collection => 'app.bsky.actor.profile', rkey => 'self' } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | my %existing = $profile ? %{ $profile->{value} } : ( '$type' => 'app.bsky.actor.profile' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | my $updated = $cb->(%existing); | |||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | my $res = $self->at->put_record( 'app.bsky.actor.profile', 'self', $updated, $profile ? $profile->{cid} : () ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | ▶ | $res // 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$res // 1
MC/DC0%0/1
$res // 1
$res
Truth table0%0/2
A
A= $res
| |||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | method getProfiles(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getProfiles: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | my $res = $self->_at_for('app.bsky.actor.getProfiles')->get( 'app.bsky.actor.getProfiles' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | return $res ? ( $res->{profiles} // [] ) : []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$res->{"profiles"} // []
MC/DC0%0/1
$res->{"profiles"} // []
$res->{"profiles"}
Truth table0%0/2
A
A= $res->{"profiles"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | method getSuggestions(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getSuggestions: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | my $res = $self->_at_for('app.bsky.actor.getSuggestions')->get( 'app.bsky.actor.getSuggestions' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | $res ? $res->{actors} : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | method searchActors(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
searchActors: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | my $res = $self->_at_for('app.bsky.actor.searchActors')->get( 'app.bsky.actor.searchActors' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | $res ? $res->{actors} : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | method searchActorsTypeahead(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
searchActorsTypeahead: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | my $res = $self->_at_for('app.bsky.actor.searchActorsTypeahead')->get( 'app.bsky.actor.searchActorsTypeahead' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | $res ? $res->{actors} : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | method mute($actor) { $self->_at_for('app.bsky.graph.muteActor')->post( 'app.bsky.graph.muteActor' => { actor => $actor } ) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mute: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | ▶ | method unmute($actor) { $self->_at_for('app.bsky.graph.unmuteActor')->post( 'app.bsky.graph.unmuteActor' => { actor => $actor } ) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unmute: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | method muteModList($listUri) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
muteModList: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | $self->_at_for('app.bsky.graph.muteActorList')->post( 'app.bsky.graph.muteActorList' => { list => $listUri } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | method unmuteModList($listUri) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unmuteModList: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | $self->_at_for('app.bsky.graph.unmuteActorList')->post( 'app.bsky.graph.unmuteActorList' => { list => $listUri } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | ▶ | method blockModList($listUri) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
blockModList: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | $self->at->create_record( 'app.bsky.graph.listblock', | |||||||||||||||||||||||||||||||||||||||||||||
| 506 | { '$type' => 'app.bsky.graph.listblock', subject => $listUri, createdAt => $self->at->_now->to_string } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||
| 509 | # Moderation | ||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 1 | ▶ | method report ( $subject, $reason_type, $reason = () ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
report: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 1 | ▶ | $self->_at_for('com.atproto.moderation.createReport') | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 512 | ->post( 'com.atproto.moderation.createReport' => | ||||||||||||||||||||||||||||||||||||||||||||||
| 513 | { subject => $subject, reasonType => $reason_type, defined $reason ? ( reason => $reason ) : () } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | ▶ | method unblockModList($url) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unblockModList: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | ▶ | $url = At::Protocol::URI->new($url) unless builtin::blessed $url; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | $self->at->delete_record( 'app.bsky.graph.listblock', $url->rkey ); | |||||||||||||||||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||
| 521 | # Notifications | ||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | method listNotifications(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listNotifications: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | my $res = $self->at->get( 'app.bsky.notification.listNotifications' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | $res ? $res->{notifications} : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | method countUnreadNotifications() { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
countUnreadNotifications: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | my $res = $self->at->get('app.bsky.notification.getUnreadCount'); | |||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | $res ? $res->{count} : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | method updateSeenNotifications( $seenAt = undef ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
updateSeenNotifications: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | my $res = $self->at->post( 'app.bsky.notification.updateSeen' => { seenAt => $seenAt // $self->at->_now->to_string } ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$seenAt // $self->at->_now->to_string
MC/DC0%0/2
$seenAt // $self->at->_now->to_string
$seenAt
$self->at->_now->to_string
Truth table0%0/3
A // B
A= $seenAtB= $self->at->_now->to_string
| |||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | $res // 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$res // 1
MC/DC0%0/1
$res // 1
$res
Truth table0%0/2
A
A= $res
| |||||||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||
| 537 | # Identity | ||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | method resolveHandle($handle) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolveHandle: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | my $res = $self->at->get( 'com.atproto.identity.resolveHandle' => { handle => $handle } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | $res ? $res->{did} : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | method updateHandle($handle) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
updateHandle: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | $self->at->post( 'com.atproto.identity.updateHandle' => { handle => $handle } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | ▶ | method describeServer() { $self->at->get('com.atproto.server.describeServer') } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describeServer: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | ▶ | method listRecords(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listRecords: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | my $res = $self->at->get( 'com.atproto.repo.listRecords' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | $res ? $res->{records} // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"records"} // ()
MC/DC0%0/2
$res->{"records"} // ()
$res->{"records"}
()
Truth table0%0/3
A // B
A= $res->{"records"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | method getLabelerServices(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getLabelerServices: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | my $res = $self->at->get( 'app.bsky.labeler.getServices' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | ▶ | $res ? $res->{views} // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"views"} // ()
MC/DC0%0/2
$res->{"views"} // ()
$res->{"views"}
()
Truth table0%0/3
A // B
A= $res->{"views"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||
| 558 | # Chat | ||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 1 | ▶ | method listConvos(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listConvos: called CC=3 SCAR=13.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 1 | my $res = $self->_at_for('chat.bsky.convo.listConvos')->get( 'chat.bsky.convo.listConvos' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 561 | 1 | ▶ | $res ? $res->{convos} // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$res->{"convos"} // ()
MC/DC0%0/2
$res->{"convos"} // ()
$res->{"convos"}
()
Truth table33%1/3
A // B
A= $res->{"convos"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | method getConvo($convoId) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getConvo: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | my $res = $self->_at_for('chat.bsky.convo.getConvo')->get( 'chat.bsky.convo.getConvo' => { convoId => $convoId } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | ▶ | $res ? $res->{convo} // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"convo"} // ()
MC/DC0%0/2
$res->{"convo"} // ()
$res->{"convo"}
()
Truth table0%0/3
A // B
A= $res->{"convo"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | method getConvoForMembers(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getConvoForMembers: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | my $res = $self->_at_for('chat.bsky.convo.getConvoForMembers')->get( 'chat.bsky.convo.getConvoForMembers' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | $res ? $res->{convo} // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"convo"} // ()
MC/DC0%0/2
$res->{"convo"} // ()
$res->{"convo"}
()
Truth table0%0/3
A // B
A= $res->{"convo"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 1 | ▶ | method getMessages(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getMessages: called CC=3 SCAR=13.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 1 | my $res = $self->_at_for('chat.bsky.convo.getMessages')->get( 'chat.bsky.convo.getMessages' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 576 | 1 | ▶ | $res ? $res->{messages} // () : $res; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$res->{"messages"} // ()
MC/DC0%0/2
$res->{"messages"} // ()
$res->{"messages"}
()
Truth table33%1/3
A // B
A= $res->{"messages"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 1 | ▶ | method sendMessage( $convoId, $message ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sendMessage: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 1 | $self->_at_for('chat.bsky.convo.sendMessage')->post( 'chat.bsky.convo.sendMessage' => { convoId => $convoId, message => $message } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | method acceptConvo($convoId) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
acceptConvo: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | $self->_at_for('chat.bsky.convo.acceptConvo')->post( 'chat.bsky.convo.acceptConvo' => { convoId => $convoId } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | ▶ | method leaveConvo($convoId) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
leaveConvo: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | $self->_at_for('chat.bsky.convo.leaveConvo')->post( 'chat.bsky.convo.leaveConvo' => { convoId => $convoId } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | ▶ | method updateRead( $convoId, $messageId = undef ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
updateRead: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | $self->_at_for('chat.bsky.convo.updateRead')->post( 'chat.bsky.convo.updateRead' => { convoId => $convoId, messageId => $messageId } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 1 | ▶ | method muteConvo($convoId) { $self->_at_for('chat.bsky.convo.muteConvo')->post( 'chat.bsky.convo.muteConvo' => { convoId => $convoId } ) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
muteConvo: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 1 | ▶ | method unmuteConvo($convoId) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unmuteConvo: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 1 | $self->_at_for('chat.bsky.convo.unmuteConvo')->post( 'chat.bsky.convo.unmuteConvo' => { convoId => $convoId } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | method addReaction( $convoId, $messageId, $reaction ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
addReaction: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | $self->_at_for('chat.bsky.convo.addReaction') | |||||||||||||||||||||||||||||||||||||||||||||
| 602 | ->post( 'chat.bsky.convo.addReaction' => { convoId => $convoId, messageId => $messageId, reaction => $reaction } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | ▶ | method removeReaction( $convoId, $messageId, $reaction ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
removeReaction: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | $self->_at_for('chat.bsky.convo.removeReaction') | |||||||||||||||||||||||||||||||||||||||||||||
| 607 | ->post( 'chat.bsky.convo.removeReaction' => { convoId => $convoId, messageId => $messageId, reaction => $reaction } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | ▶ | method deleteMessageForSelf( $convoId, $messageId ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deleteMessageForSelf: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | $self->_at_for('chat.bsky.convo.deleteMessageForSelf') | |||||||||||||||||||||||||||||||||||||||||||||
| 612 | ->post( 'chat.bsky.convo.deleteMessageForSelf' => { convoId => $convoId, messageId => $messageId } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | ▶ | method getConvoAvailability(%args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getConvoAvailability: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | $self->_at_for('chat.bsky.convo.getConvoAvailability')->get( 'chat.bsky.convo.getConvoAvailability' => \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | ▶ | method getLog(%args) { $self->_at_for('chat.bsky.convo.getLog')->get( 'chat.bsky.convo.getLog' => \%args ) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getLog: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||
| 620 | # Utils | ||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 9 | ▶ | method parse_mentions($text) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_mentions: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 9 | my @spans; | |||||||||||||||||||||||||||||||||||||||||||||
| 623 | 9 | ▶ | push @spans, { start => $-[1], handle => $2, end => $+[1] } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 624 | while $text =~ /(?:\A|\W)(@(([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?))/g; | ||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 9 | @spans; | |||||||||||||||||||||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 10 | ▶ | method parse_urls($text) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_urls: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 10 | my @spans; | |||||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||||||
| 631 | # partial/naive URL regex based on: https://stackoverflow.com/a/3809435 | ||||||||||||||||||||||||||||||||||||||||||||||
| 632 | # tweaked to disallow some training punctuation | ||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 10 | ▶ | push @spans, { start => $-[1], url => $1, end => $+[1] } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 634 | while $text | ||||||||||||||||||||||||||||||||||||||||||||||
| 635 | =~ /(?:\A|\W)(https?:\/\/(www\.)?[-a-zA-Z0-9\@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9\(\)\@:%_\+.~#?&\/\/=]*[-a-zA-Z0-9@%_\+~#\/\/=])?)/g; | ||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 10 | @spans; | |||||||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 3 | ▶ | method parse_tags($text) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_tags: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 3 | my @spans; | |||||||||||||||||||||||||||||||||||||||||||||
| 641 | 3 | ▶ | push @spans, { start => $-[1], tag => $2, end => $+[1] } while $text =~ /(?:\A|\W)(#+(\w{1, 640}))/g; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 3 | @spans; | |||||||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 3 | ▶ | method parse_facets($text) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_facets: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 3 | my @facets; | |||||||||||||||||||||||||||||||||||||||||||||
| 647 | 3 | for my $m ( $self->parse_mentions($text) ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 648 | 1 | my $res = $self->at->get( 'com.atproto.identity.resolveHandle', { handle => $m->{handle} } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||
| 650 | # if handle cannot be resolved, just skip it. Bluesky will display it as plain text | ||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 1 | ▶ | $res || next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 652 | push @facets, | ||||||||||||||||||||||||||||||||||||||||||||||
| 653 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 654 | index => { byteStart => $m->{start}, byteEnd => $m->{end} }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 1 | features => [ { '$type' => 'app.bsky.richtext.facet#mention', did => $res->{did} } ] | |||||||||||||||||||||||||||||||||||||||||||||
| 656 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 3 | for my $m ( $self->parse_urls($text) ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 659 | push @facets, | ||||||||||||||||||||||||||||||||||||||||||||||
| 660 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 661 | index => { byteStart => $m->{start}, byteEnd => $m->{end} }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 2 | features => [ { '$type' => 'app.bsky.richtext.facet#link', uri => $m->{url} } ] | |||||||||||||||||||||||||||||||||||||||||||||
| 663 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 3 | for my $m ( $self->parse_tags($text) ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 666 | push @facets, | ||||||||||||||||||||||||||||||||||||||||||||||
| 667 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 668 | index => { byteStart => $m->{start}, byteEnd => $m->{end} }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 1 | features => [ { '$type' => 'app.bsky.richtext.facet#tag', tag => $m->{tag} } ] | |||||||||||||||||||||||||||||||||||||||||||||
| 670 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 3 | @facets; | |||||||||||||||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 4 | ▶ | method parse_uri($uri) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_uri: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 4 | require At::Protocol::URI; # Should already be loaded but... | |||||||||||||||||||||||||||||||||||||||||||||
| 677 | 4 | ▶ | $uri = At::Protocol::URI->new($uri) unless builtin::blessed $uri; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 4 | { repo => $uri->host, collection => $uri->collection, rkey => $uri->rkey }; | |||||||||||||||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 2 | ▶ | method getReplyRefs($parent_uri) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getReplyRefs: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 2 | my $res = $self->at->get( 'com.atproto.repo.getRecord', $self->parse_uri($parent_uri) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 683 | 2 | ▶ | $res || return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 2 | my $root = my $parent = $res; | |||||||||||||||||||||||||||||||||||||||||||||
| 685 | 2 | ▶ | if ( $parent->{value}{reply} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 1 | $root = $self->at->get( 'com.atproto.repo.getRecord', $self->parse_uri( $parent->{value}{reply}{root}{uri} ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 687 | 1 | ▶ | $res ||= $parent; # escape hatch | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$res ||= $parent
MC/DC0%0/2
$res ||= $parent
$res
$parent
Truth table33%1/3
A ||= B
A= $resB= $parent
| |||||||||||||||||||||||||||||||||||||||||||||||
| 688 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 2 | { root => { uri => $root->{uri}, cid => $root->{cid} }, parent => { uri => $parent->{uri}, cid => $parent->{cid} } }; | |||||||||||||||||||||||||||||||||||||||||||||
| 690 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | ▶ | method uploadFile( $bytes, $mime_type //= undef ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uploadFile: not called CC=28 SCAR=67.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | if ( builtin::blessed $bytes ) { $bytes = $bytes->slurp_raw } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 694 | ▶ | elsif ( ( $^O eq 'MSWin32' ? $bytes !~ m/[\x00<>:"\/\\|?*]/ : 1 ) && -e $bytes ) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$^O eq "MSWin32" ? !($bytes =~ m[[\x00<>:"/\\|?*]]d) : 1 and -e $bytes
MC/DC0%0/2
$^O eq "MSWin32" ? !($bytes =~ m[[\x00<>:"/\\|?*]]d) : 1 and -e $bytes
$^O eq "MSWin32" ? !($bytes =~ m[[\x00<>:"/\\|?*]]d) : 1
-e $bytes
Truth table0%0/3
A and B
A= $^O eq "MSWin32" ? !($bytes =~ m[[\x00<>:"/\\|?*]]d) : 1B= -e $bytes
| |||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | $bytes = path($bytes)->slurp_raw; | |||||||||||||||||||||||||||||||||||||||||||||
| 696 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||||||||||
| 698 | # TODO: a non-naive implementation would strip EXIF metadata from JPEG files here by default | ||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | ▶ | my $determined_mime | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 10 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 700 | = defined $mime_type ? $mime_type : | ||||||||||||||||||||||||||||||||||||||||||||||
| 701 | ( $bytes =~ /^GIF89a/ ? 'image/gif' : | ||||||||||||||||||||||||||||||||||||||||||||||
| 702 | $bytes =~ /^.{2}JFIF/ ? 'image/jpeg' : | ||||||||||||||||||||||||||||||||||||||||||||||
| 703 | $bytes =~ /^.{4}PNG\r\n\x1a\n/ ? 'image/png' : | ||||||||||||||||||||||||||||||||||||||||||||||
| 704 | $bytes =~ /^.{8}BM/ ? 'image/bmp' : | ||||||||||||||||||||||||||||||||||||||||||||||
| 705 | $bytes =~ /^.{4}(II|MM)\x42\x4D/ ? 'image/tiff' : | ||||||||||||||||||||||||||||||||||||||||||||||
| 706 | $bytes =~ /^.{4}8BPS/ ? 'image/psd' : | ||||||||||||||||||||||||||||||||||||||||||||||
| 707 | $bytes =~ /^data:image\/svg\+xml;/ ? 'image/svg+xml' : | ||||||||||||||||||||||||||||||||||||||||||||||
| 708 | $bytes =~ /^.{4}ftypqt / ? 'video/quicktime' : | ||||||||||||||||||||||||||||||||||||||||||||||
| 709 | $bytes =~ /^.{4}ftyp(isom|mp4[12]?|MSNV|M4[v|a]|f4v)/i ? 'video/mp4' : | ||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 'application/octet-stream' ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | my $at_http = $self->at->http; | |||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | my $url = sprintf( '%s/xrpc/%s', $self->at->host, 'com.atproto.repo.uploadBlob' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | ▶ | my %headers = ( 'Content-Type' => $determined_mime, ( $at_http->auth ? ( 'Authorization' => $at_http->auth ) : () ), ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | ▶ | $headers{DPoP} = $at_http->_generate_dpop_proof( $url, 'POST' ) if $at_http->token_type eq 'DPoP'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | ▶ | state $http //= HTTP::Tiny->new; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
state $http //= "HTTP::Tiny"->new
MC/DC0%0/2
state $http //= "HTTP::Tiny"->new
state $http
"HTTP::Tiny"->new
Truth table0%0/3
A //= B
A= state $httpB= "HTTP::Tiny"->new
| |||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | my $res = $http->post( $url, { content => $bytes, headers => \%headers } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | my $content = $res->{content}; | |||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | ▶ | if ( $res->{success} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | ▶ | $content = decode_json($content) if $content && ( $res->{headers}{'content-type'} // '' ) =~ m[json]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$content and ($res->{"headers"}{"content-type"} // "") =~ /json/d
$res->{"headers"}{"content-type"} // ""
MC/DC0%0/2
$content and ($res->{"headers"}{"content-type"} // "") =~ /json/d
$content
$res->{"headers"}{"content-type"}
Truth table0%0/3
A and B
A= $contentB= $res->{"headers"}{"content-type"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | return $content->{blob}; | |||||||||||||||||||||||||||||||||||||||||||||
| 722 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | ▶ | my $msg = $res->{reason} // 'Unknown error'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$res->{"reason"} // "Unknown error"
MC/DC0%0/1
$res->{"reason"} // "Unknown error"
$res->{"reason"}
Truth table0%0/2
A
A= $res->{"reason"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | ▶ | if ( $content && ( $res->{headers}{'content-type'} // '' ) =~ m[json] ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$content and ($res->{"headers"}{"content-type"} // "") =~ /json/d
$res->{"headers"}{"content-type"} // ""
MC/DC0%0/2
$content and ($res->{"headers"}{"content-type"} // "") =~ /json/d
$content
$res->{"headers"}{"content-type"}
Truth table0%0/3
A and B
A= $contentB= $res->{"headers"}{"content-type"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | my $json = decode_json($content); | |||||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | ▶ | $msg .= ': ' . $json->{message} if $json->{message}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 727 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | return At::Error->new( message => $msg, fatal => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | ▶ | method uploadImages(@images) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uploadImages: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | my @ret; | |||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | for my $img (@images) { | |||||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | my $alt = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | my $mime = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | ▶ | if ( ( builtin::reftype($img) // '' ) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
builtin::reftype($img) // ""
MC/DC0%0/1
builtin::reftype($img) // ""
builtin::reftype($img)
Truth table0%0/2
A
A= builtin::reftype($img)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | $alt = $img->{alt}; | |||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | ▶ | $mime = $img->{mime} // (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$img->{"mime"} // ()
MC/DC0%0/2
$img->{"mime"} // ()
$img->{"mime"}
()
Truth table0%0/3
A // B
A= $img->{"mime"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | $img = $img->{image}; | |||||||||||||||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | ▶ | if ( builtin::blessed $img ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | ▶ | At::Error->new( message => 'image file size too large. 1000000 bytes maximum, got: ' . $img->size )->throw | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 743 | if $img->size > 1000000; | ||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | $img = $img->slurp_raw; | |||||||||||||||||||||||||||||||||||||||||||||
| 745 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 746 | ▶ | elsif ( ( $^O eq 'MSWin32' ? $img !~ m/[\x00<>:"\/\\|?*]/ : 1 ) && -e $img ) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$^O eq "MSWin32" ? !($img =~ m[[\x00<>:"/\\|?*]]d) : 1 and -e $img
MC/DC0%0/2
$^O eq "MSWin32" ? !($img =~ m[[\x00<>:"/\\|?*]]d) : 1 and -e $img
$^O eq "MSWin32" ? !($img =~ m[[\x00<>:"/\\|?*]]d) : 1
-e $img
Truth table0%0/3
A and B
A= $^O eq "MSWin32" ? !($img =~ m[[\x00<>:"/\\|?*]]d) : 1B= -e $img
| |||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | $img = path($img); | |||||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | ▶ | At::Error->new( message => 'image file size too large. 1000000 bytes maximum, got: ' . $img->size )->throw | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 749 | if $img->size > 1000000; | ||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | $img = path($img)->slurp_raw; | |||||||||||||||||||||||||||||||||||||||||||||
| 751 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 752 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | ▶ | At::Error->new( message => 'image file size too large. 1000000 bytes maximum, got: ' . length $img )->throw | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 754 | if length $img > 1000000; | ||||||||||||||||||||||||||||||||||||||||||||||
| 755 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | my $blob = $self->uploadFile( $img, $mime ); | |||||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | ▶ | $blob || $blob->throw; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | push @ret, { alt => $alt, image => $blob }; | |||||||||||||||||||||||||||||||||||||||||||||
| 759 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | { '$type' => 'app.bsky.embed.images', images => \@ret }; | |||||||||||||||||||||||||||||||||||||||||||||
| 761 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | ▶ | method uploadVideoCaption( $lang, $caption ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uploadVideoCaption: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | ▶ | if ( builtin::blessed $caption ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | ▶ | At::Error->new( message => 'caption file size too large. 20000 bytes maximum, got: ' . $caption->size )->throw | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 766 | if $caption->size > 20000; | ||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | $caption = $caption->slurp_raw; | |||||||||||||||||||||||||||||||||||||||||||||
| 768 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 769 | ▶ | elsif ( ( $^O eq 'MSWin32' ? $caption !~ m/[\x00<>:"\/\\|?*]/ : 1 ) && -e $caption ) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$^O eq "MSWin32" ? !($caption =~ m[[\x00<>:"/\\|?*]]d) : 1 and -e $caption
MC/DC0%0/2
$^O eq "MSWin32" ? !($caption =~ m[[\x00<>:"/\\|?*]]d) : 1 and -e $caption
$^O eq "MSWin32" ? !($caption =~ m[[\x00<>:"/\\|?*]]d) : 1
-e $caption
Truth table0%0/3
A and B
A= $^O eq "MSWin32" ? !($caption =~ m[[\x00<>:"/\\|?*]]d) : 1B= -e $caption
| |||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | $caption = path($caption); | |||||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | ▶ | At::Error->new( message => 'caption file size too large. 20000 bytes maximum, got: ' . $caption->size )->throw | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 772 | if $caption->size > 20000; | ||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | $caption = path($caption)->slurp_raw; | |||||||||||||||||||||||||||||||||||||||||||||
| 774 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 775 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | ▶ | At::Error->new( message => 'cation file size too large. 20000 bytes maximum, got: ' . length $caption )->throw | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 777 | if length $caption > 20000; | ||||||||||||||||||||||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | my $blob = $self->uploadFile( $caption, 'text/vtt' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | ▶ | $blob || $blob->throw; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | { '$type' => 'app.bsky.embed.video#caption', lang => $lang, file => $blob }; | |||||||||||||||||||||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | ▶ | method uploadVideo($vid) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uploadVideo: not called CC=15 SCAR=54.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 0 | my @ret; | |||||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | my ( $alt, $mime, $aspectRatio ); | |||||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | my @captions; | |||||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | ▶ | if ( ( builtin::reftype($vid) // '' ) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
builtin::reftype($vid) // ""
MC/DC0%0/1
builtin::reftype($vid) // ""
builtin::reftype($vid)
Truth table0%0/2
A
A= builtin::reftype($vid)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | $alt = $vid->{alt}; | |||||||||||||||||||||||||||||||||||||||||||||
| 790 | 0 | ▶ | $mime = $vid->{mime} // (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$vid->{"mime"} // ()
MC/DC0%0/2
$vid->{"mime"} // ()
$vid->{"mime"}
()
Truth table0%0/3
A // B
A= $vid->{"mime"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | $aspectRatio = $vid->{aspectRatio}; | |||||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | @captions = map { { lang => $_, file => $self->uploadFile( $vid->{captions}{$_}, 'text/vtt' ) } } keys %{ $vid->{captions} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | $vid = $vid->{video}; | |||||||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | ▶ | if ( builtin::blessed $vid ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | ▶ | At::Error->new( message => 'video file size too large. 50000000 bytes maximum, got: ' . $vid->size )->throw if $vid->size > 50000000; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | $vid = $vid->slurp_raw; | |||||||||||||||||||||||||||||||||||||||||||||
| 798 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 799 | ▶ | elsif ( ( $^O eq 'MSWin32' ? $vid !~ m/[\x00<>:"\/\\|?*]/ : 1 ) && -e $vid ) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$^O eq "MSWin32" ? !($vid =~ m[[\x00<>:"/\\|?*]]d) : 1 and -e $vid
MC/DC0%0/2
$^O eq "MSWin32" ? !($vid =~ m[[\x00<>:"/\\|?*]]d) : 1 and -e $vid
$^O eq "MSWin32" ? !($vid =~ m[[\x00<>:"/\\|?*]]d) : 1
-e $vid
Truth table0%0/3
A and B
A= $^O eq "MSWin32" ? !($vid =~ m[[\x00<>:"/\\|?*]]d) : 1B= -e $vid
| |||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | $vid = path($vid); | |||||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | ▶ | At::Error->new( message => 'video file size too large. 50000000 bytes maximum, got: ' . $vid->size )->throw if $vid->size > 50000000; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | $vid = path($vid)->slurp_raw; | |||||||||||||||||||||||||||||||||||||||||||||
| 803 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 804 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | ▶ | At::Error->new( message => 'video file size too large. 50000000 bytes maximum, got: ' . length $vid )->throw | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 806 | if length $vid > 50000000; | ||||||||||||||||||||||||||||||||||||||||||||||
| 807 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | my $blob = $self->uploadFile( $vid, $mime ); | |||||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | ▶ | $blob || return $blob->throw; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 810 | return { | ||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | ▶ | '$type' => 'app.bsky.embed.video', | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 812 | video => $blob, | ||||||||||||||||||||||||||||||||||||||||||||||
| 813 | ( @captions ? ( captions => \@captions ) : () ), ( defined $alt ? ( alt => $alt ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 814 | ( defined $aspectRatio ? ( aspectRatio => $aspectRatio ) : () ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 815 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 816 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | ▶ | method getEmbedRef($uri) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getEmbedRef: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | my $res = $self->at->get( 'com.atproto.repo.getRecord', $self->parse_uri($uri) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | ▶ | $res || return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | { '$type' => 'app.bsky.embed.record', record => { uri => $res->{uri}, cid => $res->{cid} } }; | |||||||||||||||||||||||||||||||||||||||||||||
| 822 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | ▶ | method fetch_embed_url_card($url) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch_embed_url_card: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | my %card = ( uri => $url, title => '', description => '' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | ▶ | state $http //= HTTP::Tiny->new; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
state $http //= "HTTP::Tiny"->new
MC/DC0%0/2
state $http //= "HTTP::Tiny"->new
state $http
"HTTP::Tiny"->new
Truth table0%0/3
A //= B
A= state $httpB= "HTTP::Tiny"->new
| |||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | my $res = $http->get($url); | |||||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | ▶ | if ( $res->{success} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | ( $card{title} ) = $res->{content} =~ m[<title>(.*?)</title>.*</head>]is; | |||||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | ▶ | ( $card{description} ) = ( $res->{content} =~ m[<meta name="description" content="(.*?)".+</meta>.*</head>]is ) // ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$res->{"content"} =~ m[<meta name="description" content="(.*?)".+</meta>.*</head>]dis // ""
MC/DC0%0/1
$res->{"content"} =~ m[<meta name="description" content="(.*?)".+</meta>.*</head>]dis // ""
$res->{"content"} =~ m[<meta name="description" content="(.*?)".+</meta>.*</head>]dis
Truth table0%0/2
A
A= $res->{"content"} =~ m[<meta name="description" content="(.*?)".+</meta>.*</head>]dis
| |||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | my ($image) = $res->{content} =~ m[<img.*?src="([^"]*)"[^>]*>(?:</img>)?]isp; | |||||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | ▶ | if ( defined $image ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | ▶ | if ( $image =~ /^data:/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | $card{thumb} = $self->uploadFile($image); | |||||||||||||||||||||||||||||||||||||||||||||
| 835 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 836 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | $res = $http->get( URI->new_abs( $image, $url ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | ▶ | $card{thumb} = $res->{success} ? $self->uploadFile( $res->{content}, $res->{headers}{'content-type'} ) : (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 839 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 841 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | { '$type' => 'app.bsky.embed.external', external => \%card }; | |||||||||||||||||||||||||||||||||||||||||||||
| 843 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 844 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 845 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 846 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||