]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/DFRN.php
New function to fetch endpoint items
[friendica.git] / src / Protocol / DFRN.php
index f065cd67ece671fc14b803cb159068c36320ce8c..4c88db1d944a47c0a70d69e7618566438fb652f9 100644 (file)
@@ -182,7 +182,7 @@ class DFRN
 
                // default permissions - anonymous user
 
-               $sql_extra = " AND NOT `item`.`private` ";
+               $sql_extra = sprintf(" AND `item`.`private` != %s ", Item::PRIVATE);
 
                $r = q(
                        "SELECT `contact`.*, `user`.`nickname`, `user`.`timezone`, `user`.`page-flags`, `user`.`account-type`
@@ -234,7 +234,7 @@ class DFRN
                        if (!empty($set)) {
                                $sql_extra = " AND `item`.`psid` IN (" . implode(',', $set) .")";
                        } else {
-                               $sql_extra = " AND NOT `item`.`private`";
+                               $sql_extra = sprintf(" AND `item`.`private` != %s", Item::PRIVATE);
                        }
                }
 
@@ -332,7 +332,7 @@ class DFRN
                        if ($public_feed) {
                                $type = 'html';
                                // catch any email that's in a public conversation and make sure it doesn't leak
-                               if ($item['private']) {
+                               if ($item['private'] == Item::PRIVATE) {
                                        continue;
                                }
                        } else {
@@ -955,7 +955,7 @@ class DFRN
                        $entry->setAttribute("xmlns:statusnet", ActivityNamespace::STATUSNET);
                }
 
-               if ($item['private']) {
+               if ($item['private'] == Item::PRIVATE) {
                        $body = Item::fixPrivatePhotos($item['body'], $owner['uid'], $item, $cid);
                } else {
                        $body = $item['body'];
@@ -1050,7 +1050,9 @@ class DFRN
                }
 
                if ($item['private']) {
-                       XML::addElement($doc, $entry, "dfrn:private", ($item['private'] ? $item['private'] : 1));
+                       // Friendica versions prior to 2020.3 can't handle "unlisted" properly. So we can only transmit public and private
+                       XML::addElement($doc, $entry, "dfrn:private", ($item['private'] == Item::PRIVATE ? Item::PRIVATE : Item::PUBLIC));
+                       XML::addElement($doc, $entry, "dfrn:unlisted", $item['private'] == Item::UNLISTED);
                }
 
                if ($item['extid']) {
@@ -2404,6 +2406,11 @@ class DFRN
 
                $item["private"] = XML::getFirstNodeValue($xpath, "dfrn:private/text()", $entry);
 
+               $unlisted = XML::getFirstNodeValue($xpath, "dfrn:unlisted/text()", $entry);
+               if (!empty($unlisted) && ($item['private'] != Item::PRIVATE)) {
+                       $item['private'] = Item::UNLISTED;
+               }
+
                $item["extid"] = XML::getFirstNodeValue($xpath, "dfrn:extid/text()", $entry);
 
                if (XML::getFirstNodeValue($xpath, "dfrn:bookmark/text()", $entry) == "true") {