X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FProtocol%2FDiaspora.php;h=65b84f3cd40a14136b40069a29601e962e130a14;hb=a9a85849f4a7656f9057ea0bc8b1aaad61d5943f;hp=bd66f487ac597f2f4d4083f7f1463cf0c8b43b8d;hpb=dad58e0f6fdff5e1ff8a002bb31119a38f08268b;p=friendica.git diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index bd66f487ac..65b84f3cd4 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -9,6 +9,7 @@ */ namespace Friendica\Protocol; +use Friendica\Content\Text\BBCode; use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\L10n; @@ -355,6 +356,9 @@ class Diaspora } $children = $basedom->children('https://joindiaspora.com/protocol'); + $inner_aes_key = null; + $inner_iv = null; + if ($children->header) { $public = true; $author_link = str_replace('acct:', '', $children->header->author_id); @@ -393,6 +397,7 @@ class Diaspora // figure out where in the DOM tree our data is hiding + $base = null; if ($dom->provenance->data) { $base = $dom->provenance; } elseif ($dom->env->data) { @@ -638,8 +643,6 @@ class Diaspora return false; } - $first_child = $data->getName(); - // Is this the new or the old version? if ($data->getName() == "XML") { $oldXML = true; @@ -668,6 +671,8 @@ class Diaspora $fields = new SimpleXMLElement("<".$type."/>"); $signed_data = ""; + $author_signature = null; + $parent_author_signature = null; foreach ($element->children() as $fieldname => $entry) { if ($oldXML) { @@ -796,14 +801,11 @@ class Diaspora */ public static function personByHandle($handle) { - $r = q( - "SELECT * FROM `fcontact` WHERE `network` = '%s' AND `addr` = '%s' LIMIT 1", - dbesc(NETWORK_DIASPORA), - dbesc($handle) - ); - if ($r) { - $person = $r[0]; - logger("In cache " . print_r($r, true), LOGGER_DEBUG); + $update = false; + + $person = dba::selectFirst('fcontact', [], ['network' => NETWORK_DIASPORA, 'addr' => $handle]); + if (DBM::is_result($person)) { + logger("In cache " . print_r($person, true), LOGGER_DEBUG); // update record occasionally so it doesn't get stale $d = strtotime($person["updated"]." +00:00"); @@ -816,7 +818,7 @@ class Diaspora } } - if (!$person || $update) { + if (!DBM::is_result($person) || $update) { logger("create or refresh", LOGGER_DEBUG); $r = Probe::uri($handle, NETWORK_DIASPORA); @@ -827,6 +829,7 @@ class Diaspora $person = $r; } } + return $person; } @@ -1057,7 +1060,7 @@ class Diaspora //} // We don't seem to like that person - if ($contact["blocked"] || $contact["readonly"] || $contact["archive"]) { + if ($contact["blocked"] || $contact["readonly"]) { // Maybe blocked, don't accept. return false; // We are following this person? @@ -1374,26 +1377,23 @@ class Diaspora /** * @brief returns contact details * - * @param array $contact The default contact if the person isn't found - * @param array $person The record of the person - * @param int $uid The user id + * @param array $def_contact The default contact if the person isn't found + * @param array $person The record of the person + * @param int $uid The user id * * @return array * 'cid' => contact id * 'network' => network type */ - private static function authorContactByUrl($contact, $person, $uid) + private static function authorContactByUrl($def_contact, $person, $uid) { - $r = q( - "SELECT `id`, `network`, `url` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1", - dbesc(normalise_link($person["url"])), - intval($uid) - ); - if ($r) { - $cid = $r[0]["id"]; - $network = $r[0]["network"]; - } else { + $condition = ['nurl' => normalise_link($person["url"]), 'uid' => $uid]; + $contact = dba::selectFirst('contact', ['id', 'network'], $condition); + if (DBM::is_result($contact)) { $cid = $contact["id"]; + $network = $contact["network"]; + } else { + $cid = $def_contact["id"]; $network = NETWORK_DIASPORA; } @@ -2842,23 +2842,7 @@ class Diaspora continue; } - // Currently we don't have a central deletion function that we could use in this case. - // The function "item_drop" doesn't work for that case - dba::update( - 'item', - [ - 'deleted' => true, - 'title' => '', - 'body' => '', - 'edited' => DateTimeFormat::utcNow(), - 'changed' => DateTimeFormat::utcNow()], - ['id' => $item["id"]] - ); - - // Delete the thread - if it is a starting post and not a comment - if ($target_type != 'Comment') { - delete_thread($item["id"], $item["parent-uri"]); - } + Item::deleteById($item["id"]); logger("Deleted target ".$target_guid." (".$item["id"].") from user ".$item["uid"]." parent: ".$item["parent"], LOGGER_DEBUG); @@ -3197,7 +3181,7 @@ class Diaspora * * @return int Result of the transmission */ - public static function transmit($owner, $contact, $envelope, $public_batch, $queue_run = false, $guid = "") + public static function transmit($owner, $contact, $envelope, $public_batch, $queue_run = false, $guid = "", $no_queue = false) { $a = get_app(); @@ -3240,30 +3224,20 @@ class Diaspora logger("transmit: ".$logid."-".$guid." returns: ".$return_code); if (!$return_code || (($return_code == 503) && (stristr($a->get_curl_headers(), "retry-after")))) { - logger("queue message"); - - $r = q( - "SELECT `id` FROM `queue` WHERE `cid` = %d AND `network` = '%s' AND `content` = '%s' AND `batch` = %d LIMIT 1", - intval($contact["id"]), - dbesc(NETWORK_DIASPORA), - dbesc($envelope), - intval($public_batch) - ); - if ($r) { - logger("add_to_queue ignored - identical item already in queue"); - } else { + if (!$no_queue) { + logger("queue message"); // queue message for redelivery - Queue::add($contact["id"], NETWORK_DIASPORA, $envelope, $public_batch); - - // The message could not be delivered. We mark the contact as "dead" - Contact::markForArchival($contact); + Queue::add($contact["id"], NETWORK_DIASPORA, $envelope, $public_batch, $guid); } + + // The message could not be delivered. We mark the contact as "dead" + Contact::markForArchival($contact); } elseif (($return_code >= 200) && ($return_code <= 299)) { // We successfully delivered a message, the contact is alive Contact::unmarkForArchival($contact); } - return(($return_code) ? $return_code : (-1)); + return $return_code ? $return_code : -1; } @@ -3310,7 +3284,7 @@ class Diaspora $envelope = self::buildMessage($msg, $owner, $contact, $owner['uprvkey'], $contact['pubkey'], $public_batch); if ($spool) { - Queue::add($contact['id'], NETWORK_DIASPORA, $envelope, $public_batch); + Queue::add($contact['id'], NETWORK_DIASPORA, $envelope, $public_batch, $guid); return true; } else { $return_code = self::transmit($owner, $contact, $envelope, $public_batch, false, $guid); @@ -3767,6 +3741,7 @@ class Diaspora $parent = $p[0]; $target_type = ($parent["uri"] === $parent["parent-uri"] ? "Post" : "Comment"); + $positive = null; if ($item['verb'] === ACTIVITY_LIKE) { $positive = "true"; } elseif ($item['verb'] === ACTIVITY_DISLIKE) { @@ -4207,6 +4182,10 @@ class Diaspora $small = System::baseUrl().'/photo/custom/50/' .$profile['uid'].'.jpg'; $searchable = (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false'); + $dob = null; + $about = null; + $location = null; + $tags = null; if ($searchable === 'true') { $dob = ''; @@ -4219,7 +4198,7 @@ class Diaspora } $about = $profile['about']; - $about = strip_tags(bbcode($about)); + $about = strip_tags(BBCode::convert($about)); $location = Profile::formatLocation($profile); $tags = '';