X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Factivity.php;h=5d6230c6df623ac9000d76aa92d6d9dac1929622;hb=ecf32880254666860335d4fe2a96909cd592d3e8;hp=bd1d5d56c044ec289cbd2ec1304381b77c6d5c65;hpb=11a86d046e30a7fe76d242c5dd2e54ed9a808ab2;p=quix0rs-gnu-social.git diff --git a/lib/activity.php b/lib/activity.php index bd1d5d56c0..5d6230c6df 100644 --- a/lib/activity.php +++ b/lib/activity.php @@ -53,6 +53,7 @@ class Activity { const SPEC = 'http://activitystrea.ms/spec/1.0/'; const SCHEMA = 'http://activitystrea.ms/schema/1.0/'; + const MEDIA = 'http://purl.org/syndication/atommedia'; const VERB = 'verb'; const OBJECT = 'object'; @@ -85,7 +86,7 @@ class Activity public $actor; // an ActivityObject public $verb; // a string (the URL) - public $object; // an ActivityObject + public $objects = array(); // an array of ActivityObjects public $target; // an ActivityObject public $context; // an ActivityObject public $time; // Time of the activity @@ -161,12 +162,15 @@ class Activity // XXX: do other implied stuff here } - $objectEl = $this->_child($entry, self::OBJECT); + $objectEls = $entry->getElementsByTagNameNS(self::SPEC, self::OBJECT); - if (!empty($objectEl)) { - $this->object = new ActivityObject($objectEl); + if ($objectEls->length > 0) { + for ($i = 0; $i < $objectEls->length; $i++) { + $objectEl = $objectEls->item($i); + $this->objects[] = new ActivityObject($objectEl); + } } else { - $this->object = new ActivityObject($entry); + $this->objects[] = new ActivityObject($entry); } $actorEl = $this->_child($entry, self::ACTOR); @@ -175,6 +179,17 @@ class Activity $this->actor = new ActivityObject($actorEl); + // Cliqset has bad actor IDs (just nickname of user). We + // work around it by getting the author data and using its + // id instead + + if (!preg_match('/^\w+:/', $this->actor->id)) { + $authorEl = ActivityUtils::child($entry, 'author'); + if (!empty($authorEl)) { + $authorObj = new ActivityObject($authorEl); + $this->actor->id = $authorObj->id; + } + } } else if (!empty($feed) && $subjectEl = $this->_child($feed, self::SUBJECT)) { @@ -280,8 +295,8 @@ class Activity } } - $this->object = new ActivityObject($item); - $this->context = new ActivityContext($item); + $this->objects[] = new ActivityObject($item); + $this->context = new ActivityContext($item); } /** @@ -339,8 +354,10 @@ class Activity $xs->element('activity:verb', null, $this->verb); - if ($this->object) { - $xs->raw($this->object->asString()); + if (!empty($this->objects)) { + foreach($this->objects as $object) { + $xs->raw($object->asString()); + } } if ($this->target) {