madeon (madeon) wrote in changelog,
madeon
madeon
changelog

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

Committer: sbelyaev
LJSUP-11468: Push notifications Livejournal server-side code refactoring
U   trunk/cgi-bin/LJ/Event/Befriended.pm
U   trunk/cgi-bin/LJ/Event/Birthday.pm
U   trunk/cgi-bin/LJ/Event/CommunityJoinRequest.pm
U   trunk/cgi-bin/LJ/Event/Defriended.pm
U   trunk/cgi-bin/LJ/Event/JournalNewComment.pm
U   trunk/cgi-bin/LJ/Event/JournalNewEntry.pm
U   trunk/cgi-bin/LJ/Event/NewUserpic.pm
U   trunk/cgi-bin/LJ/Event/OfficialPost.pm
U   trunk/cgi-bin/LJ/Event/PollVote.pm
U   trunk/cgi-bin/LJ/Event/UserExpunged.pm
U   trunk/cgi-bin/LJ/Event/UserMessageRecvd.pm
Modified: trunk/cgi-bin/LJ/Event/Befriended.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/Befriended.pm	2012-03-20 13:45:10 UTC (rev 21472)
+++ trunk/cgi-bin/LJ/Event/Befriended.pm	2012-03-20 13:49:22 UTC (rev 21473)
@@ -195,7 +195,9 @@
 
 sub as_push_payload {
     my $self = shift;
-    return '"t":7,"j":"'.$self->friend->user.'"';
+    return { 't' => 7,
+             'j' => $self->friend->user,   
+           };
 }
 
 1;

Modified: trunk/cgi-bin/LJ/Event/Birthday.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/Birthday.pm	2012-03-20 13:45:10 UTC (rev 21472)
+++ trunk/cgi-bin/LJ/Event/Birthday.pm	2012-03-20 13:49:22 UTC (rev 21473)
@@ -219,7 +219,10 @@
 
 sub as_push_payload {
     my $self = shift;
-    return '"t":17,"j":"'.$self->bdayuser->user().'","b":"'. $self->next_bday().'"';
+    return { 't' => 17,
+             'j' => $self->bdayuser->user(),
+             'b' => $self->next_bday(),
+           };
 }
 
 1;

Modified: trunk/cgi-bin/LJ/Event/CommunityJoinRequest.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/CommunityJoinRequest.pm	2012-03-20 13:45:10 UTC (rev 21472)
+++ trunk/cgi-bin/LJ/Event/CommunityJoinRequest.pm	2012-03-20 13:49:22 UTC (rev 21473)
@@ -177,7 +177,10 @@
 
 sub as_push_payload {
     my $self = shift;
-    return '"t":15,"j":"'.$self->comm->user().'","u":"'.$self->requestor->user().'"';
+    return { 't' => 15,
+             'j' => $self->comm->user(),
+             'u' => $self->requestor->user(),
+           };
 }
 
 

Modified: trunk/cgi-bin/LJ/Event/Defriended.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/Defriended.pm	2012-03-20 13:45:10 UTC (rev 21472)
+++ trunk/cgi-bin/LJ/Event/Defriended.pm	2012-03-20 13:49:22 UTC (rev 21473)
@@ -177,7 +177,10 @@
 
 sub as_push_payload {
     my $self = shift;
-    return '"t":8,"j":"'.$self->friend->user.'"';
+
+    return { 't' => 8,
+             'j' => $self->friend->user,
+           };
 }
 
 

Modified: trunk/cgi-bin/LJ/Event/JournalNewComment.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/JournalNewComment.pm	2012-03-20 13:45:10 UTC (rev 21472)
+++ trunk/cgi-bin/LJ/Event/JournalNewComment.pm	2012-03-20 13:49:22 UTC (rev 21473)
@@ -952,26 +952,38 @@
     my $entry = $self->comment->entry;
     my $parent = $self->comment->parent;
 
+    my $payload = { 'p' => $entry->ditemid,
+                    'c' => $self->comment->dtalkid,
+                  };
 
