aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-08-17 16:53:14 -0700
committerzotlabs <mike@macgirvin.com>2017-08-17 16:53:14 -0700
commit65a320c5091c6aaac86b0de661b5eac8a0e9521d (patch)
tree8cadd9e2916927f92f2ccef432c8031e5316c89c
parentb0f2c22000eecbb76e7666fb9e67635dcbb36a64 (diff)
downloadvolse-hubzilla-65a320c5091c6aaac86b0de661b5eac8a0e9521d.tar.gz
volse-hubzilla-65a320c5091c6aaac86b0de661b5eac8a0e9521d.tar.bz2
volse-hubzilla-65a320c5091c6aaac86b0de661b5eac8a0e9521d.zip
move activitystreams parser back to core; we will eventually need it in core utilities
-rw-r--r--Zotlabs/Lib/ActivityStreams.php (renamed from Zotlabs/Lib/ActivityStreams2.php)32
1 files changed, 20 insertions, 12 deletions
diff --git a/Zotlabs/Lib/ActivityStreams2.php b/Zotlabs/Lib/ActivityStreams.php
index 904782bf7..2b610c7a4 100644
--- a/Zotlabs/Lib/ActivityStreams2.php
+++ b/Zotlabs/Lib/ActivityStreams.php
@@ -2,8 +2,7 @@
namespace Zotlabs\Lib;
-
-class ActivityStreams2 {
+class ActivityStreams {
public $data;
public $valid = false;
@@ -21,11 +20,17 @@ class ActivityStreams2 {
}
if($this->is_valid()) {
- $this->id = $this->get_property_obj('id');
- $this->type = $this->get_primary_type();
- $this->actor = $this->get_compound_property('actor');
- $this->obj = $this->get_compound_property('object');
- $this->tgt = $this->get_compound_property('target');
+ $this->id = $this->get_property_obj('id');
+ $this->type = $this->get_primary_type();
+ $this->actor = $this->get_compound_property('actor');
+ $this->obj = $this->get_compound_property('object');
+ $this->tgt = $this->get_compound_property('target');
+ $this->origin = $this->get_compound_property('origin');
+
+ if(($this->type === 'Note') && (! $this->obj)) {
+ $this->obj = $this->data;
+ $this->type = 'Create';
+ }
}
}
@@ -34,16 +39,19 @@ class ActivityStreams2 {
}
function get_property_obj($property,$base = '') {
- if(! $base) {
- $base = $this->data;
- }
- return $base[$property];
+ $base = (($base) ? $base : $this->data);
+ return ((array_key_exists($property,$base)) ? $base[$property] : null);
}
function fetch_property($url) {
$redirects = 0;
+ if(! check_siteallowed($url)) {
+ logger('blacklisted: ' . $url);
+ return null;
+ }
+
$x = z_fetch_url($url,true,$redirects,
- ['headers' => [ 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"']]);
+ ['headers' => [ 'Accept: application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"']]);
if($x['success'])
return json_decode($x['body'],true);
return null;