Типа я (zilogic) wrote in changelog,
Типа я
zilogic
changelog

[livejournal] r22835: LJSUP-13403: Implement new ESN notificat...

Committer: amyshkin
LJSUP-13403: Implement new ESN notification "Somebody promote entry in my journal" for Journal Promo Service users
U   trunk/cgi-bin/LJ/Event.pm
U   trunk/cgi-bin/LJ/NotificationInbox.pm
Modified: trunk/cgi-bin/LJ/Event.pm
===================================================================
--- trunk/cgi-bin/LJ/Event.pm	2012-09-07 08:01:04 UTC (rev 22834)
+++ trunk/cgi-bin/LJ/Event.pm	2012-09-07 08:08:29 UTC (rev 22835)
@@ -87,11 +87,11 @@
 # my $event =
 #     LJ::Event->new_from_raw_params($example_etypeid, $u->id, $arg1, $arg2, $arg3, $arg4);
 sub new_from_raw_params {
-    my (undef, $etypeid, $journalid, $arg1, $arg2, $arg3, $arg4) = @_;
+    my (undef, $etypeid, $journalid, @args ) = @_;
 
     my $class   = LJ::Event->class($etypeid) or confess "Classname cannot be undefined/false";
     my $journal = LJ::load_userid($journalid);
-    my $evt     = LJ::Event->new($journal, $arg1, $arg2, $arg3, $arg4);
+    my $evt     = LJ::Event->new($journal, @args);
 
     # bless into correct class
     bless $evt, $class;
@@ -107,9 +107,10 @@
 # my ($etypeid, $journalid, $arg1, $arg2) = @$params;
 sub raw_params {
     my $self = shift;
-    use Data::Dumper;
+
     my $ju = $self->event_journal or
         Carp::confess("Event $self has no journal: " . Dumper($self));
+
     my @params = map { $_ || 0 } (
         $self->etypeid,
         $ju->id,
@@ -579,10 +580,12 @@
     my $zeromeans = $self->zero_journalid_subs_means;
 
     my @wildcards_from;
+
     if ($zeromeans eq 'friends') {
         # find friendofs, add to @wildcards_from
         @wildcards_from = LJ::get_friendofs($self->u);
-    } elsif ($zeromeans eq 'all') {
+    }
+    elsif ($zeromeans eq 'all') {
         $allmatch = 1;
     }
 
@@ -603,12 +606,14 @@
         ## TODO: check that LJ::get_cluster_master($cid) in other parts of code
         ## will return handle to 'active' db, not cached 'inactive' db handle
         my $udbh = '';
+
         if (not $LJ::DISABLED{'try_to_load_subscriptions_from_slave'}){
-            $udbh = eval { 
-                        require 'LJ/DBUtil.pm';
-                        LJ::DBUtil->get_inactive_db($cid); # connect to slave 
-                    };
+            $udbh = eval {
+                require 'LJ/DBUtil.pm';
+                LJ::DBUtil->get_inactive_db($cid); # connect to slave
+             };
         }
+
         $udbh ||= LJ::get_cluster_master($cid); # default (master) connect
 
         die "Can't connect to db" unless $udbh;
@@ -627,7 +632,9 @@
         my @args = ($self->etypeid);
         push @args, $self->u->id unless $allmatch;
         push @args, @extra_args;
+
         $sth->execute(@args);
+
         if ($sth->err) {
             warn "SQL: [$sql], args=[@args]\n";
             die $sth->errstr;

Modified: trunk/cgi-bin/LJ/NotificationInbox.pm
===================================================================
--- trunk/cgi-bin/LJ/NotificationInbox.pm	2012-09-07 08:01:04 UTC (rev 22834)
+++ trunk/cgi-bin/LJ/NotificationInbox.pm	2012-09-07 08:08:29 UTC (rev 22835)
@@ -375,6 +375,7 @@
     # if over the max, delete the oldest notification
     my $max = $u->get_cap('inbox_max');
     my $skip = $max - 1; # number to skip to get to max
+
     if ($max && $self->count >= $max) {
 
         # Get list of bookmarks and ignore them when checking inbox limits
@@ -426,11 +427,15 @@
             or die $u->errstr;
     }
 
-    # send notification
-    $self->__send_notify( { 'u'         => $u,
-                            'journal_u' => LJ::want_user($evt->arg2),
-                            'msgid'     => $evt->arg1,
-                            'etypeid'   => $evt->etypeid, });
+    if ( LJ::Event::UserMessageRecvd->etypeid == $evt->etypeid ) {
+        # send notification
+        $self->__send_notify({
+            'u'         => $u,
+            'journal_u' => LJ::want_user($evt->arg2),
+            'msgid'     => $evt->arg1,
+            'etypeid'   => $evt->etypeid,
+        });
+    }
 
     # invalidate memcache
     $self->expire_cache;
@@ -440,15 +445,11 @@
 
 sub __send_notify {
     my ($self, $data) = @_;
-    my $etypeid = $data->{'etypeid'};
+    my $msgid       = $data->{'msgid'};
+    my $u           = $data->{'u'};
+    my $journal_u   = $data->{'journal_u'};
 
-    if (LJ::Event::UserMessageRecvd->etypeid == $etypeid) {
-        my $msgid       = $data->{'msgid'};
-        my $u           = $data->{'u'};
-        my $journal_u   = $data->{'journal_u'};
-
-        LJ::Event::InboxUserMessageRecvd->new($u, $msgid, $journal_u)->fire;
-    }
+    LJ::Event::InboxUserMessageRecvd->new($u, $msgid, $journal_u)->fire;
 }
 
 # return true if item is bookmarked

Tags: amyshkin, livejournal, pm, zilogic
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