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

[fotobilder] r1463: LJSUP-11926 (ensure that fotobilder API ...

Committer: ailyin
LJSUP-11926 (ensure that fotobilder API works with the new photo hosting)
U   trunk/lib/FB/Protocol/Fotki/UploadPrepare.pm
U   trunk/lib/FB/Protocol/Fotki.pm
U   trunk/lib/FB/Protocol/Response.pm
Modified: trunk/lib/FB/Protocol/Fotki/UploadPrepare.pm
===================================================================
--- trunk/lib/FB/Protocol/Fotki/UploadPrepare.pm	2012-04-23 15:04:25 UTC (rev 1462)
+++ trunk/lib/FB/Protocol/Fotki/UploadPrepare.pm	2012-04-24 12:36:41 UTC (rev 1463)
@@ -29,15 +29,11 @@
 
     my $ret = {};
 
-    if (ref $spaces eq 'ARRAY') {
-        my $free_space = $spaces->[3] - $spaces->[0]; 
-        $free_space = 0 if $free_space < 0;
-        $ret->{Quota} = {
-            Total     => [ LJ::Pics->get_available_space($lj_user) ],
-            Used      => [ LJ::Pics->get_occupied_space($lj_user) ],
-            Remaining => [ LJ::Pics->get_free_space($lj_user) ],
-        };
-    }
+    $ret->{Quota} = {
+        Total     => [ LJ::Pics->get_available_space($lj_user) ],
+        Used      => [ LJ::Pics->get_occupied_space($lj_user) ],
+        Remaining => [ LJ::Pics->get_free_space($lj_user) ],
+    };
 
   PIC:
     foreach my $pic (@$picarr) {

Modified: trunk/lib/FB/Protocol/Fotki.pm
===================================================================
--- trunk/lib/FB/Protocol/Fotki.pm	2012-04-23 15:04:25 UTC (rev 1462)
+++ trunk/lib/FB/Protocol/Fotki.pm	2012-04-24 12:36:41 UTC (rev 1463)
@@ -8,31 +8,57 @@
 }
 # map security values from FB to LJ security and 
 sub fb2lj_security {
-    my ($class, $sec) = @_;
-    $sec = $sec + 0;
-    my ($security, $allowmask);
-    if ($sec == 255) {
-        $security = 'public';
-        $allowmask = 0;
-    } elsif ($sec >= 126 && $sec < 158) {
-        $security = 'usemask';
-        $allowmask =  $sec - 127;
-    } else {
-        $security = 'private';
-        $allowmask = 0;
+    my ( $class, $sec ) = @_;
+    $sec = int $sec;
+
+    # public => public
+    # registered users => public
+    if ( $sec == 255 || $sec == 253 ) {
+        return ( 'public', 0 );
     }
-    return ($security, $allowmask);
+
+    # all groups => friends
+    if ( $sec == 254 ) {
+        return ( 'usemask', 1 );
+    }
+
+    # specified group in range 1..30 => proper allowmask
+    if ($sec > 0 && $sec <= 30) {
+        return ( 'usemask', 1 << $sec );
+    }
+
+    # otherwise, private
+    return ( 'private', 0 );
 }
 
 sub lj2fb_security {
-    my ($class, $security, $allowmask) = @_;
+    my ( $class, $security, $allowmask ) = @_;
 
-    if ($security eq 'public') {
+    # public => public
+    if ( $security eq 'public' ) {
         return 255;
-    } elsif ($security eq 'usemask') {
-        return 127 + $allowmask;
-    } 
-    return 0;
+    }
+
+    # private => private
+    if ( $security eq 'private' ) {
+        return 0;
+    }
+
+    # from here on, $security equals 'usemask'
+
+    # friends => all groups
+    if ( $allowmask == 1 ) {
+        return 254;
+    }
+
+    # proper allowmask => one group in range 1..30
+    my $major_bit = 0;
+    foreach my $bit ( 1 .. 30 ) {
+        next unless $allowmask & ( 1 << $bit );
+        $major_bit = $bit;
+    }
+
+    return $major_bit;
 }
 
 

Modified: trunk/lib/FB/Protocol/Response.pm
===================================================================
--- trunk/lib/FB/Protocol/Response.pm	2012-04-23 15:04:25 UTC (rev 1462)
+++ trunk/lib/FB/Protocol/Response.pm	2012-04-24 12:36:41 UTC (rev 1463)
@@ -33,6 +33,7 @@
                                         GetGals
                                         GetGalsTree
                                         GetPics
+                                        GetSecGroups
                                         Login
                                         UploadPrepare
                                         UploadTempFile

Tags: ailyin, andy, fotobilder, 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