]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/activitycontext.php
Merge branch 'nightly' into 'nightly'
[quix0rs-gnu-social.git] / lib / activitycontext.php
index cebd72ea9078573fb53e3ab2aa22b9c8af45f716..68ee08a8fbcc3ac79fea11d4339e91b742ed76e0 100644 (file)
@@ -39,6 +39,7 @@ class ActivityContext
     public $location;
     public $attention = array();    // 'uri' => 'type'
     public $conversation;
+    public $conversation_url;
     public $scope;
 
     const THR     = 'http://purl.org/syndication/thread/1.0';
@@ -48,12 +49,14 @@ class ActivityContext
     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 = 'conversation';
 
     const POINT     = 'point';
 
     const MENTIONED    = 'mentioned';
-    const CONVERSATION = 'ostatus:conversation';
 
     const ATTN_PUBLIC  = 'http://activityschema.org/collection/public';
 
@@ -72,7 +75,23 @@ class ActivityContext
 
         $this->location = $this->getLocation($element);
 
-        $this->conversation = ActivityUtils::getLink($element, self::CONVERSATION);
+        foreach ($element->getElementsByTagNameNS(self::OSTATUS, self::CONVERSATION) as $conv) {
+            if ($conv->hasAttribute('ref')) {
+                $this->conversation = $conv->getAttribute('ref');
+                if ($conv->hasAttribute('href')) {
+                    $this->conversation_url = $conv->getAttribute('href');
+                }
+            } else {
+                $this->conversation = $conv->textContent;
+            }
+            if (!empty($this->conversation)) {
+                break;
+            }
+        }
+        if (empty($this->conversation)) {
+            // fallback to the atom:link rel="ostatus:conversation" element
+            $this->conversation = ActivityUtils::getLink($element, 'ostatus:'.self::CONVERSATION);
+        }
 
         // Multiple attention links allowed
 
@@ -139,6 +158,7 @@ class ActivityContext
 
         $context['inReplyTo']    = $this->getInReplyToArray();
         $context['conversation'] = $this->conversation;
+        $context['conversation_url'] = $this->conversation_url;
 
         return array_filter($context);
     }