<commit_before>package ReseqTrack::WebsiteUpdater::Model::PubSubHubBub;
use namespace::autoclean;
use Moose;
use Mojo::UserAgent;
use XML::RSS::Parser;
use FileHandle;

has 'rss' => (is => 'rw', isa => 'Str', required=>1);

sub publish {
  my ($self) = @_;
  return 0 if ! -f $self->rss;

  my $parser = XML::RSS::Parser->new;;
  my $fh = FileHandle->new($self->rss);
  my $feed = $parser->parse_file($fh);

  my $hub_href =  $feed->query('/channel/atom:link[@rel="hub"]/@atom:href');
  return 0 if !$hub_href;
  my $rss_href =  $feed->query('/channel/atom:link[@rel="rel"]/@atom:href');
  return 0 if !hub_href;
  my $ua = Mojo::UserAgent->new()
  my $tx = $ua->post($hub_href, form => {'hub.mode' => 'publish', 'hub.url' => $rss_href});

  return 1 if $tx->success;
  die "pubsubhubbub publish unsuccessulf ".$tx->error->{code};

}




1;<commit_msg>more helpful error logging<commit_after>package ReseqTrack::WebsiteUpdater::Model::PubSubHubBub;
use namespace::autoclean;
use Moose;
use Mojo::UserAgent;
use XML::RSS::Parser;
use FileHandle;

has 'rss' => (is => 'rw', isa => 'Str', required=>1);

sub publish {
  my ($self) = @_;
  return 0 if ! -f $self->rss;

  my $parser = XML::RSS::Parser->new;;
  my $fh = FileHandle->new($self->rss);
  my $feed = $parser->parse_file($fh);

  my $hub_href =  $feed->query('/channel/atom:link[@rel="hub"]/@atom:href');
  return 0 if !$hub_href;
  my $rss_href =  $feed->query('/channel/atom:link[@rel="rel"]/@atom:href');
  return 0 if !hub_href;
  my $ua = Mojo::UserAgent->new()
  my $tx = $ua->post($hub_href, form => {'hub.mode' => 'publish', 'hub.url' => $rss_href});

  return 1 if $tx->success;
  die "pubsubhubbub publish unsuccessulf ".$tx->error->{code}.': '.$tx->res->content->body;

}




1;
{'fraction_non_alphanumeric': 0.21993127147766323, 'fraction_numerical': 0.006872852233676976, 'mean_word_length': 4.672077922077922, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7552701', 'n_tokens_mistral': 694, 'n_tokens_neox': 664, 'n_words': 147}