+
     unless($u->equals($self->event_journal)) {
 
         if($self->event_journal->journaltype eq 'C') {
-
             if($parent) {
-                return '"t":26, "j":"'.$self->event_journal->user.'",'.
-                    '"p":'.$entry->ditemid.', "r":'.$self->comment->parent->dtalkid.', "c":'.$self->comment->dtalkid;
+                $payload->{'t'} = 26;
+                $payload->{'j'} = $self->event_journal->user;
+                $payload->{'r'} = $self->comment->parent->dtalkid;
+                return $payload;
             }
         } else {
-            return '"t":25,"j":"'.$self->event_journal->user.'","p":'.$entry->ditemid.',"c":'.$self->comment->dtalkid;
+            $payload->{'t'} = 25;
+            $payload->{'j'} = $self->event_journal->user;
+            return $payload;
         }
 
     } else {
+        $payload->{'j'} = $self->event_journal->user;
+
         if($parent && LJ::u_equals($parent->poster, $u)) {
-            return '"t":5,"j":"'.$self->event_journal->user.'","p":'.$entry->ditemid.',"c":'.$self->comment->dtalkid;
+            $payload->{'t'} = 5;
+            return $payload;
         } elsif($self->event_journal->journaltype eq 'C') {
-            return '"t":4,"j":"'.$self->event_journal->user.'","p":'.$entry->ditemid.',"c":'.$self->comment->dtalkid;
+            $payload->{'t'} = 4;
+            return $payload;
         } else {
-            return '"t":3,"j":"'.$self->event_journal->user.'","p":'.$entry->ditemid.',"c":'.$self->comment->dtalkid; 
+            $payload->{'t'} = 3;
+            return $payload;
         }
     }
 }  

Modified: trunk/cgi-bin/LJ/Event/JournalNewEntry.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/JournalNewEntry.pm	2012-03-20 13:45:10 UTC (rev 21472)
+++ trunk/cgi-bin/LJ/Event/JournalNewEntry.pm	2012-03-20 13:49:22 UTC (rev 21473)
@@ -439,7 +439,10 @@
 
 sub as_push_payload {
     my ($self,$u) = @_;
-    return '"t":19,"j":"'.$u->user.'","p":'.$self->entry->ditemid;
+    return { 't' => 19,
+             'j' => $u->user,
+             'p' => $self->entry->ditemid,
+           };
 }
 
 1;

Modified: trunk/cgi-bin/LJ/Event/NewUserpic.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/NewUserpic.pm	2012-03-20 13:45:10 UTC (rev 21472)
+++ trunk/cgi-bin/LJ/Event/NewUserpic.pm	2012-03-20 13:49:22 UTC (rev 21473)
@@ -168,7 +168,9 @@
 
 sub as_push_payload {
     my $self = shift;
-    return '"t":16,"j":"'.$self->event_journal->user().'"';
+    return { 't' => 16,
+             'j' => $self->event_journal->user(),
+           };
 }
 
 

Modified: trunk/cgi-bin/LJ/Event/OfficialPost.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/OfficialPost.pm	2012-03-20 13:45:10 UTC (rev 21472)
+++ trunk/cgi-bin/LJ/Event/OfficialPost.pm	2012-03-20 13:49:22 UTC (rev 21473)
@@ -192,7 +192,9 @@
 
 sub as_push_payload {
     my $self = shift;
-    return '"t":1,"p":'.$self->arg1;
+    return { 't' => 1,
+             'p' => $self->arg1,
+           };
 }
 
 1;

Modified: trunk/cgi-bin/LJ/Event/PollVote.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/PollVote.pm	2012-03-20 13:45:10 UTC (rev 21472)
+++ trunk/cgi-bin/LJ/Event/PollVote.pm	2012-03-20 13:49:22 UTC (rev 21473)
@@ -199,8 +199,12 @@
 
 sub as_push_payload {
     my $self = shift;
-
-    return '"t":6,"j":"'.$self->entry->poster->user.'","p":'.$self->entry->ditemid.',"pl":'.$self->arg2;
+    
+    return { 't'  => 6,
+             'j'  => $self->entry->poster->user,
+             'p'  => $self->entry->ditemid,
+             'pl' => $self->arg2,
+           };
 }
 
 1;

Modified: trunk/cgi-bin/LJ/Event/UserExpunged.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/UserExpunged.pm	2012-03-20 13:45:10 UTC (rev 21472)
+++ trunk/cgi-bin/LJ/Event/UserExpunged.pm	2012-03-20 13:49:22 UTC (rev 21473)
@@ -113,7 +113,9 @@
 
 sub as_push_payload {
     my $self = shift;
-    return  '"t": 24, "j": "'.$self->event_journal->user.'"';
+    return { 't' => 24,
+             'j' => $self->event_journal->user,
+           };
 }
 
 

Modified: trunk/cgi-bin/LJ/Event/UserMessageRecvd.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/UserMessageRecvd.pm	2012-03-20 13:45:10 UTC (rev 21472)
+++ trunk/cgi-bin/LJ/Event/UserMessageRecvd.pm	2012-03-20 13:49:22 UTC (rev 21473)
@@ -216,10 +216,9 @@
 sub as_push_payload {
     my $self = shift; 
     my $os = shift;
-    if ($os eq 'wp7') {
-        return "?m=". $self->arg1;
-    }
-    return '"t":9,"m":'.$self->arg1;
+
+    return { 'm' => int($self->arg1),
+             't' => 9,};
 }
 
 sub subscription_as_html {

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