Committer: henrylyne
Add hubbub pinging on edit.U trunk/cgi-bin/ljfeed.pl U trunk/cgi-bin/ljprotocol.pl
Modified: trunk/cgi-bin/ljfeed.pl =================================================================== --- trunk/cgi-bin/ljfeed.pl 2009-08-25 14:28:52 UTC (rev 15635) +++ trunk/cgi-bin/ljfeed.pl 2009-08-25 16:38:36 UTC (rev 15636) @@ -1069,5 +1069,31 @@ return $ret; } +sub generate_hubbub_jobs { + my $u = shift; + my $joblist = shift; + return if $LJ::DISABLED{'hubbub'}; + + foreach my $hub (@LJ::HUBBUB_HUBS) { + my $make_hubbub_job = sub { + my $type = shift; + + my $topic_url = $u->journal_base . "/data/$type"; + return TheSchwartz::Job->new( + funcname => 'TheSchwartz::Worker::PubSubHubbubPublish', + arg => { + hub => $hub, + topic_url => $topic_url, + }, + coalesce => $hub, + ); + }; + + push @$joblist, $make_hubbub_job->("rss"); + push @$joblist, $make_hubbub_job->("atom"); + } +} + + 1; Modified: trunk/cgi-bin/ljprotocol.pl =================================================================== --- trunk/cgi-bin/ljprotocol.pl 2009-08-25 14:28:52 UTC (rev 15635) +++ trunk/cgi-bin/ljprotocol.pl 2009-08-25 16:38:36 UTC (rev 15636) @@ -1561,27 +1561,8 @@ push @jobs, LJ::EventLogRecord::NewEntry->new($entry)->fire_job; # PubSubHubbub Support - unless ($LJ::DISABLED{'hubbub'}) { - foreach my $hub (@LJ::HUBBUB_HUBS) { - my $make_hubbub_job = sub { - my $type = shift; + LJ::Feed::generate_hubbub_jobs($uowner, \@jobs); - my $topic_url = $uowner->journal_base . "/data/$type"; - return TheSchwartz::Job->new( - funcname => 'TheSchwartz::Worker::PubSubHubbubPublish', - arg => { - hub => $hub, - topic_url => $topic_url, - }, - coalesce => $hub, - ); - }; - - push @jobs, $make_hubbub_job->("rss"); - push @jobs, $make_hubbub_job->("atom"); - } - } - my $sclient = LJ::theschwartz(); if ($sclient && @jobs) { my @handles = $sclient->insert_jobs(@jobs); @@ -1957,8 +1938,18 @@ my $entry = LJ::Entry->new($ownerid, jitemid => $itemid); LJ::EventLogRecord::EditEntry->new($entry)->fire; - LJ::run_hooks("editpost", $entry); + my @jobs; # jobs to insert into TheSchwartz + LJ::run_hooks("editpost", $entry, \@jobs); + # PubSubHubbub Support + LJ::Feed::generate_hubbub_jobs($uowner, \@jobs); + + my $sclient = LJ::theschwartz(); + if ($sclient && @jobs) { + my @handles = $sclient->insert_jobs(@jobs); + # TODO: error on failure? depends on the job I suppose? property of the job? + } + return $res; }