]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/DFRN.php
Add missing default config keys
[friendica.git] / src / Protocol / DFRN.php
index ddbda750b919e21c1a84368a0d099c6ec566f040..79fa000f176571af17655f53d52fccda7b9ce2e7 100644 (file)
@@ -77,6 +77,11 @@ class DFRN
                }
 
                foreach ($items as $item) {
+                       // These values aren't sent when sending from the queue.
+                       /// @todo Check if we can set these values from the queue or if they are needed at all.
+                       $item["entry:comment-allow"] = defaults($item, "entry:comment-allow", true);
+                       $item["entry:cid"] = defaults($item, "entry:cid", 0);
+
                        $entry = self::entry($doc, "text", $item, $owner, $item["entry:comment-allow"], $item["entry:cid"]);
                        $root->appendChild($entry);
                }
@@ -1551,6 +1556,7 @@ class DFRN
                                logger("Contact ".$author["link"]." wasn't found for user ".$importer["importer_uid"]." XML: ".$xml, LOGGER_DEBUG);
                        }
 
+                       $author["contact-unknown"] = true;
                        $author["contact-id"] = $importer["id"];
                        $author["network"] = $importer["network"];
                        $onlyfetch = true;
@@ -2426,6 +2432,8 @@ class DFRN
                // Fetch the owner
                $owner = self::fetchauthor($xpath, $entry, $importer, "dfrn:owner", true);
 
+               $owner_unknown = (isset($owner["contact-unknown"]) && $owner["contact-unknown"]);
+
                $item["owner-link"] = $owner["link"];
                $item["owner-id"] = Contact::getIdForURL($owner["link"], 0);
 
@@ -2621,7 +2629,7 @@ class DFRN
                        }
 
                        // Is it an event?
-                       if ($item["object-type"] == ACTIVITY_OBJ_EVENT) {
+                       if (($item["object-type"] == ACTIVITY_OBJ_EVENT) && !$owner_unknown) {
                                logger("Item ".$item["uri"]." seems to contain an event.", LOGGER_DEBUG);
                                $ev = Event::fromBBCode($item["body"]);
                                if ((x($ev, "desc") || x($ev, "summary")) && x($ev, "start")) {
@@ -2654,6 +2662,13 @@ class DFRN
                        return;
                }
 
+               // This check is done here to be able to receive connection requests in "processVerbs"
+               if (($entrytype == DFRN::TOP_LEVEL) && $owner_unknown) {
+                       logger("Item won't be stored because user " . $importer["importer_uid"] . " doesn't follow " . $item["owner-link"] . ".", LOGGER_DEBUG);
+                       return;
+               }
+
+
                // Update content if 'updated' changes
                if (DBM::is_result($current)) {
                        if (self::updateContent($current, $item, $importer, $entrytype)) {
@@ -2746,7 +2761,7 @@ class DFRN
                }
 
                $condition = ['uri' => $uri, 'uid' => $importer["importer_uid"]];
-               $item = Item::selectFirst(['id', 'parent', 'contact-id', 'file'], $condition);
+               $item = Item::selectFirst(['id', 'parent', 'contact-id', 'file', 'deleted'], $condition);
                if (!DBM::is_result($item)) {
                        logger("Item with uri " . $uri . " for user " . $importer["importer_uid"] . " wasn't found.", LOGGER_DEBUG);
                        return;