summaryrefslogtreecommitdiff
path: root/lib/activityutils.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-12-17 13:09:37 -0500
committerEvan Prodromou <evan@status.net>2010-12-17 13:09:37 -0500
commit16fc5314fbc4d7542e45c75af787ef906ae359ae (patch)
tree29c2377d9abda9e57171332d630a7cf656de40cb /lib/activityutils.php
parent39804809dd67d72926d985f31164e6df334ee387 (diff)
move code to get an author object for a feed to a library from Ostatus_profile
Diffstat (limited to 'lib/activityutils.php')
-rw-r--r--lib/activityutils.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/activityutils.php b/lib/activityutils.php
index c462514c4..11befc0ed 100644
--- a/lib/activityutils.php
+++ b/lib/activityutils.php
@@ -270,4 +270,51 @@ class ActivityUtils
return false;
}
+
+ static function getFeedAuthor($feedEl)
+ {
+ // Try the feed author
+
+ $author = ActivityUtils::child($feedEl, Activity::AUTHOR, Activity::ATOM);
+
+ if (!empty($author)) {
+ return new ActivityObject($author);
+ }
+
+ // Try old and deprecated activity:subject
+
+ $subject = ActivityUtils::child($feedEl, Activity::SUBJECT, Activity::SPEC);
+
+ if (!empty($subject)) {
+ return new ActivityObject($subject);
+ }
+
+ // Sheesh. Not a very nice feed! Let's try fingerpoken in the
+ // entries.
+
+ $entries = $feedEl->getElementsByTagNameNS(Activity::ATOM, 'entry');
+
+ if (!empty($entries) && $entries->length > 0) {
+
+ $entry = $entries->item(0);
+
+ // Try the author
+
+ $author = ActivityUtils::child($entry, Activity::AUTHOR, Activity::ATOM);
+
+ if (!empty($author)) {
+ return new ActivityObject($author);
+ }
+
+ // Try the (deprecated) activity:actor
+
+ $actor = ActivityUtils::child($entry, Activity::ACTOR, Activity::SPEC);
+
+ if (!empty($actor)) {
+ return new ActivityObject($actor);
+ }
+ }
+
+ return null;
+ }
}