X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FProtocol%2FDFRN.php;h=194fa43fdd4fc51ac537566ba1aa55d45789bfb3;hb=19aef93560355d22e84e7ad549ff308ce839130d;hp=759ba674b1fd2e768f74d8392420216fa98752e6;hpb=befc2af5043a3afde251721c0d27df695db1bb7e;p=friendica.git diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 759ba674b1..194fa43fdd 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -899,10 +899,10 @@ class DFRN $entry->setAttribute("xmlns:statusnet", ActivityNamespace::STATUSNET); } + $body = Post\Media::addAttachmentsToBody($item['uri-id'], $item['body'] ?? ''); + if ($item['private'] == Item::PRIVATE) { - $body = Item::fixPrivatePhotos($item['body'], $owner['uid'], $item, $cid); - } else { - $body = $item['body']; + $body = Item::fixPrivatePhotos($body, $owner['uid'], $item, $cid); } // Remove the abstract element. It is only locally important. @@ -1272,7 +1272,7 @@ class DFRN switch ($rino_remote_version) { case 1: - $key = openssl_random_pseudo_bytes(16); + $key = random_bytes(16); $data = self::aesEncrypt($postvars['data'], $key); break; @@ -1441,19 +1441,19 @@ class DFRN /** * Fetch the author data from head or entry items * - * @param object $xpath XPath object - * @param object $context In which context should the data be searched - * @param array $importer Record of the importer user mixed with contact of the content - * @param string $element Element name from which the data is fetched - * @param bool $onlyfetch Should the data only be fetched or should it update the contact record as well - * @param string $xml optional, default empty + * @param \DOMXPath $xpath XPath object + * @param \DOMNode $context In which context should the data be searched + * @param array $importer Record of the importer user mixed with contact of the content + * @param string $element Element name from which the data is fetched + * @param bool $onlyfetch Should the data only be fetched or should it update the contact record as well + * @param string $xml optional, default empty * * @return array Relevant data of the author * @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \ImagickException * @todo Find good type-hints for all parameter */ - private static function fetchauthor($xpath, $context, $importer, $element, $onlyfetch, $xml = "") + private static function fetchauthor(\DOMXPath $xpath, \DOMNode $context, $importer, $element, $onlyfetch, $xml = "") { $author = []; $author["name"] = XML::getFirstNodeValue($xpath, $element."/atom:name/text()", $context); @@ -1609,12 +1609,14 @@ class DFRN } // "dfrn:birthday" contains the birthday converted to UTC - $birthday = XML::getFirstNodeValue($xpath, $element . "/poco:birthday/text()", $context); - - if (strtotime($birthday) > time()) { - $bd_timestamp = strtotime($birthday); - - $poco["bdyear"] = date("Y", $bd_timestamp); + $birthday = XML::getFirstNodeValue($xpath, $element . "/dfrn:birthday/text()", $context); + try { + $birthday_date = new \DateTime($birthday); + if ($birthday_date > new \DateTime()) { + $poco["bdyear"] = $birthday_date->format("Y"); + } + } catch (\Exception $e) { + // Invalid birthday } // "poco:birthday" is the birthday in the format "yyyy-mm-dd" @@ -2195,6 +2197,12 @@ class DFRN $item["title"] = XML::getFirstNodeValue($xpath, "atom:title/text()", $entry); + if (!empty($item["title"])) { + $item["post-type"] = Item::PT_ARTICLE; + } else { + $item["post-type"] = Item::PT_NOTE; + } + $item["created"] = XML::getFirstNodeValue($xpath, "atom:published/text()", $entry); $item["body"] = XML::getFirstNodeValue($xpath, "dfrn:env/text()", $entry); @@ -2239,6 +2247,8 @@ class DFRN $item['uri-id'] = ItemURI::insert(['uri' => $item['uri'], 'guid' => $item['guid']]); + $item["body"] = Item::improveSharedDataInBody($item); + Tag::storeFromBody($item['uri-id'], $item["body"]); // We store the data from "dfrn:diaspora_signature" in a different table, this is done in "Item::insert" @@ -2334,7 +2344,7 @@ class DFRN return 403; } } - + // Get the type of the item (Top level post, reply or remote reply) $entrytype = self::getEntryType($importer, $item); @@ -2426,8 +2436,8 @@ class DFRN if (in_array($entrytype, [DFRN::REPLY, DFRN::REPLY_RC])) { // Will be overwritten for sharing accounts in Item::insert - if (empty($item['post-type']) && ($entrytype == DFRN::REPLY)) { - $item['post-type'] = Item::PT_COMMENT; + if (empty($item['post-reason']) && ($entrytype == DFRN::REPLY)) { + $item['post-reason'] = Item::PR_COMMENT; } $posted_id = Item::insert($item); @@ -2588,7 +2598,7 @@ class DFRN $header["direction"] = $direction; if ($direction === Conversation::RELAY) { - $header['post-type'] = Item::PT_RELAY; + $header['post-reason'] = Item::PR_RELAY; } // Update the contact table if the data has changed