madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r21597: LJSUP-11468: Push notifications Livejour...

Committer: sbelyaev
LJSUP-11468: Push notifications Livejournal server-side code refactoring
U   trunk/cgi-bin/LJ/NotificationInbox.pm
Modified: trunk/cgi-bin/LJ/NotificationInbox.pm
===================================================================
--- trunk/cgi-bin/LJ/NotificationInbox.pm	2012-03-29 14:30:04 UTC (rev 21596)
+++ trunk/cgi-bin/LJ/NotificationInbox.pm	2012-03-29 15:07:10 UTC (rev 21597)
@@ -6,7 +6,7 @@
 
 use strict;
 use Carp qw(croak);
-use Class::Autouse qw (LJ::NotificationItem LJ::Event LJ::NotificationArchive);
+use Class::Autouse qw (LJ::NotificationItem LJ::Event LJ::NotificationArchive LJ::Event::InboxUserMessageRecvd);
 
 # constructor takes a $u
 sub new {
@@ -426,12 +426,31 @@
             or die $u->errstr;
     }
 
+    # 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;
 
     return LJ::NotificationItem->new($u, $qid);
 }
 
+sub __send_notify {
+    my ($self, $data) = @_;
+    my $etypeid = $data->{'etypeid'};
+
+    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;
+    }
+}
+
 # return true if item is bookmarked
 sub is_bookmark {
     my ($self, $qid) = @_;

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