X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Factivitycontext.php;h=32f15c1e9f963d8afa48d4e852b2067fafce2a44;hb=b4271a3533bdf12329f27dd75452c1ef2a6ee3d1;hp=371eab3e640bce81d39677ae18b4cf9f976479a7;hpb=f4c0cff032799f695b04821265f9921ecb773ad7;p=quix0rs-gnu-social.git diff --git a/lib/activitycontext.php b/lib/activitycontext.php index 371eab3e64..32f15c1e9f 100644 --- a/lib/activitycontext.php +++ b/lib/activitycontext.php @@ -37,8 +37,7 @@ class ActivityContext public $replyToID; public $replyToUrl; public $location; - public $attention = array(); - public $attentionType = array(); + public $attention = array(); // 'uri' => 'type' public $conversation; public $scope; @@ -46,14 +45,19 @@ class ActivityContext const GEORSS = 'http://www.georss.org/georss'; const OSTATUS = 'http://ostatus.org/schema/1.0'; - const INREPLYTO = 'in-reply-to'; - const REF = 'ref'; - const HREF = 'href'; + const INREPLYTO = 'in-reply-to'; + const REF = 'ref'; + const HREF = 'href'; + + // OStatus element names with prefixes + const OBJECTTYPE = 'ostatus:object-type'; // FIXME: Undocumented! + const CONVERSATION = 'ostatus:conversation'; const POINT = 'point'; const MENTIONED = 'mentioned'; - const CONVERSATION = 'ostatus:conversation'; + + const ATTN_PUBLIC = 'http://activityschema.org/collection/public'; function __construct($element = null) { @@ -70,23 +74,28 @@ class ActivityContext $this->location = $this->getLocation($element); - $this->conversation = ActivityUtils::getLink($element, self::CONVERSATION); + $convs = $element->getElementsByTagNameNS(self::OSTATUS, self::CONVERSATION); + foreach ($convs as $conv) { + $this->conversation = $conv->textContent; + } + if (empty($this->conversation)) { + // fallback to the atom:link rel="ostatus:conversation" element + $this->conversation = ActivityUtils::getLink($element, self::CONVERSATION); + } // Multiple attention links allowed $links = $element->getElementsByTagNameNS(ActivityUtils::ATOM, ActivityUtils::LINK); - $attention = array(); for ($i = 0; $i < $links->length; $i++) { $link = $links->item($i); - $linkRel = $link->getAttribute(ActivityUtils::REL); - - if ($linkRel == self::MENTIONED) { - $attention[] = $link->getAttribute(self::HREF); + $linkRel = $link->getAttribute(ActivityUtils::REL); + $linkHref = $link->getAttribute(self::HREF); + if ($linkRel == self::MENTIONED && $linkHref !== '') { + $this->attention[$linkHref] = $link->getAttribute(ActivityContext::OBJECTTYPE); } } - $this->attention = array_unique($attention); } /** @@ -159,15 +168,10 @@ class ActivityContext { $tos = array(); - foreach ($this->attention as $attnUrl) { - if (array_key_exists($attnUrl, $this->attentionType)) { - $type = ActivityObject::canonicalType($this->attentionType[$attnUrl]); - } else { - $type = ActivityObject::canonicalType(ActivityObject::PERSON); - } + foreach ($this->attention as $attnUrl => $attnType) { $to = array( - 'objectType' => $type, - 'id' => $attnUrl + 'objectType' => $attnType, // can be empty + 'id' => $attnUrl, ); $tos[] = $to; }