holyandrew (holyandrew) wrote in changelog,
holyandrew
holyandrew
changelog

[ljcom] r12654: LJINT-482: Comments for side projects (l...

Committer: akanashin
LJINT-482: Comments for side projects (letidor) - improvements
U   trunk/bin/worker/partner-sites
U   trunk/cgi-bin/LJ/Hooks/PartnerSites.pm
U   trunk/cgi-bin/LJ/PartnerSite.pm
Modified: trunk/bin/worker/partner-sites
===================================================================
--- trunk/bin/worker/partner-sites	2012-09-17 09:19:33 UTC (rev 12653)
+++ trunk/bin/worker/partner-sites	2012-09-17 10:36:21 UTC (rev 12654)
@@ -46,7 +46,9 @@
         return $job->completed;
     }
 
-    my $url = $partner->sync_comments_url_from_entry($entry);
+    my $posterid = $arg->{'posterid'};
+
+    my $url = $partner->sync_comments_url_from_entry($entry, $posterid);
     my $ua = LJ::get_useragent( 'role' => 'partners-sync-comments-count' );
 
     my $res = $ua->get($url);

Modified: trunk/cgi-bin/LJ/Hooks/PartnerSites.pm
===================================================================
--- trunk/cgi-bin/LJ/Hooks/PartnerSites.pm	2012-09-17 09:19:33 UTC (rev 12653)
+++ trunk/cgi-bin/LJ/Hooks/PartnerSites.pm	2012-09-17 10:36:21 UTC (rev 12654)
@@ -5,7 +5,7 @@
 use LJ::PartnerSite;
 
 LJ::register_hook( 'replycount_change' => sub {
-    my ( $entry ) = @_;
+    my ( $entry, $posterid ) = @_;
 
     my $journal = $entry->journal;
 
@@ -20,6 +20,7 @@
         'arg'      => {
             'journalid' => $journal->userid,
             'jitemid'   => $entry->jitemid,
+            'posterid'  => $posterid,
         },
     );
     $sclient->insert($job);

Modified: trunk/cgi-bin/LJ/PartnerSite.pm
===================================================================
--- trunk/cgi-bin/LJ/PartnerSite.pm	2012-09-17 09:19:33 UTC (rev 12653)
+++ trunk/cgi-bin/LJ/PartnerSite.pm	2012-09-17 10:36:21 UTC (rev 12654)
@@ -374,6 +374,10 @@
         $entry = LJ::Entry->new( $self->journal,
                                  'jitemid' => $row->{'jitemid'} );
 
+    } elsif (my $ditemid = $opts->{'ditemid'}) {
+        $entry = LJ::Entry->new( $self->journal,
+                                 'ditemid' => $ditemid );
+
     } elsif ( $opts->{'nocreate'} ) {
         # database didn't find an entry for us, and we don't wish to create
         # one, so let's return undef, but first, memcache that there
@@ -1024,7 +1028,7 @@
 =cut
 
 sub sync_comments_url_from_entry {
-    my ( $self, $entry ) = @_;
+    my ( $self, $entry, $posterid ) = @_;
 
     my $docid   = $self->docid_from_entry($entry);
     $docid    ||= '';
@@ -1036,6 +1040,11 @@
     $url =~ s/\Q[[docid]]\E/$docid/g;
     $url =~ s/\Q[[dochash]]\E/$dochash/g;
     $url =~ s/\Q[[count]]\E/$count/g;
+    
+    if ($posterid && (my $poster = LJ::load_userid($posterid))) {
+        my $poster_name = $poster->user;
+        $url =~ s/\Q[[poster]]\E/$poster_name/g;
+    }
 
     return $url;
 }

Tags: akanashin, holyandrew, ljcom, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments