]> git.mxchange.org Git - friendica.git/blobdiff - mod/salmon.php
Edited view/sv/registrations-top.tpl via GitHub
[friendica.git] / mod / salmon.php
index 2acb094c31c8b4cc4a9b274aa669e4314f2ee9b5..885ba470c8458e64a8456f9015e52c2cbfd2da82 100644 (file)
@@ -14,7 +14,7 @@ function salmon_return($val) {
 
        if($val >= 400)
                $err = 'Error';
-       if($val == 200)
+       if($val >= 200 && $val < 300)
                $err = 'OK';
 
        logger('mod-salmon returns ' . $val);   
@@ -158,8 +158,10 @@ function salmon_post(&$a) {
 
     $verify = $rsa->verify($signed_data,$signature);
 
-       if(! $verify)
+       if(! $verify) {
+               logger('mod-salmon: message did not verify using protocol. Trying statusnet hack.');
            $verify = $rsa->verify($stnet_signed_data,$signature);
+    }
 
        if(! $verify) {
                logger('mod-salmon: Message did not verify. Discarding.');
@@ -175,7 +177,7 @@ function salmon_post(&$a) {
        *
        */
 
-       $r = q("SELECT * FROM `contact` WHERE `network` = 'stat' AND ( `url` = '%s' OR `lrdd` = '%s') 
+       $r = q("SELECT * FROM `contact` WHERE `network` = 'stat' AND ( `url` = '%s' OR `alias` = '%s') 
                AND `uid` = %d LIMIT 1",
                dbesc($author_link),
                dbesc($author_link),
@@ -186,7 +188,7 @@ function salmon_post(&$a) {
        }       
        if((count($r)) && ($r[0]['readonly'])) {
                logger('mod-salmon: Ignoring this author.');
-               salmon_return(200);
+               salmon_return(202);
                // NOTREACHED
        }
 
@@ -197,9 +199,16 @@ function salmon_post(&$a) {
 
        $hub = '';
 
-       // consume_feed will only accept a follow activity from this person if there is no contact record.
+       /**
+        *
+        * anti-spam measure: consume_feed will accept a follow activity from 
+        * this person (and nothing else) if there is no existing contact record.
+        *
+        */
+
+       $contact_rec = ((count($r)) ? $r[0] : null);
 
-       consume_feed($feedxml,$importer,((count($r)) ? $r[0] : null),$hub);
+       consume_feed($feedxml,$importer,$contact_rec,$hub);
 
        salmon_return(200);
 }