]> git.mxchange.org Git - friendica.git/blobdiff - include/diaspora.php
Merge branch '1702-detect-server' of github.com:annando/friendica into 1702-detect...
[friendica.git] / include / diaspora.php
index fdbc0479f906a3439d37c9119aad05dfabed8412..eca22092d81352987a2a8a0e6981c8c7aa3fb206 100644 (file)
@@ -8,6 +8,8 @@
  * This will change in the future.
  */
 
+use \Friendica\Core\Config;
+
 require_once("include/items.php");
 require_once("include/bb2diaspora.php");
 require_once("include/Scrape.php");
@@ -309,10 +311,6 @@ class Diaspora {
                        return false;
                }
 
-               // Use a dummy importer to import the data for the public copy
-               $importer = array("uid" => 0, "page-flags" => PAGE_FREELOVE);
-               $message_id = self::dispatch($importer,$msg);
-
                // Now distribute it to the followers
                $r = q("SELECT `user`.* FROM `user` WHERE `user`.`uid` IN
                        (SELECT `contact`.`uid` FROM `contact` WHERE `contact`.`network` = '%s' AND `contact`.`addr` = '%s')
@@ -320,13 +318,22 @@ class Diaspora {
                        dbesc(NETWORK_DIASPORA),
                        dbesc($msg["author"])
                );
-               if ($r) {
+
+               if (dbm::is_result($r)) {
                        foreach ($r as $rr) {
                                logger("delivering to: ".$rr["username"]);
                                self::dispatch($rr,$msg);
                        }
                } else {
-                       logger("No subscribers for ".$msg["author"]." ".print_r($msg, true), LOGGER_DEBUG);
+                       $social_relay = (bool)Config::get('system', 'relay_subscribe', false);
+
+                       // Use a dummy importer to import the data for the public copy
+                       if ($social_relay) {
+                               $importer = array("uid" => 0, "page-flags" => PAGE_FREELOVE);
+                               $message_id = self::dispatch($importer,$msg);
+                       } else {
+                               logger("Unwanted message from ".$msg["author"]." send by ".$_SERVER["REMOTE_ADDR"]." with ".$_SERVER["HTTP_USER_AGENT"].": ".print_r($msg, true), LOGGER_DEBUG);
+                       }
                }
 
                return $message_id;