X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FProtocol%2FDFRN.php;h=4c88db1d944a47c0a70d69e7618566438fb652f9;hb=b6ab8c9e9455728a79fc1e4995651c845ded5dbf;hp=ff891701a396156eb2b3ec76f92cb8c105a0665e;hpb=13a10b8f20ac7c5927c39d9e80e1a7d515385736;p=friendica.git diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index ff891701a3..4c88db1d94 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -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 { @@ -639,27 +639,17 @@ class DFRN */ private static function addAuthor(DOMDocument $doc, array $owner, $authorelement, $public) { - // Is the profile hidden or shouldn't be published in the net? Then add the "hide" element - $r = q( - "SELECT `id` FROM `profile` INNER JOIN `user` ON `user`.`uid` = `profile`.`uid` - WHERE (`hidewall` OR NOT `net-publish`) AND `user`.`uid` = %d", - intval($owner['uid']) - ); - if (DBA::isResult($r)) { - $hidewall = true; - } else { - $hidewall = false; - } + // Should the profile be "unsearchable" in the net? Then add the "hide" element + $hide = DBA::exists('profile', ['uid' => $owner['uid'], 'net-publish' => false]); $author = $doc->createElement($authorelement); $namdate = DateTimeFormat::utc($owner['name-date'].'+00:00', DateTimeFormat::ATOM); - $uridate = DateTimeFormat::utc($owner['uri-date'].'+00:00', DateTimeFormat::ATOM); $picdate = DateTimeFormat::utc($owner['avatar-date'].'+00:00', DateTimeFormat::ATOM); $attributes = []; - if (!$public || !$hidewall) { + if (!$public || !$hide) { $attributes = ["dfrn:updated" => $namdate]; } @@ -670,7 +660,7 @@ class DFRN $attributes = ["rel" => "photo", "type" => "image/jpeg", "media:width" => 300, "media:height" => 300, "href" => $owner['photo']]; - if (!$public || !$hidewall) { + if (!$public || !$hide) { $attributes["dfrn:updated"] = $picdate; } @@ -679,7 +669,7 @@ class DFRN $attributes["rel"] = "avatar"; XML::addElement($doc, $author, "link", "", $attributes); - if ($hidewall) { + if ($hide) { XML::addElement($doc, $author, "dfrn:hide", "true"); } @@ -965,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']; @@ -1060,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']) { @@ -2414,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") {