X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FProtocol%2FDFRN.php;h=797a3973b46e4c9254bc3dc0079b6cc70b7da82a;hb=98dd4e889a280da83b21934ded58d292bd92b63b;hp=df974729bab07261d01cfe7b8645d167727391cc;hpb=852d148efdfb737ea192b296cf07055194ac7706;p=friendica.git diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index df974729ba..797a3973b4 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -51,6 +51,7 @@ use Friendica\Util\Crypto; use Friendica\Util\DateTimeFormat; use Friendica\Util\Images; use Friendica\Util\Network; +use Friendica\Util\Proxy; use Friendica\Util\Strings; use Friendica\Util\XML; @@ -618,7 +619,8 @@ class DFRN XML::addElement($doc, $author, "dfrn:handle", $owner["addr"], $attributes); $attributes = ["rel" => "photo", "type" => "image/jpeg", - "media:width" => 300, "media:height" => 300, "href" => $owner['photo']]; + "media:width" => Proxy::PIXEL_SMALL, "media:height" => Proxy::PIXEL_SMALL, + "href" => Contact::getAvatarUrlForId($owner['id'], Proxy::SIZE_SMALL, $owner['updated'])]; if (!$public || !$hide) { $attributes["dfrn:updated"] = $picdate; @@ -899,7 +901,7 @@ class DFRN $entry->setAttribute("xmlns:statusnet", ActivityNamespace::STATUSNET); } - $body = Post\Media::addAttachmentsToBody($item['uri-id'], $item['body']); + $body = Post\Media::addAttachmentsToBody($item['uri-id'], $item['body'] ?? ''); if ($item['private'] == Item::PRIVATE) { $body = Item::fixPrivatePhotos($body, $owner['uid'], $item, $cid); @@ -1272,7 +1274,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 +1443,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 +1611,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"