- my $content = msg_content($mime);
- defined($content) or return 0;
-
- my $midurl = $feed_opts->{midurl} || "http://example.com/mid/%s.html";
- my $mid = utf8_header($mime, "Message-ID") or return 0;
- $mid =~ s/\A<//;
- $mid =~ s/>\z//;
-
- my $subject = utf8_header($mime, "Subject") || "";
- defined($subject) && length($subject) or return 0;
-
- my $from = utf8_header($mime, "From") or return 0;
-
- my @from = Email::Address->parse($from);
- my $name = $from[0]->name;
- defined $name or $name = "";
- my $email = $from[0]->address;
- defined $email or $email = "";
-
- my $url = sprintf($midurl, uri_escape($mid));
- my $date = utf8_header($mime, "Date");
- $date or return 0;
- $date = feed_date($date) or return 0;
- $feed->add_entry(
- author => { name => $name, email => $email },
- title => $subject,
- updated => $date,
- content => { type => "html", content => $content },
- link => $url,
- id => $add,
- );
- 1;
-}
-
-# returns a plain-text message body without quoted text
-# returns undef if there was nothing
-sub msg_content {
- my ($mime) = @_;
- my $rv;
-
- # scan through all parts, looking for displayable text
- $mime->walk_parts(sub {
- return if $rv;
- my ($part) = @_;
- return if $part->subparts; # walk_parts already recurses
- my $ct = $part->content_type || 'text/plain';
- return if $ct !~ m!\btext/[a-z0-9\+\._-]+\b!i;
- my @body;
- my $killed_wrote; # omit "So-and-so wrote:" line
-
- # no quoted text in Atom feed summary
- # $part->body should already be decoded for us (no QP)
-
- my $state = 0; # 0: beginning, 1: keep, 2: quoted
- foreach my $l (split(/\r?\n/, $part->body)) {
- if ($state == 0) {
- # drop leading blank lines
- next if $l =~ /\A\s*\z/;
-
- $state = ($l =~ /\A>/) ? 2 : 1; # fall-through
- }
- if ($state == 2) { # quoted text, drop it
- if ($l !~ /\A>/) {
- push @body, "<quoted text snipped>";
- if ($l =~ /\S/) {
- push @body, $l;
- }
- $state = 1;
- }
+ # get recent messages
+ # we could use git log -z, but, we already know ssoma will not
+ # leave us with filenames with spaces in them..
+ my $log = $ibx->git->popen(qw/log
+ --no-notes --no-color --raw -r
+ --no-abbrev --abbrev-commit/,
+ "--format=%H", $range);
+ my %deleted; # only an optimization at this point
+ my $last;
+ my $last_commit;
+ local $/ = "\n";
+ my @oids;
+ while (defined(my $line = <$log>)) {
+ if ($line =~ /$addmsg/o) {
+ my $add = $1;
+ next if $deleted{$add}; # optimization-only
+ push @oids, $add;
+ if (scalar(@oids) >= $max) {
+ $last = 1;
+ last;