diff options
-rw-r--r-- | lib/activity.php | 16 | ||||
-rw-r--r-- | plugins/OStatus/classes/Ostatus_profile.php | 40 |
2 files changed, 46 insertions, 10 deletions
diff --git a/lib/activity.php b/lib/activity.php index dcd079c7a..20e501acb 100644 --- a/lib/activity.php +++ b/lib/activity.php @@ -799,20 +799,24 @@ class ActivityObject $obj->type = ActivityObject::PERSON; // @fixme guess better - $obj->title = ActivityUtils::childContent($el, ActivityObject::TITLE, self::RSS); - $obj->link = ActivityUtils::childContent($el, ActivityUtils::LINK, self::RSS); - $obj->id = ActivityUtils::getLink($el, self::SELF); + $obj->title = ActivityUtils::childContent($el, ActivityObject::TITLE, Activity::RSS); + $obj->link = ActivityUtils::childContent($el, ActivityUtils::LINK, Activity::RSS); + $obj->id = ActivityUtils::getLink($el, Activity::SELF); - $desc = ActivityUtils::childContent($el, self::DESCRIPTION, self::RSS); + if (empty($obj->id)) { + $obj->id = $obj->link; + } + + $desc = ActivityUtils::childContent($el, Activity::DESCRIPTION, Activity::RSS); if (!empty($desc)) { $obj->content = htmlspecialchars_decode($desc, ENT_QUOTES); } - $imageEl = ActivityUtils::child($el, self::IMAGE, self::RSS); + $imageEl = ActivityUtils::child($el, Activity::IMAGE, Activity::RSS); if (!empty($imageEl)) { - $obj->avatarLinks[] = ActivityUtils::childContent($imageEl, self::URL, self::RSS); + $obj->avatarLinks[] = ActivityUtils::childContent($imageEl, Activity::URL, Activity::RSS); } return $obj; diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index bff6ff209..4f449a44d 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -787,9 +787,20 @@ class Ostatus_profile extends Memcached_DataObject throw new FeedSubNoHubException(); } - // Try to get a profile from the feed activity:subject + $feedEl = $discover->root; - $feedEl = $discover->feed->documentElement; + if ($feedEl->tagName == 'feed') { + return self::ensureAtomFeed($feedEl, $hints); + } else if ($feedEl->tagName == 'channel') { + return self::ensureRssChannel($feedEl, $hints); + } else { + throw new FeedSubBadXmlException($feeduri); + } + } + + public static function ensureAtomFeed($feedEl, $hints) + { + // Try to get a profile from the feed activity:subject $subject = ActivityUtils::child($feedEl, Activity::SUBJECT, Activity::SPEC); @@ -837,6 +848,17 @@ class Ostatus_profile extends Memcached_DataObject throw new FeedSubException("Can't find enough profile information to make a feed."); } + public static function ensureRssChannel($feedEl, $hints) + { + // @fixme we should check whether this feed has elements + // with different <author> or <dc:creator> elements, and... I dunno. + // Do something about that. + + $obj = ActivityObject::fromRssChannel($feedEl); + + return self::ensureActivityObjectProfile($obj, $hints); + } + /** * Download and update given avatar image * @@ -1299,9 +1321,19 @@ class Ostatus_profile extends Memcached_DataObject return $hints['nickname']; } - // Try the definitive ID + // Try the profile url (like foo.example.com or example.com/user/foo) - $nickname = self::nicknameFromURI($object->id); + $profileUrl = ($object->link) ? $object->link : $hints['profileurl']; + + if (!empty($profileUrl)) { + $nickname = self::nicknameFromURI($profileUrl); + } + + // Try the URI (may be a tag:, http:, acct:, ... + + if (empty($nickname)) { + $nickname = self::nicknameFromURI($object->id); + } // Try a Webfinger if one was passed (way) down |