Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[ljcom] r10294: LJSUP-8139 (VKontakte integration)

Committer: ailyin
LJSUP-8139 (VKontakte integration)
U   trunk/bin/upgrading/en_LJ.dat
U   trunk/cgi-bin/LJ/Client/Vkontakte.pm
U   trunk/cgi-bin/LJ/Setting/VkontakteConnect.pm
A   trunk/cgi-bin/LJ/Worker/Repost/CommentToVkontakte.pm
A   trunk/cgi-bin/LJ/Worker/Repost/EntryToVkontakte.pm
U   trunk/htdocs/manage/settings/vkontakte.bml
Modified: trunk/bin/upgrading/en_LJ.dat
===================================================================
--- trunk/bin/upgrading/en_LJ.dat	2011-03-24 09:30:42 UTC (rev 10293)
+++ trunk/bin/upgrading/en_LJ.dat	2011-03-24 10:39:06 UTC (rev 10294)
@@ -5266,6 +5266,8 @@
 
 repost.label.twitter=Twitter
 
+repost.label.vkontakte=Vkontakte
+
 repost.link.edit=Edit
 
 repost.link.facebook.select_img=Choose a pic

Modified: trunk/cgi-bin/LJ/Client/Vkontakte.pm
===================================================================
--- trunk/cgi-bin/LJ/Client/Vkontakte.pm	2011-03-24 09:30:42 UTC (rev 10293)
+++ trunk/cgi-bin/LJ/Client/Vkontakte.pm	2011-03-24 10:39:06 UTC (rev 10294)
@@ -127,8 +127,8 @@
 
     if ( $params_returned->{'error'} ) {
         warn 'vkontakte connectivity error: '
-           . $params_returned->{'error'} . ' / '
-           . $params_returned->{'error_description'};
+           . $params_returned->{'error'}->{'error_code'} . ' / '
+           . $params_returned->{'error'}->{'error_msg'};
 
         die 'vkontakte connectivity error';
     }

Modified: trunk/cgi-bin/LJ/Setting/VkontakteConnect.pm
===================================================================
--- trunk/cgi-bin/LJ/Setting/VkontakteConnect.pm	2011-03-24 09:30:42 UTC (rev 10293)
+++ trunk/cgi-bin/LJ/Setting/VkontakteConnect.pm	2011-03-24 10:39:06 UTC (rev 10294)
@@ -8,7 +8,7 @@
 
     return $u
         && LJ::is_enabled( 'repost_vkontakte', $u )
-        && $LJ::FACEBOOK_CONNECT_API_KEY
+        && $LJ::VKONTAKTE_CONF
         && ( $u->is_personal || $u->is_identity ) ? 1 : 0;
 }
 

Added: trunk/cgi-bin/LJ/Worker/Repost/CommentToVkontakte.pm
===================================================================
--- trunk/cgi-bin/LJ/Worker/Repost/CommentToVkontakte.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/Worker/Repost/CommentToVkontakte.pm	2011-03-24 10:39:06 UTC (rev 10294)
@@ -0,0 +1,41 @@
+package LJ::Worker::Repost::CommentToVkontakte;
+use strict;
+
+use base qw(LJ::Worker::Repost);
+use LJ::Text;
+use LJ::Client::Vkontakte;
+
+sub work {
+    my ($class, $job) = @_;
+
+    my $arg     = $job->arg;
+
+    my $poster  = LJ::load_userid($arg->{'posterid'});
+    my $journal = LJ::load_userid($arg->{'journalid'});
+    my $comment = LJ::Comment->new($journal, 'jtalkid' => $arg->{'jtalkid'});
+
+    my $short_url = $class->shorten_url($comment->url);
+    my $title     = $comment->subject_raw || $comment->body_raw;
+
+    $title = $class->cleanup($title);
+
+    $title = LJ::Lang::get_text( $poster->prop('browselang'),
+                                 'vkontakteconnect.untitled.comment' )
+        if $title !~ /\S/;
+
+    $title = LJ::Text->truncate_to_word_with_ellipsis(
+        'str' => $title,
+        'chars' => 139 - length($short_url),
+    );
+
+    my $status = "$title $short_url";
+
+    LJ::Client::Vkontakte->call( 'wall.post', {
+        'message' =>  $status,
+        'access_token' => $poster->prop('vkontakte_access_token'),
+    } );
+
+    return $job->completed;
+}
+
+1;

Added: trunk/cgi-bin/LJ/Worker/Repost/EntryToVkontakte.pm
===================================================================
--- trunk/cgi-bin/LJ/Worker/Repost/EntryToVkontakte.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/Worker/Repost/EntryToVkontakte.pm	2011-03-24 10:39:06 UTC (rev 10294)
@@ -0,0 +1,41 @@
+package LJ::Worker::Repost::EntryToVkontakte;
+use strict;
+
+use base qw(LJ::Worker::Repost);
+use LJ::Text;
+use LJ::Client::Vkontakte;
+
+sub work {
+    my ($class, $job) = @_;
+
+    my $arg     = $job->arg;
+
+    my $poster  = LJ::load_userid($arg->{'posterid'});
+    my $journal = LJ::load_userid($arg->{'journalid'});
+    my $entry   = LJ::Entry->new($journal, 'jitemid' => $arg->{'jitemid'});
+
+    my $short_url = $class->shorten_url($entry->url);
+    my $title     = $entry->subject_raw || $entry->event_raw;
+
+    $title = $class->cleanup($title);
+
+    $title = LJ::Lang::get_text( $poster->prop('browselang'),
+                                 'vkontakteconnect.untitled.entry' )
+        if $title eq '';
+
+    $title = LJ::Text->truncate_to_word_with_ellipsis(
+        'str' => $title,
+        'chars' => 139 - length($short_url),
+    );
+
+    my $status = "$title $short_url";
+
+    LJ::Client::Vkontakte->call( 'wall.post', {
+        'message' =>  $status,
+        'access_token' => $poster->prop('vkontakte_access_token'),
+    } );
+
+    return $job->completed;
+}
+
+1;

Modified: trunk/htdocs/manage/settings/vkontakte.bml
===================================================================
--- trunk/htdocs/manage/settings/vkontakte.bml	2011-03-24 09:30:42 UTC (rev 10293)
+++ trunk/htdocs/manage/settings/vkontakte.bml	2011-03-24 10:39:06 UTC (rev 10294)
@@ -83,7 +83,8 @@
             );
 
         $u->clear_prop($_)
-            foreach qw( vkontakte_access_token vkontakte_name vkontakte_link );
+            foreach qw( vkontakte_userid vkontakte_access_token
+                        vkontakte_name vkontakte_link );
 
         return LJ::Request->redirect($settings_page);
     }

Tags: andy, bml, dat, ljcom, pm
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