]> git.mxchange.org Git - friendica.git/blobdiff - mod/salmon.php
Conversation and Item now handles (dis)like as they should
[friendica.git] / mod / salmon.php
index 0264e820db2a03f224c512928170d2868cfce9b3..1e16f9d14ba1d2e6b7b8fff8886b24adbcdef04d 100644 (file)
@@ -25,12 +25,12 @@ function salmon_post(&$a) {
 
        $xml = file_get_contents('php://input');
 
-       logger('mod-salmon: new salmon ' . $xml);
+       logger('mod-salmon: new salmon ' . $xml, LOGGER_DATA);
 
        $nick       = (($a->argc > 1) ? notags(trim($a->argv[1])) : '');
        $mentions   = (($a->argc > 2 && $a->argv[2] === 'mention') ? true : false);
 
-       $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
+       $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 LIMIT 1",
                dbesc($nick)
        );
        if(! count($r))
@@ -170,14 +170,28 @@ function salmon_post(&$a) {
        *
        */
 
-       $r = q("SELECT * FROM `contact` WHERE `network` = 'stat' AND ( `url` = '%s' OR `alias` = '%s'
+       $r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND ( `url` = '%s' OR `alias` = '%s' 
                AND `uid` = %d LIMIT 1",
+               dbesc(NETWORK_OSTATUS),
                dbesc($author_link),
                dbesc($author_link),
                intval($importer['uid'])
        );
        if(! count($r)) {
                logger('mod-salmon: Author unknown to us.');
+               if(get_pconfig($importer['uid'],'system','ostatus_autofriend')) {
+                       require_once('include/follow.php');
+                       $result = new_contact($importer['uid'],$author_link);
+                       if($result['success']) {
+                               $r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND ( `url` = '%s' OR `alias` = '%s' ) 
+                                       AND `uid` = %d LIMIT 1",
+                                       dbesc(NETWORK_OSTATUS),
+                                       dbesc($author_link),
+                                       dbesc($author_link),
+                                       intval($importer['uid'])
+                               );
+                       }
+               }
        }       
 
        // is this a follower? Or have we ignored the person?