App-SpreadRevolutionaryDate

 view release on metacpan or  search on metacpan

lib/App/SpreadRevolutionaryDate/BlueskyLite.pm  view on Meta::CPAN

    }
    my $img_response = $ua->get($img_url);
    return unless $img_response->is_success;

    my $blob_req = HTTP::Request->new('POST', 'https://bsky.social/xrpc/com.atproto.repo.uploadBlob');
    $blob_req->header('Content-Type' => $img_response->header('Content-Type'));
    $blob_req->content($img_response->content);
    my $blob_response = $self->{ua}->request($blob_req);
    return unless $blob_response->is_success;

    my $blob_content = decode_json($blob_response->decoded_content);
    ($card->{thumb}) = $blob_content->{blob};
  }

  return $card;
}

sub _lookup_repo {
  my $self = shift;
  my $account = shift || return;
  $account .= '.bsky.social' unless $account =~ /[â‹…]/;
  my $uri = URI->new('https://bsky.social/xrpc/com.atproto.identity.resolveHandle');
  $uri->query_form(handle => $account);
  my $response = $self->{ua}->get($uri);
  return if !$response->is_success;

  my $content = decode_json($response->decoded_content);
  return $content->{did};
}

sub _generate_facets {
  my $self = shift;
  my $text = shift || return;
  my $facets = [];
  my $embed;
  my $pos = 0;
  foreach my $w (split /\s+/, $text) {

lib/App/SpreadRevolutionaryDate/BlueskyLite.pm  view on Meta::CPAN

    password   => $args{'password'},
  );
  my $json = encode_json(\%payload);

  my $req = HTTP::Request->new('POST', 'https://bsky.social/xrpc/com.atproto.server.createSession');
  $req->header('Content-Type' => 'application/json');
  $req->content($json);
  my $response = $self{ua}->request($req);

  if ($response->is_success) {
    my $content = decode_json($response->decoded_content);
    my $did = $content->{did};
    my $access_jwt = $content->{accessJwt};
    $self{ua}->default_header('Authorization' => 'Bearer ' . $access_jwt);
    $self{did} = $did;
  }

  my $self = bless(\%self, $class);
  return $self;
}

lib/App/SpreadRevolutionaryDate/BlueskyLite.pm  view on Meta::CPAN

        $img_bytes = <$fh>;
    }
    close $fh;

    my $blob_req = HTTP::Request->new('POST', 'https://bsky.social/xrpc/com.atproto.repo.uploadBlob');
    $blob_req->header('Content-Type' => $mime_type);
    $blob_req->content($img_bytes);
    my $blob_response = $self->{ua}->request($blob_req);
    return unless $blob_response->is_success;

    my $blob_content = decode_json($blob_response->decoded_content);
    $payload->{record}->{embed} = {
        '$type'    => 'app.bsky.embed.images',
        images => [
            {
                alt => $img_alt,
                image => $blob_content->{blob},
            },
        ],
    };
  }

lib/App/SpreadRevolutionaryDate/BlueskyLite.pm  view on Meta::CPAN

  if ($reply) {
      $payload->{record}->{reply} = $reply;
  }

  my $json = encode_json($payload);
  my $req = HTTP::Request->new('POST', 'https://bsky.social/xrpc/com.atproto.repo.createRecord');
  $req->header('Content-Type' => 'application/json');
  $req->content($json);
  my $response = $self->{ua}->request($req);
  if ($response->is_success) {
      return decode_json($response->decoded_content);
  } else {
      return $response;
  }
}


# A module must return a true value. Traditionally, a module returns 1.
# But this module is a revolutionary one, so it discards all old traditions.
# Idea borrowed from Jean Forget's DateTime::Calendar::FrenchRevolutionary.
"Quand le gouvernement viole les droits du peuple,



( run in 0.826 second using v1.01-cache-2.11-cpan-26ccb49234f )