]> Sergey Matveev's repositories - public-inbox.git/commitdiff
Feed: <id> element must be a URI, oops :x
authorEric Wong <e@80x24.org>
Sun, 27 Apr 2014 05:04:02 +0000 (05:04 +0000)
committerEric Wong <e@80x24.org>
Sun, 27 Apr 2014 05:59:24 +0000 (05:59 +0000)
For each feed element, we'll just use the link since there's
currently no suitable URN.

lib/PublicInbox/Feed.pm
t/feed.t

index a8578e760fdf8cc002e8ad53d9a008879ee4bff0..2dc3940ff7e4fc3bd591f5501eb40f53792fb112 100644 (file)
@@ -36,7 +36,7 @@ sub generate {
                        href => $feed_opts->{atomurl} ||
                                "http://example.com/atom.xml",
                },
-               id => $addr || 'public-inbox@example.com',
+               id => 'mailto:' . ($addr || 'public-inbox@example.com'),
                updated => POSIX::strftime(DATEFMT, gmtime),
        );
 
@@ -278,13 +278,17 @@ sub add_to_feed {
        my $date = $mime->header('Date');
        $date = PublicInbox::Hval->new_oneline($date);
        $date = feed_date($date->raw) or return 0;
+       $add =~ tr!/!!d;
+       my $h = '[a-f0-9]';
+       my (@uuid5) = ($add =~ m!\A($h{8})($h{4})($h{4})($h{4})($h{12})!o);
+
        $feed->add_entry(
                author => { name => $name, email => $email },
                title => $subject,
                updated => $date,
                content => { type => "html", content => $content },
                link => $midurl . $href,
-               id => $add,
+               id => 'urn:uuid:' . join('-', @uuid5),
        );
        1;
 }
index a6bffdcd830a0e3c18a63d7a641b83f77af3b0b1..880716ccb4a3df9e1c0c6b6c30303542ca179894 100644 (file)
--- a/t/feed.t
+++ b/t/feed.t
@@ -58,7 +58,7 @@ EOF
                        my $p = XML::Feed->parse(\$feed);
                        is($p->format, "Atom", "parsed atom feed");
                        is(scalar $p->entries, 3, "parsed three entries");
-                       is($p->id, 'public-inbox@example.com',
+                       is($p->id, 'mailto:public-inbox@example.com',
                                "id is set to default");
                }
 
@@ -142,7 +142,8 @@ EOF
                SKIP: {
                        skip 'XML::Feed missing', 3 unless $have_xml_feed;
                        my $p = XML::Feed->parse(\$feed);
-                       is($p->id, 'a@example.com', "ID is set correctly");
+                       is($p->id, 'mailto:a@example.com',
+                               "ID is set correctly");
                        is($p->format, "Atom", "parsed atom feed");
                        is(scalar $p->entries, 3, "parsed three entries");
                }