X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FProtocol%2FDFRN.php;h=1ab4d8f9e4959592cf887e9f09f651989de53455;hb=cbfc3d0c28e0b55c3ccf1ddfd321798a8c2532e8;hp=767c1f45bc5ad8cd8ebad8fa9b2a46edc68e562a;hpb=61693419e8cf571a2ad26690423d356023badc2e;p=friendica.git diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 767c1f45bc..1ab4d8f9e4 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -81,7 +81,8 @@ class DFRN return []; } - $user['importer_uid'] = $user['uid']; + $user['importer_uid'] = $user['uid']; + $user['uprvkey'] = $user['prvkey']; } else { $user = ['importer_uid' => 0, 'uprvkey' => '', 'timezone' => 'UTC', 'nickname' => '', 'sprvkey' => '', 'spubkey' => '', @@ -1163,15 +1164,17 @@ class DFRN * @return int Deliver status. Negative values mean an error. * @todo Add array type-hint for $owner, $contact */ - public static function deliver($owner, $contact, $atom, $dissolve = false) + public static function deliver($owner, $contact, $atom, $dissolve = false, $legacy_transport = false) { $a = get_app(); // At first try the Diaspora transport layer - $ret = self::transmit($owner, $contact, $atom); - if ($ret >= 200) { - logger('Delivery via Diaspora transport layer was successful with status ' . $ret); - return $ret; + if (!$dissolve && !$legacy_transport) { + $ret = self::transmit($owner, $contact, $atom); + if ($ret >= 200) { + logger('Delivery via Diaspora transport layer was successful with status ' . $ret); + return $ret; + } } $idtosend = $orig_id = (($contact['dfrn-id']) ? $contact['dfrn-id'] : $contact['issued-id']); @@ -1618,6 +1621,10 @@ class DFRN } } + if (empty($author['avatar'])) { + logger('Empty author: ' . $xml); + } + if (DBA::isResult($contact_old) && !$onlyfetch) { logger("Check if contact details for contact " . $contact_old["id"] . " (" . $contact_old["nick"] . ") have to be updated.", LOGGER_DEBUG); @@ -1747,6 +1754,10 @@ class DFRN // Update check for this field has to be done differently $datefields = ["name-date", "uri-date"]; foreach ($datefields as $field) { + // The date fields arrives as '2018-07-17T10:44:45Z' - the database return '2018-07-17 10:44:45' + // The fields have to be in the same format to be comparable, since strtotime does add timezones. + $contact[$field] = DateTimeFormat::utc($contact[$field]); + if (strtotime($contact[$field]) > strtotime($contact_old[$field])) { logger("Difference for contact " . $contact["id"] . " in field '" . $field . "'. New value: '" . $contact[$field] . "', old value '" . $contact_old[$field] . "'", LOGGER_DEBUG); $update = true; @@ -2244,6 +2255,11 @@ class DFRN if ($Blink && link_compare($Blink, System::baseUrl() . "/profile/" . $importer["nickname"])) { $author = DBA::selectFirst('contact', ['name', 'thumb', 'url'], ['id' => $item['author-id']]); + $item['id'] = $posted_id; + + $parent = Item::selectFirst(['id'], ['uri' => $item['parent-uri'], 'uid' => $importer["importer_uid"]]); + $item["parent"] = $parent['id']; + // send a notification notification( [ @@ -2394,8 +2410,11 @@ class DFRN break; case "enclosure": $enclosure = $href; - if (strlen($item["attach"])) { + + if (!empty($item["attach"])) { $item["attach"] .= ","; + } else { + $item["attach"] = ""; } $item["attach"] .= '[attach]href="' . $href . '" length="' . $length . '" type="' . $type . '" title="' . $title . '"[/attach]'; @@ -2441,7 +2460,7 @@ class DFRN } // Fetch the owner - $owner = self::fetchauthor($xpath, $entry, $importer, "dfrn:owner", true); + $owner = self::fetchauthor($xpath, $entry, $importer, "dfrn:owner", true, $xml); $owner_unknown = (isset($owner["contact-unknown"]) && $owner["contact-unknown"]); @@ -2451,7 +2470,7 @@ class DFRN $item["owner-id"] = Contact::getIdForURL($owner["link"], 0); // fetch the author - $author = self::fetchauthor($xpath, $entry, $importer, "atom:author", true); + $author = self::fetchauthor($xpath, $entry, $importer, "atom:author", true, $xml); $item["author-name"] = $author["name"]; $item["author-link"] = $author["link"];