alf (red_alf) wrote in changelog,
alf
red_alf
changelog

[livejournal] r23364: LJSUP-10900: Implement MessagePack proto...

Committer: afedorov
LJSUP-10900: Implement MessagePack protocol driver to access to Relation Service.

U   trunk/cgi-bin/LJ/RelationService/MysqlAPI.pm
U   trunk/cgi-bin/LJ/RelationService.pm
Modified: trunk/cgi-bin/LJ/RelationService/MysqlAPI.pm
===================================================================
--- trunk/cgi-bin/LJ/RelationService/MysqlAPI.pm	2012-11-26 15:41:43 UTC (rev 23363)
+++ trunk/cgi-bin/LJ/RelationService/MysqlAPI.pm	2012-11-27 02:59:46 UTC (rev 23364)
@@ -967,4 +967,31 @@
     return $ret;
 }
 
+sub find_relation_attributes {
+    my $class  = shift;
+    my $u      = shift;
+    my $friend = shift;
+    my $type   = shift;
+    my %opts   = @_;
+
+    return undef unless $type eq 'F';
+
+    return undef unless $u && $friend;
+ 
+    my $jid = LJ::want_userid($u);
+    my $fid = LJ::want_userid($friend);
+    return undef unless $jid && $fid;
+
+    my $dbr = LJ::get_db_reader();
+    die "No database reader available" unless $dbr;
+
+    my $fr = $dbr->selectrow_hashref("
+        SELECT groupmask, fgcolor, bgcolor 
+        FROM friends 
+        WHERE userid=? 
+          AND friendid=?
+    ", { Slice => {} }, $u->userid, $friend->userid);
+    return $fr;
+}
+
 1;

Modified: trunk/cgi-bin/LJ/RelationService.pm
===================================================================
--- trunk/cgi-bin/LJ/RelationService.pm	2012-11-26 15:41:43 UTC (rev 23363)
+++ trunk/cgi-bin/LJ/RelationService.pm	2012-11-27 02:59:46 UTC (rev 23364)
@@ -321,4 +321,27 @@
     return $interface->set_rel_multi($edges);
 }
 
+sub find_relation_attributes {
+    my $class  = shift;
+    my $u      = shift;
+    my $friend = shift;
+    my $type   = shift;
+    my %opts   = @_;
+    
+    $u = LJ::want_user($u);
+    $friend = LJ::want_user($friend);
+    
+    return undef unless $u && $friend && $type;
+
+    if ($class->_load_alt_api('read', $type)) {
+        my $alt = $class->alt_api($u);
+        if ($alt) {
+            $alt->find_relation_attributes($u, $friend, $type, %opts);
+        }
+    }
+
+    my $interface = $class->relation_api($u);
+    return $interface->find_relation_attributes($u, $friend, $type, %opts);    
+}
+
 1;

Tags: afedorov, livejournal, pm, red_alf
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