X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FProtocol%2FDFRN.php;h=10c43626a1d3e72b2653e3d40e16dbbda5acf241;hb=64b40254b001ee69e9b040680f4cc632405cffce;hp=e29cfcc5ab38c7cd29989179c53da31cc0e0489e;hpb=d75cd8a00a88a52e6d7bf67c91ba464c81c644c1;p=friendica.git diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index e29cfcc5ab..10c43626a1 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -1,6 +1,6 @@ set('system', 'site_pubkey', $res['pubkey']); } - $profilephotos = Photo::selectToArray(['resource-id' , 'scale'], ['profile' => true, 'uid' => $uid], ['order' => ['scale']]); + $profilephotos = Photo::selectToArray(['resource-id', 'scale', 'type'], ['profile' => true, 'uid' => $uid], ['order' => ['scale']]); $photos = []; $ext = Images::supportedTypes(); foreach ($profilephotos as $p) { - $photos[$p['scale']] = DI::baseUrl().'/photo/'.$p['resource-id'].'-'.$p['scale'].'.'.$ext[$p['type']]; + $photos[$p['scale']] = DI::baseUrl() . '/photo/' . $p['resource-id'] . '-' . $p['scale'] . '.' . $ext[$p['type']]; } - $doc = new DOMDocument('1.0', 'utf-8'); $doc->formatOutput = true; @@ -775,6 +774,7 @@ class DFRN } $body = Post\Media::addAttachmentsToBody($item['uri-id'], DI::contentItem()->addSharedPost($item)); + $body = Post\Media::addHTMLAttachmentToBody($item['uri-id'], $body); if ($item['private'] == Item::PRIVATE) { $body = Item::fixPrivatePhotos($body, $owner['uid'], $item, $cid); @@ -1015,6 +1015,10 @@ class DFRN $xml = $postResult->getBody(); $curl_stat = $postResult->getReturnCode(); + if (!empty($contact['gsid']) && ($postResult->isTimeout() || empty($curl_stat))) { + GServer::setFailureById($contact['gsid']); + } + if (empty($curl_stat) || empty($xml)) { Logger::notice('Empty answer from ' . $contact['id'] . ' - ' . $dest_url); return -9; // timed out @@ -1036,6 +1040,10 @@ class DFRN return -23; } + if (!empty($contact['gsid'])) { + GServer::setReachableById($contact['gsid'], Protocol::DFRN); + } + if (!empty($res->message)) { Logger::info('Transmit to ' . $dest_url . ' returned status '.$res->status.' - '.$res->message); } @@ -1334,7 +1342,7 @@ class DFRN */ private static function processMail(DOMXPath $xpath, DOMNode $mail, array $importer) { - Logger::notice("Processing mails"); + Logger::info("Processing mails"); $msg = []; $msg['uid'] = $importer['importer_uid']; @@ -1362,7 +1370,7 @@ class DFRN */ private static function processSuggestion(DOMXPath $xpath, DOMNode $suggestion, array $importer) { - Logger::notice('Processing suggestions'); + Logger::info('Processing suggestions'); $url = $xpath->evaluate('string(dfrn:url[1]/text())', $suggestion); $cid = Contact::getIdForURL($url); @@ -1438,7 +1446,7 @@ class DFRN */ private static function processRelocation(DOMXPath $xpath, DOMNode $relocation, array $importer): bool { - Logger::notice("Processing relocations"); + Logger::info("Processing relocations"); /// @TODO Rewrite this to one statement $relocate = []; @@ -1491,7 +1499,7 @@ class DFRN Contact::updateAvatar($importer['id'], $relocate['avatar'], true); - Logger::notice('Contacts are updated.'); + Logger::info('Contacts are updated.'); /// @TODO /// merge with current record, current contents have priority @@ -1586,22 +1594,22 @@ class DFRN // Big question: Do we need these functions? They were part of the "consume_feed" function. // This function once was responsible for DFRN and OStatus. if ($activity->match($item['verb'], Activity::FOLLOW)) { - Logger::notice("New follower"); + Logger::info("New follower"); Contact::addRelationship($importer, $contact, $item); return false; } if ($activity->match($item['verb'], Activity::UNFOLLOW)) { - Logger::notice("Lost follower"); + Logger::info("Lost follower"); Contact::removeFollower($contact); return false; } if ($activity->match($item['verb'], Activity::REQ_FRIEND)) { - Logger::notice("New friend request"); + Logger::info("New friend request"); Contact::addRelationship($importer, $contact, $item, true); return false; } if ($activity->match($item['verb'], Activity::UNFRIEND)) { - Logger::notice("Lost sharer"); + Logger::info("Lost sharer"); Contact::removeSharer($contact); return false; } @@ -1705,7 +1713,7 @@ class DFRN * Checks if an incoming message is wanted * * @param array $item - * @param array $imporer + * @param array $importer * @return boolean Is the message wanted? */ private static function isSolicitedMessage(array $item, array $importer): bool @@ -1751,7 +1759,7 @@ class DFRN */ private static function processEntry(array $header, DOMXPath $xpath, DOMNode $entry, array $importer, string $xml, int $protocol) { - Logger::notice("Processing entries"); + Logger::info("Processing entries"); $item = $header; @@ -2072,6 +2080,7 @@ class DFRN // This is my contact on another system, but it's really me. // Turn this into a wall post. $notify = Item::isRemoteSelf($importer, $item); + $item['wall'] = (bool)$notify; $posted_id = Item::insert($item, $notify); @@ -2098,7 +2107,7 @@ class DFRN */ private static function processDeletion(DOMXPath $xpath, DOMNode $deletion, array $importer) { - Logger::notice("Processing deletions"); + Logger::info("Processing deletions"); $uri = null; foreach ($deletion->attributes as $attributes) { @@ -2278,7 +2287,7 @@ class DFRN self::processDeletion($xpath, $deletion, $importer); } if (count($deletions) > 0) { - Logger::notice(count($deletions) . ' deletions had been processed'); + Logger::info(count($deletions) . ' deletions had been processed'); return 200; } }