Committer: aurbanowich
LJSUP-7874 SMS notification - new features+statistics
U trunk/cgi-bin/LJ/Comment.pm U trunk/cgi-bin/LJ/Event/Befriended.pm U trunk/cgi-bin/LJ/Event/CommentReply.pm U trunk/cgi-bin/LJ/Event/Defriended.pm U trunk/cgi-bin/LJ/Event/InvitedFriendJoins.pm U trunk/cgi-bin/LJ/Event/JournalNewComment.pm U trunk/cgi-bin/LJ/Event/JournalNewEntry.pm U trunk/cgi-bin/LJ/Event/OfficialPost.pm U trunk/cgi-bin/LJ/Event/UserNewEntry.pm U trunk/cgi-bin/LJ/Event.pm
Modified: trunk/cgi-bin/LJ/Comment.pm =================================================================== --- trunk/cgi-bin/LJ/Comment.pm 2011-03-03 04:56:54 UTC (rev 18448) +++ trunk/cgi-bin/LJ/Comment.pm 2011-03-03 05:10:07 UTC (rev 18449) @@ -212,13 +212,13 @@ } sub url { - my $self = shift; + my ($self, $extra) = @_; my $dtalkid = $self->dtalkid; my $entry = $self->entry; my $url = $entry->url; - return "$url?thread=$dtalkid#t$dtalkid"; + return "$url?thread=$dtalkid$extra#t$dtalkid"; } sub reply_url { Modified: trunk/cgi-bin/LJ/Event/Befriended.pm =================================================================== --- trunk/cgi-bin/LJ/Event/Befriended.pm 2011-03-03 04:56:54 UTC (rev 18448) +++ trunk/cgi-bin/LJ/Event/Befriended.pm 2011-03-03 05:10:07 UTC (rev 18449) @@ -125,10 +125,14 @@ } sub as_sms { - my ($self, $u) = @_; + my ($self, $u, $opt) = @_; my $lang = $u->prop('browselang') || $LJ::DEFAULT_LANG; - my $tinyurl = LJ::API::BitLy->shorten( "http://m.livejournal.com/read/user/".$self->friend->user ); + my $tinyurl = "http://m.livejournal.com/read/user/" + . $self->friend->user; + my $mparms = $opt->{mobile_url_extra_params}; + $tinyurl .= '?' . join('&', map {$_ . '=' . $mparms->{$_}} keys %$mparms) if $mparms; + $tinyurl = LJ::API::BitLy->shorten($tinyurl); undef $tinyurl if $tinyurl =~ /^500/; # [[friend]] has added you to their friends list. Reply with ADD [[friend]] to add them [[disclaimer]] Modified: trunk/cgi-bin/LJ/Event/CommentReply.pm =================================================================== --- trunk/cgi-bin/LJ/Event/CommentReply.pm 2011-03-03 04:56:54 UTC (rev 18448) +++ trunk/cgi-bin/LJ/Event/CommentReply.pm 2011-03-03 05:10:07 UTC (rev 18449) @@ -15,7 +15,7 @@ sub is_tracking { 0 } sub as_sms { - my ($self, $u) = @_; + my ($self, $u, $opt) = @_; my $user = $self->comment->poster ? $self->comment->poster->display_username : '(Anonymous user)'; my $edited = $self->comment->is_edited; @@ -40,8 +40,12 @@ } } my $msg = LJ::Lang::get_text($lang, $ml_key, undef, { user => $user } ); - my $tinyurl = LJ::API::BitLy->shorten($self->comment->url); - return undef if $tinyurl =~ /^500/; + my $mparms = $opt->{mobile_url_extra_params}; + my $tinyurl = $mparms?$self->comment->url( '&' . join('&', map {$_ . '=' . $mparms->{$_}} keys %$mparms)) + : $self->comment->url; + $tinyurl = LJ::API::BitLy->shorten($tinyurl); + undef $tinyurl if $tinyurl =~ /^500/; + return $msg . " " . $tinyurl; } Modified: trunk/cgi-bin/LJ/Event/Defriended.pm =================================================================== --- trunk/cgi-bin/LJ/Event/Defriended.pm 2011-03-03 04:56:54 UTC (rev 18448) +++ trunk/cgi-bin/LJ/Event/Defriended.pm 2011-03-03 05:10:07 UTC (rev 18449) @@ -108,12 +108,15 @@ } sub as_string { - my ($self, $u) = @_; + my ($self, $u, $opt) = @_; my $lang = ($u && $u->prop('browselang')) || $LJ::DEFAULT_LANG; - my $tinyurl = LJ::API::BitLy->shorten( "http://m.livejournal.com/read/user/".$self->friend->{user} ); + my $tinyurl = "http://m.livejournal.com/read/user/".$self->friend->{user}; + my $mparms = $opt->{mobile_url_extra_params}; + $tinyurl .= '?' . join('&', map {$_ . '=' . $mparms->{$_}} keys %$mparms) if $mparms; + $tinyurl = LJ::API::BitLy->shorten($tinyurl); undef $tinyurl if $tinyurl =~ /^500/; - + # [[friend]] has removed you from their Friends list. return LJ::Lang::get_text($lang, 'notification.sms.defriended', undef, { friend => $self->friend->{user}, Modified: trunk/cgi-bin/LJ/Event/InvitedFriendJoins.pm =================================================================== --- trunk/cgi-bin/LJ/Event/InvitedFriendJoins.pm 2011-03-03 04:56:54 UTC (rev 18448) +++ trunk/cgi-bin/LJ/Event/InvitedFriendJoins.pm 2011-03-03 05:10:07 UTC (rev 18449) @@ -101,12 +101,15 @@ } sub as_string { - my ($self, $u) = @_; + my ($self, $u, $opt) = @_; my $lang = ($u && $u->prop('browselang')) || $LJ::DEFAULT_LANG; my $tinyurl; if( $self->friend->user ){ - $tinyurl = LJ::API::BitLy->shorten( "http://m.livejournal.com/read/user/".$self->friend->user ); + $tinyurl = "http://m.livejournal.com/read/user/".$self->friend->user; + my $mparms = $opt->{mobile_url_extra_params}; + $tinyurl .= '?' . join('&', map {$_ . '=' . $mparms->{$_}} keys %$mparms) if $mparms; + $tinyurl = LJ::API::BitLy->shorten($tinyurl); undef $tinyurl if $tinyurl =~ /^500/; } Modified: trunk/cgi-bin/LJ/Event/JournalNewComment.pm =================================================================== --- trunk/cgi-bin/LJ/Event/JournalNewComment.pm 2011-03-03 04:56:54 UTC (rev 18448) +++ trunk/cgi-bin/LJ/Event/JournalNewComment.pm 2011-03-03 05:10:07 UTC (rev 18449) @@ -218,7 +218,7 @@ } sub as_sms { - my ($self, $u) = @_; + my ($self, $u, $opt) = @_; my $user = $self->comment->poster ? $self->comment->poster->display_username : '(Anonymous user)'; my $edited = $self->comment->is_edited; @@ -270,9 +270,12 @@ my $msg = LJ::Lang::get_text($lang, $ml_key, undef, $ml_params); #/read/user/%username%/%post_ID%/comments/%comment_ID%#comments - my $url = "http://m.livejournal.com/read/user/".$self->event_journal->user."/".$entry->ditemid."/comments/".$self->comment->dtalkid."#comments"; - my $tinyurl = LJ::API::BitLy->shorten($url); - return undef if $tinyurl =~ /^500/; + my $tinyurl = "http://m.livejournal.com/read/user/".$self->event_journal->user."/".$entry->ditemid."/comments/".$self->comment->dtalkid; + my $mparms = $opt->{mobile_url_extra_params}; + $tinyurl .= '?' . join('&', map {$_ . '=' . $mparms->{$_}} keys %$mparms) if $mparms; + $tinyurl .= "#comments"; + $tinyurl = LJ::API::BitLy->shorten($tinyurl); + undef $tinyurl if $tinyurl =~ /^500/; return $msg . " " . $tinyurl; } Modified: trunk/cgi-bin/LJ/Event/JournalNewEntry.pm =================================================================== --- trunk/cgi-bin/LJ/Event/JournalNewEntry.pm 2011-03-03 04:56:54 UTC (rev 18448) +++ trunk/cgi-bin/LJ/Event/JournalNewEntry.pm 2011-03-03 05:10:07 UTC (rev 18449) @@ -78,14 +78,17 @@ } sub as_sms { - my ($self, $u) = @_; + my ($self, $u, $opt) = @_; my $lang = ($u && $u->prop('browselang')) || $LJ::DEFAULT_LANG; my $tinyurl; - $tinyurl = LJ::API::BitLy->shorten( "http://m.livejournal.com/read/user/" - . $self->entry->journal->user . '/' . $self->entry->ditemid . '/' ); + $tinyurl = "http://m.livejournal.com/read/user/" + . $self->entry->journal->user . '/' . $self->entry->ditemid . '/'; + my $mparms = $opt->{mobile_url_extra_params}; + $tinyurl .= '?' . join('&', map {$_ . '=' . $mparms->{$_}} keys %$mparms) if $mparms; + $tinyurl = LJ::API::BitLy->shorten($tinyurl); undef $tinyurl if $tinyurl =~ /^500/; - + my $mlstrng = $self->entry->journal->is_comm ? 'notification.sms.journalnewentry_comm' : 'notification.sms.journalnewentry'; # [[poster]] has posted with a new entry. To view, send READ [[journal]] to read it. [[disclaimer]] # [[poster]] has posted with a new entry in [[journal]]. To view, send READ [[journal]] to read it. [[disclaimer]] Modified: trunk/cgi-bin/LJ/Event/OfficialPost.pm =================================================================== --- trunk/cgi-bin/LJ/Event/OfficialPost.pm 2011-03-03 04:56:54 UTC (rev 18448) +++ trunk/cgi-bin/LJ/Event/OfficialPost.pm 2011-03-03 05:10:07 UTC (rev 18449) @@ -124,14 +124,18 @@ } sub as_sms { - my ($self, $u) = @_; + my ($self, $u, $opt) = @_; + my $lang = ($u && $u->prop('browselang')) || $LJ::DEFAULT_LANG; my $entry = $self->entry or return "(Invalid entry)"; - my $tinyurl = LJ::API::BitLy->shorten( 'http://m.livejournal.com/read/user/' - . $entry->journal->user . '/' . $entry->ditemid . '/' ); + my $tinyurl = 'http://m.livejournal.com/read/user/' + . $entry->journal->user . '/' . $entry->ditemid . '/'; + my $mparms = $opt->{mobile_url_extra_params}; + $tinyurl .= '?' . join('&', map {$_ . '=' . $mparms->{$_}} keys %$mparms) if $mparms; + $tinyurl = LJ::API::BitLy->shorten($tinyurl); undef $tinyurl if $tinyurl =~ /^500/; - + # There is a new [[abbrev]] announcement in [[journal]]. Reply with READ [[journal]] to read it. [[disclaimer]] return LJ::Lang::get_text($lang, 'notification.sms.officialpost', undef, { abbrev => $LJ::SITENAMEABBREV, Modified: trunk/cgi-bin/LJ/Event/UserNewEntry.pm =================================================================== --- trunk/cgi-bin/LJ/Event/UserNewEntry.pm 2011-03-03 04:56:54 UTC (rev 18448) +++ trunk/cgi-bin/LJ/Event/UserNewEntry.pm 2011-03-03 05:10:07 UTC (rev 18449) @@ -100,15 +100,18 @@ } sub as_sms { - my ($self, $u) = @_; + my ($self, $u, $opt) = @_; my $lang = ($u && $u->prop('browselang')) || $LJ::DEFAULT_LANG; my $entry = $self->entry; my $mlstring = ($entry->posterid == $entry->journalid)? 'notification.sms.usernewentry':'notification.sms.usernewentry_comm'; - my $tinyurl = LJ::API::BitLy->shorten( 'http://m.livejournal.com/read/user/' - . $entry->journal->user . '/' . $entry->ditemid . '/' ); + my $tinyurl = 'http://m.livejournal.com/read/user/' + . $entry->journal->user . '/' . $entry->ditemid . '/'; + my $mparms = $opt->{mobile_url_extra_params}; + $tinyurl .= '?' . join('&', map {$_ . '=' . $mparms->{$_}} keys %$mparms) if $mparms; + $tinyurl = LJ::API::BitLy->shorten($tinyurl); undef $tinyurl if $tinyurl =~ /^500/; - + # User '[[user]]' posted in their journal # User '[[user]]' posted '[[journal]]' return LJ::Lang::get_text($lang, '.string', undef, { Modified: trunk/cgi-bin/LJ/Event.pm =================================================================== --- trunk/cgi-bin/LJ/Event.pm 2011-03-03 04:56:54 UTC (rev 18448) +++ trunk/cgi-bin/LJ/Event.pm 2011-03-03 05:10:07 UTC (rev 18449) @@ -481,9 +481,9 @@ # # $txtlj->send($u, $event->as_sms($u)); sub as_sms { - my ($self, $u) = @_; + my ($self, $u, $opt) = @_; return LJ::Text->truncate_with_ellipsis( - 'str' => $self->as_string($u), + 'str' => $self->as_string($u, $opt), 'bytes' => 160, 'ellipsis' => '...', );