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' => '',
}
$contact = $r[0];
- include_once 'include/security.php';
$set = PermissionSet::get($owner_id, $contact['id']);
XML::addElement($doc, $author, "dfrn:handle", $owner["addr"], $attributes);
$attributes = ["rel" => "photo", "type" => "image/jpeg",
- "media:width" => 175, "media:height" => 175, "href" => $owner['photo']];
+ "media:width" => 300, "media:height" => 300, "href" => $owner['photo']];
if (!$public || !$hidewall) {
$attributes["dfrn:updated"] = $picdate;
* @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) {
+ $curlResult = self::transmit($owner, $contact, $atom);
+ if ($curlResult >= 200) {
+ logger('Delivery via Diaspora transport layer was successful with status ' . $curlResult);
+ return $curlResult;
+ }
}
$idtosend = $orig_id = (($contact['dfrn-id']) ? $contact['dfrn-id'] : $contact['issued-id']);
logger('dfrn_deliver: ' . $url);
- $ret = Network::curl($url);
+ $curlResult = Network::curl($url);
- if (!empty($ret["errno"]) && ($ret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
+ if ($curlResult->isTimeout()) {
Contact::markForArchival($contact);
return -2; // timed out
}
- $xml = $ret['body'];
+ $xml = $curlResult->getBody();
- $curl_stat = $a->get_curl_code();
+ $curl_stat = $curlResult->getReturnCode();
if (empty($curl_stat)) {
Contact::markForArchival($contact);
return -3; // timed out
logger('dfrn_deliver: ' . "SENDING: " . print_r($postvars, true), LOGGER_DATA);
- $xml = Network::post($contact['notify'], $postvars);
+ $postResult = Network::post($contact['notify'], $postvars);
+
+ $xml = $postResult->getBody();
logger('dfrn_deliver: ' . "RECEIVED: " . $xml, LOGGER_DATA);
- $curl_stat = $a->get_curl_code();
+ $curl_stat = $postResult->getReturnCode();
if (empty($curl_stat) || empty($xml)) {
Contact::markForArchival($contact);
return -9; // timed out
}
- if (($curl_stat == 503) && stristr($a->get_curl_headers(), 'retry-after')) {
+ if (($curl_stat == 503) && stristr($postResult->getHeader(), 'retry-after')) {
Contact::markForArchival($contact);
return -10;
}
$content_type = ($public_batch ? "application/magic-envelope+xml" : "application/json");
- $xml = Network::post($dest_url, $envelope, ["Content-Type: ".$content_type]);
+ $postResult = Network::post($dest_url, $envelope, ["Content-Type: ".$content_type]);
+ $xml = $postResult->getBody();
- $curl_stat = $a->get_curl_code();
+ $curl_stat = $postResult->getReturnCode();
if (empty($curl_stat) || empty($xml)) {
logger('Empty answer from ' . $contact['id'] . ' - ' . $dest_url);
Contact::markForArchival($contact);
return -9; // timed out
}
- if (($curl_stat == 503) && (stristr($a->get_curl_headers(), 'retry-after'))) {
+ if (($curl_stat == 503) && (stristr($postResult->getHeader(), 'retry-after'))) {
Contact::markForArchival($contact);
return -10;
}
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(
[
if (Item::exists($condition)) {
return false;
}
+
+ // The owner of an activity must be the author
+ $item["owner-name"] = $item["author-name"];
+ $item["owner-link"] = $item["author-link"];
+ $item["owner-avatar"] = $item["author-avatar"];
+ $item["owner-id"] = $item["author-id"];
} else {
$is_like = false;
}
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]';
/// @todo Do we really need this check for HTML elements? (It was copied from the old function)
if ((strpos($item['body'], '<') !== false) && (strpos($item['body'], '>') !== false)) {
- $base_url = get_app()->get_baseurl();
+ $base_url = get_app()->getBaseURL();
$item['body'] = reltoabs($item['body'], $base_url);
$item['body'] = html2bb_video($item['body']);
logger('auto_redir: ' . $r[0]['name'] . ' ' . $sec, LOGGER_DEBUG);
$dest = (($url) ? '&destination_url=' . $url : '');
- goaway($r[0]['poll'] . '?dfrn_id=' . $dfrn_id
+ System::externalRedirect($r[0]['poll'] . '?dfrn_id=' . $dfrn_id
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest);
}