]> git.mxchange.org Git - friendica.git/blobdiff - include/diaspora.php
Issue-#3873
[friendica.git] / include / diaspora.php
index 8c04ec1d07e5fd817a993c0707aeb9cb26b8b865..846a89ba9ced9a50607f17a567913c9ace789b8d 100644 (file)
@@ -12,6 +12,7 @@ use Friendica\App;
 use Friendica\Core\System;
 use Friendica\Core\Config;
 use Friendica\Core\PConfig;
+use Friendica\Core\Worker;
 use Friendica\Network\Probe;
 
 require_once 'include/items.php';
@@ -41,7 +42,7 @@ class Diaspora {
         */
        public static function relay_list() {
 
-               $serverdata = get_config("system", "relay_server");
+               $serverdata = Config::get("system", "relay_server");
                if ($serverdata == "")
                        return array();
 
@@ -410,7 +411,7 @@ class Diaspora {
         */
        public static function dispatch_public($msg) {
 
-               $enabled = intval(get_config("system", "diaspora_enabled"));
+               $enabled = intval(Config::get("system", "diaspora_enabled"));
                if (!$enabled) {
                        logger("diaspora is disabled");
                        return false;
@@ -739,7 +740,7 @@ class Diaspora {
 
                if (!$person || $update) {
                        logger("create or refresh", LOGGER_DEBUG);
-                       $r = probe_url($handle, PROBE_DIASPORA);
+                       $r = Probe::uri($handle, NETWORK_DIASPORA);
 
                        // Note that Friendica contacts will return a "Diaspora person"
                        // if Diaspora connectivity is enabled on their server
@@ -1134,7 +1135,8 @@ class Diaspora {
                        return false;
 
                // This will work for new Diaspora servers and Friendica servers from 3.5
-               $source_url = $server."/fetch/post/".$guid;
+               $source_url = $server."/fetch/post/".urlencode($guid);
+
                logger("Fetch post from ".$source_url, LOGGER_DEBUG);
 
                $envelope = fetch_url($source_url);
@@ -1150,7 +1152,7 @@ class Diaspora {
 
                // This will work for older Diaspora and Friendica servers
                if (!$x) {
-                       $source_url = $server."/p/".$guid.".xml";
+                       $source_url = $server."/p/".urlencode($guid).".xml";
                        logger("Fetch post from ".$source_url, LOGGER_DEBUG);
 
                        $x = fetch_url($source_url);
@@ -1396,9 +1398,9 @@ class Diaspora {
                                                $n, dbesc($f[0]),
                                                intval($importer["uid"]));
 
-                                       if ($x === false) {
-                                               return false;
-                                       }
+                               if ($x === false) {
+                                       return false;
+                               }
                        }
                }
 
@@ -1604,7 +1606,7 @@ class Diaspora {
                        dba::insert('sign', array('iid' => $message_id, 'signed_text' => json_encode($data)));
 
                        // notify others
-                       proc_run(PRIORITY_HIGH, "include/notifier.php", "comment-import", $message_id);
+                       Worker::add(PRIORITY_HIGH, "notifier", "comment-import", $message_id);
                }
 
                return true;
@@ -1914,7 +1916,7 @@ class Diaspora {
                        dba::insert('sign', array('iid' => $message_id, 'signed_text' => json_encode($data)));
 
                        // notify others
-                       proc_run(PRIORITY_HIGH, "include/notifier.php", "comment-import", $message_id);
+                       Worker::add(PRIORITY_HIGH, "notifier", "comment-import", $message_id);
                }
 
                return true;
@@ -2149,7 +2151,7 @@ class Diaspora {
                        intval($importer["uid"])
                );
 
-               if ($r && !$r[0]["hide-friends"] && !$contact["hidden"] && intval(get_pconfig($importer["uid"], "system", "post_newfriend"))) {
+               if ($r && !$r[0]["hide-friends"] && !$contact["hidden"] && intval(PConfig::get($importer["uid"], "system", "post_newfriend"))) {
 
                        $self = q("SELECT * FROM `contact` WHERE `self` AND `uid` = %d LIMIT 1",
                                intval($importer["uid"])
@@ -2190,7 +2192,7 @@ class Diaspora {
 
                                $i = item_store($arr);
                                if ($i)
-                                       proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i);
+                                       Worker::add(PRIORITY_HIGH, "notifier", "activity", $i);
                        }
                }
        }
@@ -2613,7 +2615,7 @@ class Diaspora {
                        // Now check if the retraction needs to be relayed by us
                        if ($parent["origin"]) {
                                // notify others
-                               proc_run(PRIORITY_HIGH, "include/notifier.php", "drop", $item["id"]);
+                               Worker::add(PRIORITY_HIGH, "notifier", "drop", $item["id"]);
                        }
                }
 
@@ -2940,7 +2942,7 @@ class Diaspora {
 
                $a = get_app();
 
-               $enabled = intval(get_config("system", "diaspora_enabled"));
+               $enabled = intval(Config::get("system", "diaspora_enabled"));
                if (!$enabled)
                        return 200;
 
@@ -2956,7 +2958,7 @@ class Diaspora {
                if (!$queue_run && was_recently_delayed($contact["id"])) {
                        $return_code = 0;
                } else {
-                       if (!intval(get_config("system", "diaspora_test"))) {
+                       if (!intval(Config::get("system", "diaspora_test"))) {
                                $content_type = (($public_batch) ? "application/magic-envelope+xml" : "application/json");
 
                                post_url($dest_url."/", $envelope, array("Content-Type: ".$content_type));
@@ -3568,11 +3570,11 @@ class Diaspora {
                // Split the signed text
                $signed_parts = explode(";", $signature['signed_text']);
 
-               if ($item["deleted"])
+               if ($item["deleted"]) {
                        $message = array("author" => $signature['signer'],
                                        "target_guid" => $signed_parts[0],
                                        "target_type" => $signed_parts[1]);
-               elseif ($item['verb'] === ACTIVITY_LIKE)
+               } elseif (in_array($item["verb"], array(ACTIVITY_LIKE, ACTIVITY_DISLIKE))) {
                        $message = array("author" => $signed_parts[4],
                                        "guid" => $signed_parts[1],
                                        "parent_guid" => $signed_parts[3],
@@ -3580,7 +3582,7 @@ class Diaspora {
                                        "positive" => $signed_parts[0],
                                        "author_signature" => $signature['signature'],
                                        "parent_author_signature" => "");
-               else {
+               else {
                        // Remove the comment guid
                        $guid = array_shift($signed_parts);
 
@@ -3615,12 +3617,13 @@ class Diaspora {
         */
        public static function send_relay($item, $owner, $contact, $public_batch = false) {
 
-               if ($item["deleted"])
+               if ($item["deleted"]) {
                        return self::send_retraction($item, $owner, $contact, $public_batch, true);
-               elseif ($item['verb'] === ACTIVITY_LIKE)
+               } elseif (in_array($item["verb"], array(ACTIVITY_LIKE, ACTIVITY_DISLIKE))) {
                        $type = "like";
-               else
+               } else {
                        $type = "comment";
+               }
 
                logger("Got relayable data ".$type." for item ".$item["guid"]." (".$item["id"].")", LOGGER_DEBUG);
 
@@ -3687,7 +3690,7 @@ class Diaspora {
 
                if ($item['id'] == $item['parent']) {
                        $target_type = "Post";
-               } elseif ($item["verb"] == ACTIVITY_LIKE) {
+               } elseif (in_array($item["verb"], array(ACTIVITY_LIKE, ACTIVITY_DISLIKE))) {
                        $target_type = "Like";
                } else {
                        $target_type = "Comment";