X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FProtocol%2FOStatus.php;h=dec5c4c80b021a572da0d951304a7234dcbab6bc;hb=75ec384fc3e42c77727e552751651029cd54a010;hp=b1cc4f40203d22069cd7f35f37854b895568dcfa;hpb=0cc1a07cfa98d5e6fdd273148aae2c0de76c3407;p=friendica.git diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index b1cc4f4020..dec5c4c80b 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -53,7 +53,7 @@ class OStatus * @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \ImagickException */ - private static function fetchAuthor(DOMXPath $xpath, $context, array $importer, array &$contact, $onlyfetch) + private static function fetchAuthor(DOMXPath $xpath, $context, array $importer, array &$contact = null, $onlyfetch) { $author = []; $author["author-link"] = XML::getFirstNodeValue($xpath, 'atom:author/atom:uri/text()', $context); @@ -72,7 +72,7 @@ class OStatus } $author["author-id"] = Contact::getIdForURL($author["author-link"]); - $author["contact-id"] = $contact["id"]; + $author['contact-id'] = defaults($contact, 'id', $author['author-id']); $contact = []; @@ -322,7 +322,7 @@ class OStatus * @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \ImagickException */ - private static function process($xml, array $importer, array &$contact, &$hub, $stored = false, $initialize = true) + private static function process($xml, array $importer, array &$contact = null, &$hub, $stored = false, $initialize = true) { if ($initialize) { self::$itemlist = []; @@ -1453,7 +1453,7 @@ class OStatus * @param array $owner Contact data of the poster * @param bool $show_profile Whether to show profile * - * @return object author element + * @return \DOMElement author element * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ private static function addAuthor(DOMDocument $doc, array $owner, $show_profile = true) @@ -1573,7 +1573,7 @@ class OStatus * @param bool $toplevel optional default false * @param bool $feed_mode Behave like a regular feed for users if true * - * @return object Entry element + * @return \DOMElement Entry element * @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \ImagickException */ @@ -1605,7 +1605,7 @@ class OStatus * @param DOMDocument $doc XML document * @param array $contact Array of the contact that is added * - * @return object Source element + * @return \DOMElement Source element * @throws \Exception */ private static function sourceEntry(DOMDocument $doc, array $contact) @@ -1748,7 +1748,7 @@ class OStatus * @param array $owner Contact data of the poster * @param bool $toplevel Is it for en entry element (false) or a feed entry (true)? * - * @return object Entry element with "like" + * @return \DOMElement Entry element with "like" * @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \ImagickException */ @@ -1763,19 +1763,16 @@ class OStatus $verb = NAMESPACE_ACTIVITY_SCHEMA."favorite"; self::entryContent($doc, $entry, $item, $owner, "Favorite", $verb, false); - $as_object = $doc->createElement("activity:object"); - $parent = Item::selectFirst([], ['uri' => $item["thr-parent"], 'uid' => $item["uid"]]); + if (DBA::isResult($parent)) { + $as_object = $doc->createElement("activity:object"); - if (!$parent) { - $parent = []; - } + XML::addElement($doc, $as_object, "activity:object-type", self::constructObjecttype($parent)); - XML::addElement($doc, $as_object, "activity:object-type", self::constructObjecttype($parent)); + self::entryContent($doc, $as_object, $parent, $owner, "New entry"); - self::entryContent($doc, $as_object, $parent, $owner, "New entry"); - - $entry->appendChild($as_object); + $entry->appendChild($as_object); + } self::entryFooter($doc, $entry, $item, $owner); @@ -1835,7 +1832,7 @@ class OStatus * @param array $owner Contact data of the poster * @param bool $toplevel Is it for en entry element (false) or a feed entry (true)? * - * @return object Entry element + * @return \DOMElement Entry element * @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \ImagickException */ @@ -1900,7 +1897,7 @@ class OStatus * @param bool $toplevel Is it for en entry element (false) or a feed entry (true)? * @param bool $feed_mode Behave like a regular feed for users if true * - * @return object Entry element + * @return \DOMElement Entry element * @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \ImagickException */ @@ -1976,7 +1973,7 @@ class OStatus * @brief Adds elements to the XML document * * @param DOMDocument $doc XML document - * @param object $entry Entry element where the content is added + * @param \DOMElement $entry Entry element where the content is added * @param array $item Data of the item that is to be posted * @param array $owner Contact data of the poster * @param string $title Title for the post @@ -1986,7 +1983,7 @@ class OStatus * @return void * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - private static function entryContent(DOMDocument $doc, $entry, array $item, array $owner, $title, $verb = "", $complete = true, $feed_mode = false) + private static function entryContent(DOMDocument $doc, \DOMElement $entry, array $item, array $owner, $title, $verb = "", $complete = true, $feed_mode = false) { if ($verb == "") { $verb = self::constructVerb($item);