madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r23207: LJSUP-14052: Web Notifications for LJ pr...

Committer: sbelyaev
LJSUP-14052: Web Notifications for LJ prototype [internal]
U   trunk/cgi-bin/LJ/Event/UserMessageRecvd.pm
Modified: trunk/cgi-bin/LJ/Event/UserMessageRecvd.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/UserMessageRecvd.pm	2012-10-26 14:07:25 UTC (rev 23206)
+++ trunk/cgi-bin/LJ/Event/UserMessageRecvd.pm	2012-10-29 08:26:30 UTC (rev 23207)
@@ -16,6 +16,32 @@
 
 sub is_common { 1 }
 
+sub as_web_notification {
+    my ($self, $u) = @_;
+
+    my $msg     = $self->load_message;
+    my $other_u = $msg->other_u;
+    my $msgid   = $msg->msgid;
+    my $qid     = $msg->qid;
+
+    my $pic;
+    if ($msg->userpic) {
+        $pic = LJ::Userpic->new_from_keyword($other_u, $msg->userpic);
+    } else {
+        $pic = $other_u->userpic;
+    }
+
+    my $inbox = "$LJ::SITEROOT/inbox/?view=usermsg_recvd&selected=" . $msgid . "#all_Row_$qid";
+    my $pic_url = $pic ? $pic->url : 
+                         "$LJ::STATPREFIX/horizon/nouserpic.png?v=2621";
+
+    return {  title   => $msg->subject,
+              content => $msg->body,
+              tag     => $other_u->user,
+              icon    => $pic_url,
+              url     => $inbox };
+}
+
 sub as_email_subject {
     my ($self, $u) = @_;
 

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