kareila: (Default)
kareila ([personal profile] kareila) wrote in [site community profile] changelog2009-10-28 03:27 am

[dw-free] Wrong username when trying to track journals from your readpage with the ajax-y track butt

[commit: http://hg.dwscoalition.org/dw-free/rev/8b4cb56c5ca9]

http://bugs.dwscoalition.org/show_bug.cgi?id=1487

Make AJAX tracker on reading page aware of which journal is being tracked.

Patch by [personal profile] wyntarvox.

Files modified:
  • cgi-bin/LJ/S2.pm
  • htdocs/js/esn.js
--------------------------------------------------------------------------------
diff -r fbc88a77756e -r 8b4cb56c5ca9 cgi-bin/LJ/S2.pm
--- a/cgi-bin/LJ/S2.pm	Tue Oct 27 15:43:01 2009 -0500
+++ b/cgi-bin/LJ/S2.pm	Tue Oct 27 22:27:40 2009 -0500
@@ -3542,6 +3542,7 @@ sub _Entry__get_link
     my $remote = LJ::get_remote();
     my $null_link = { '_type' => 'Link', '_isnull' => 1 };
     my $journalu = LJ::load_user($journal);
+    my $esnjournal = $journalu->is_community ? $journal : $poster;
 
     if ($key eq "edit_entry") {
         return $null_link unless $remote && ($remote->{'user'} eq $journal ||
@@ -3636,7 +3637,8 @@ sub _Entry__get_link
                             'lj_newentry_token'   => $newentry_auth_token,
                             'lj_newentry_subid'   => $newentry_sub ? $newentry_sub->id : 0,
                             'class'               => 'TrackButton',
-                            'js_swapname'         => $ctx->[S2::PROPS]->{text_unwatch_comments} );
+                            'js_swapname'         => $ctx->[S2::PROPS]->{text_unwatch_comments},
+                            'journal'              => $esnjournal );
     }
     if ($key eq "unwatch_comments") {
         return $null_link unless LJ::is_enabled('esn');
@@ -3667,7 +3669,8 @@ sub _Entry__get_link
                             'lj_newentry_token'   => $newentry_auth_token,
                             'lj_newentry_subid'   => $newentry_sub ? $newentry_sub->id : 0,
                             'class'               => 'TrackButton',
-                            'js_swapname'         => $ctx->[S2::PROPS]->{text_watch_comments} );
+                            'js_swapname'         => $ctx->[S2::PROPS]->{text_watch_comments},
+                            'journal'             => $esnjournal );
     }
 }
 
diff -r fbc88a77756e -r 8b4cb56c5ca9 htdocs/js/esn.js
--- a/htdocs/js/esn.js	Tue Oct 27 15:43:01 2009 -0500
+++ b/htdocs/js/esn.js	Tue Oct 27 22:27:40 2009 -0500
@@ -156,6 +156,8 @@ ESN.trackBtnClickHandler = function (evt
         
         if ( typeof LJ_cmtinfo !== 'undefined' ) {
             journal = LJ_cmtinfo["journal"];
+        } else if ( typeof trackBtn.getAttribute( "journal" ) != "undefined" ) {
+            journal = trackBtn.getAttribute( "journal" );
         } else if ( typeof Site !== 'undefined' ) {
             journal = Site.currentJournal;
         }
--------------------------------------------------------------------------------