madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r22545: LJSUP-12902: Create notifications for re...

Committer: sbelyaev
LJSUP-12902: Create notifications for reposts
U   trunk/cgi-bin/LJ/Event/JournalNewRepost.pm
Modified: trunk/cgi-bin/LJ/Event/JournalNewRepost.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/JournalNewRepost.pm	2012-08-01 13:51:09 UTC (rev 22544)
+++ trunk/cgi-bin/LJ/Event/JournalNewRepost.pm	2012-08-01 15:10:30 UTC (rev 22545)
@@ -10,12 +10,15 @@
 use Class::Autouse qw(LJ::Entry);
 use base 'LJ::Event';
 
+use LJ::Event::JournalNewEntry;
+
 ############################################################################
 # constructor & property overrides
 #
 
 sub new {
     my ($class, $entry) = @_;
+
     croak 'Not an LJ::Entry' unless blessed $entry && $entry->isa("LJ::Entry");
     return $class->SUPER::new( $entry->poster, 
                                $entry->journalid, 
@@ -96,22 +99,20 @@
 
 sub matches_filter {
     my ($self, $subscr) = @_;
+ 
+    my $ditemid = $self->arg2;
+    my $evtju   = $self->event_journal;
+    return 0 unless $evtju && $ditemid; # TODO: throw error?
 
-    # does the entry actually exist?
-    return 0 unless $self->journalid && $self->real_ditemid; # TODO: throw error?
-
-    # construct the entry so we can determine visibility
-    my $entry = $self->entry;
+    my $entry = LJ::Entry->new($evtju, ditemid => $ditemid);
     return 0 unless $entry && $entry->valid; # TODO: throw error?
     return 0 unless $entry->visible_to($subscr->owner);
 
-    # journalid of 0 means 'all friends', so if the poster is
-    # a friend of the subscription owner, then they match
-    return 1 if ! $subscr->journalid && LJ::is_friend($subscr->owner, $self->poster);
+    # all posts by friends
+    return 1 if ! $subscr->journalid && LJ::is_friend($subscr->owner, $self->event_journal);
 
-    # otherwise we have a journalid, see if it's the specific
-    # journal that the subscription is watching
-    return LJ::u_equals($subscr->journal, $self->poster);
+    # a post on a specific journal
+    return LJ::u_equals( $subscr->journal, $evtju );
 }
 
 
@@ -377,8 +378,9 @@
 
     my @subs;
     foreach my $subsc (@entry_subs) {
-        my $row = { userid  => $subsc->{'userid'},
-                    ntypeid => $subsc->{'ntypeid'},
+        my $row = { userid      => $subsc->{'userid'},
+                    journalid   => $subsc->{'journalid'},
+                    ntypeid     => $subsc->{'ntypeid'},
                   };
 
         push @subs, LJ::Subscription->new_from_row($row);

Tags: livejournal, madeon, pm, sbelyaev
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