diff options
author | Mike Macgirvin <mike@macgirvin.com> | 2010-10-27 15:50:44 -0700 |
---|---|---|
committer | Mike Macgirvin <mike@macgirvin.com> | 2010-10-27 15:50:44 -0700 |
commit | f01e8743fcfd26cc44a6c808418773520c77fe84 (patch) | |
tree | 4d6de6d2bb36ae1188a65e5f413d742e071c7eb5 | |
parent | 78351df785aea429619845254c3fe2ddd1983969 (diff) | |
download | volse-hubzilla-f01e8743fcfd26cc44a6c808418773520c77fe84.tar.gz volse-hubzilla-f01e8743fcfd26cc44a6c808418773520c77fe84.tar.bz2 volse-hubzilla-f01e8743fcfd26cc44a6c808418773520c77fe84.zip |
match schemeless activities per the latest activity spec
-rw-r--r-- | boot.php | 8 | ||||
-rw-r--r-- | include/items.php | 12 |
2 files changed, 14 insertions, 6 deletions
@@ -1288,3 +1288,11 @@ function logger($msg) { @file_put_contents($logfile, datetime_convert() . ':' . session_id() . ' ' . $msg . "\n", FILE_APPEND); return; }} + + +if(! function_exists('activity_match')) { +function activity_match($haystack,$needle) { + if(($haystack === $needle) || (($basename($needle) === $haystack) && strstr($needle,NAMESPACE_ACTIVITY_SCHEMA))) + return true; + return false; +}}
\ No newline at end of file diff --git a/include/items.php b/include/items.php index f11bebf50..52d0bc5b6 100644 --- a/include/items.php +++ b/include/items.php @@ -301,7 +301,7 @@ function get_atom_elements($feed,$item) { $rawactor = $item->get_item_tags(NAMESPACE_ACTIVITY, 'actor'); - if($rawactor && $rawactor[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'] === ACTIVITY_OBJ_PERSON) { + if($rawactor && activity_match($rawactor[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'],ACTIVITY_OBJ_PERSON)) { $base = $rawactor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']; if($base && count($base)) { foreach($base as $link) { @@ -333,7 +333,7 @@ function get_atom_elements($feed,$item) { $rawactor = $feed->get_feed_tags(NAMESPACE_ACTIVITY, 'subject'); - if($rawactor && $rawactor[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'] === ACTIVITY_OBJ_PERSON) { + if($rawactor && activity_match($rawactor[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'],ACTIVITY_OBJ_PERSON)) { $base = $rawactor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']; if($base && count($base)) { @@ -482,7 +482,7 @@ function item_store($arr) { $arr['gravity'] = intval($arr['gravity']); elseif($arr['parent-uri'] == $arr['uri']) $arr['gravity'] = 0; - elseif($arr['verb'] == ACTIVITY_POST) + elseif(activity_match($arr['verb'],ACTIVITY_POST)) $arr['gravity'] = 6; if(! x($arr,'type')) @@ -891,7 +891,7 @@ function consume_feed($xml,$importer,$contact, &$hub) { $datarray['parent-uri'] = $parent_uri; $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $contact['id']; - if(($datarray['verb'] === ACTIVITY_LIKE) || ($datarray['verb'] === ACTIVITY_DISLIKE)) { + if((activity_match($datarray['verb'],ACTIVITY_LIKE)) || (activity_match($datarray['verb'],ACTIVITY_DISLIKE))) { $datarray['type'] = 'activity'; $datarray['gravity'] = GRAVITY_LIKE; } @@ -922,12 +922,12 @@ function consume_feed($xml,$importer,$contact, &$hub) { } $datarray = get_atom_elements($feed,$item); - if($datarray['verb'] === ACTIVITY_FOLLOW) { + if(activity_match($datarray['verb'],ACTIVITY_FOLLOW)) { logger('consume-feed: New follower'); new_follower($importer,$contact,$datarray,$item); return; } - if($datarray['verb'] === ACTIVITY_UNFOLLOW) { + if(activity_match($datarray['verb'],ACTIVITY_UNFOLLOW)) { lose_follower($importer,$contact,$datarray,$item); return; } |