]> git.mxchange.org Git - friendica.git/commitdiff
faster friend requests (DFRN)
authorFriendika <info@friendika.com>
Wed, 7 Sep 2011 01:06:19 +0000 (18:06 -0700)
committerFriendika <info@friendika.com>
Wed, 7 Sep 2011 01:06:19 +0000 (18:06 -0700)
boot.php
include/network.php
mod/dfrn_request.php

index b17d948601a4fa0e8f5c281edef3b24252fa8b39..9eabcd4efd713fbba7a3c1e7ea43f7a0e06970be 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -7,7 +7,7 @@ require_once('include/text.php');
 require_once("include/pgettext.php");
 
 
-define ( 'FRIENDIKA_VERSION',      '2.2.1094' );
+define ( 'FRIENDIKA_VERSION',      '2.2.1095' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.21'    );
 define ( 'DB_UPDATE_VERSION',      1087      );
 
index 2832ae2d33660e75c27c8ed30bb302bea9ccd329..deb257ff3d877720f1a866c1614b0d6bedf0f99b 100644 (file)
@@ -259,22 +259,29 @@ function convert_xml_element_to_array($xml_element, &$recursion_depth=0) {
 // or if the resultant personal XRD doesn't contain a supported 
 // subscription/friend-request attribute.
 
+// amended 7/9/2011 to return an hcard which could save potentially loading 
+// a lengthy content page to scrape dfrn attributes
+
 if(! function_exists('webfinger_dfrn')) {
-function webfinger_dfrn($s) {
+function webfinger_dfrn($s,&$hcard) {
        if(! strstr($s,'@')) {
                return $s;
        }
+       $profile_link = '';
+
        $links = webfinger($s);
        logger('webfinger_dfrn: ' . $s . ':' . print_r($links,true), LOGGER_DATA);
        if(count($links)) {
-               foreach($links as $link)
+               foreach($links as $link) {
                        if($link['@attributes']['rel'] === NAMESPACE_DFRN)
-                               return $link['@attributes']['href'];
-               foreach($links as $link)
+                               $profile_link = $link['@attributes']['href'];
                        if($link['@attributes']['rel'] === NAMESPACE_OSTATUSSUB)
-                               return 'stat:' . $link['@attributes']['template'];              
+                               $profile_link = 'stat:' . $link['@attributes']['template'];     
+                       if($link['@attributes']['rel'] === 'http://microformats.org/profile/hcard')
+                               $hcard = $link['@attributes']['href'];                          
+               }
        }
-       return '';
+       return $profile_link;
 }}
 
 // Given an email style address, perform webfinger lookup and 
index ce83001b480de9ae6bd4800ae84a880b0b33830f..5d789f480bb31cd34ddf3472004351eb1faf2321 100644 (file)
@@ -277,14 +277,15 @@ function dfrn_request_post(&$a) {
 
                // Canonicalise email-style profile locator
 
-               $url = webfinger_dfrn($url);
+               $hcard = '';
+               $url = webfinger_dfrn($url,$hcard);
 
                if(substr($url,0,5) === 'stat:') {
-                       $network = 'stat';
+                       $network = NETWORK_OSTATUS;
                        $url = substr($url,5);
                }
                else {
-                       $network = 'dfrn';
+                       $network = NETWORK_DFRN;
                }
 
                logger('dfrn_request: url: ' . $url);
@@ -342,7 +343,7 @@ function dfrn_request_post(&$a) {
 
                                require_once('Scrape.php');
 
-                               $parms = scrape_dfrn($url);
+                               $parms = scrape_dfrn(($hcard) ? $hcard : $url);
 
                                if(! count($parms)) {
                                        notice( t('Profile location is not valid or does not contain profile information.') . EOL );