X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FProtocol%2FOStatus.php;h=fe8f060aa3fffdf68ca6da5205fd5b08516c5467;hb=341d8860d15cd2224a3595dfa3c553b03658ef60;hp=9988a4009bb1dadc780224d067d37533cc0b3c24;hpb=eb1b2256a00ece6d802e798ee15ad1f8b55c36f9;p=friendica.git diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index 9988a4009b..fe8f060aa3 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -1,6 +1,6 @@ 0)) { if (self::$itemlist[0]['uri'] == self::$itemlist[0]['thr-parent']) { + $uid = self::$itemlist[0]['uid']; // We will import it everytime, when it is started by our contacts - $valid = Contact::isSharingByURL(self::$itemlist[0]['author-link'], self::$itemlist[0]['uid']); + $valid = Contact::isSharingByURL(self::$itemlist[0]['author-link'], $uid); if (!$valid) { // If not, then it depends on this setting - $valid = ((self::$itemlist[0]['uid'] == 0) || !DI::pConfig()->get(self::$itemlist[0]['uid'], 'system', 'accept_only_sharer', false)); + $valid = !$uid || DI::pConfig()->get($uid, 'system', 'accept_only_sharer') != Item::COMPLETION_NONE; + if ($valid) { Logger::info("Item with uri ".self::$itemlist[0]['uri']." will be imported due to the system settings."); } } else { Logger::info("Item with uri ".self::$itemlist[0]['uri']." belongs to a contact (".self::$itemlist[0]['contact-id']."). It will be imported."); } - if ($valid) { + + if ($valid && DI::pConfig()->get($uid, 'system', 'accept_only_sharer') != Item::COMPLETION_LIKE) { // Never post a thread when the only interaction by our contact was a like $valid = false; $verbs = [Activity::POST, Activity::SHARE]; @@ -728,7 +731,7 @@ class OStatus self::$conv_list[$conversation] = true; - $curlResult = DI::httpClient()->get($conversation, [HttpClientOptions::ACCEPT_CONTENT => ['application/atom+xml', 'text/html']]); + $curlResult = DI::httpClient()->get($conversation, HttpClientAccept::ATOM_XML); if (!$curlResult->isSuccess() || empty($curlResult->getBody())) { return; @@ -758,7 +761,7 @@ class OStatus } } if ($file != '') { - $conversation_atom = DI::httpClient()->get($attribute['href']); + $conversation_atom = DI::httpClient()->get($attribute['href'], HttpClientAccept::ATOM_XML); if ($conversation_atom->isSuccess()) { $xml = $conversation_atom->getBody(); @@ -872,7 +875,7 @@ class OStatus return; } - $curlResult = DI::httpClient()->get($self); + $curlResult = DI::httpClient()->get($self, HttpClientAccept::ATOM_XML); if (!$curlResult->isSuccess()) { return; @@ -922,7 +925,7 @@ class OStatus } $stored = false; - $curlResult = DI::httpClient()->get($related, [HttpClientOptions::ACCEPT_CONTENT => ['application/atom+xml', 'text/html']]); + $curlResult = DI::httpClient()->get($related, HttpClientAccept::ATOM_XML); if (!$curlResult->isSuccess() || empty($curlResult->getBody())) { return; @@ -954,7 +957,7 @@ class OStatus } } if ($atom_file != '') { - $curlResult = DI::httpClient()->get($atom_file); + $curlResult = DI::httpClient()->get($atom_file, HttpClientAccept::ATOM_XML); if ($curlResult->isSuccess()) { Logger::info('Fetched XML for URI ' . $related_uri); @@ -966,7 +969,7 @@ class OStatus // Workaround for older GNU Social servers if (($xml == '') && strstr($related, '/notice/')) { - $curlResult = DI::httpClient()->get(str_replace('/notice/', '/api/statuses/show/', $related) . '.atom'); + $curlResult = DI::httpClient()->get(str_replace('/notice/', '/api/statuses/show/', $related) . '.atom', HttpClientAccept::ATOM_XML); if ($curlResult->isSuccess()) { Logger::info('GNU Social workaround to fetch XML for URI ' . $related_uri); @@ -977,7 +980,7 @@ class OStatus // Even more worse workaround for GNU Social ;-) if ($xml == '') { $related_guess = self::convertHref($related_uri); - $curlResult = DI::httpClient()->get(str_replace('/notice/', '/api/statuses/show/', $related_guess) . '.atom'); + $curlResult = DI::httpClient()->get(str_replace('/notice/', '/api/statuses/show/', $related_guess) . '.atom', HttpClientAccept::ATOM_XML); if ($curlResult->isSuccess()) { Logger::info('GNU Social workaround 2 to fetch XML for URI ' . $related_uri); @@ -1728,6 +1731,7 @@ class OStatus if ($owner['contact-type'] == Contact::TYPE_COMMUNITY) { $contact = Contact::getByURL($item['author-link']) ?: $owner; + $contact['nickname'] = $contact['nickname'] ?? $contact['nick']; $author = self::addAuthor($doc, $contact, false); $entry->appendChild($author); }