aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib/ActivityStreams.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-08-27 21:46:10 -0700
committerzotlabs <mike@macgirvin.com>2017-08-27 21:46:10 -0700
commit6385d11b5489d3d3cf0c8200e689276824af148e (patch)
tree7b817542f436940d55aa2322314c3d06fccddf23 /Zotlabs/Lib/ActivityStreams.php
parentd0d0a2df3a4011cf92c34293d21deee4412ac4a1 (diff)
downloadvolse-hubzilla-6385d11b5489d3d3cf0c8200e689276824af148e.tar.gz
volse-hubzilla-6385d11b5489d3d3cf0c8200e689276824af148e.tar.bz2
volse-hubzilla-6385d11b5489d3d3cf0c8200e689276824af148e.zip
AS2: recipient collection
Diffstat (limited to 'Zotlabs/Lib/ActivityStreams.php')
-rw-r--r--Zotlabs/Lib/ActivityStreams.php43
1 files changed, 42 insertions, 1 deletions
diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php
index 3bbe3b190..686f4a140 100644
--- a/Zotlabs/Lib/ActivityStreams.php
+++ b/Zotlabs/Lib/ActivityStreams.php
@@ -14,6 +14,8 @@ class ActivityStreams {
public $origin = null;
public $owner = null;
+ public $recips = null;
+
function __construct($string) {
$this->data = json_decode($string,true);
@@ -28,7 +30,7 @@ class ActivityStreams {
$this->obj = $this->get_compound_property('object');
$this->tgt = $this->get_compound_property('target');
$this->origin = $this->get_compound_property('origin');
- $this->owner = $this->get_compound_property('owner','','http://purl.org/zot/protocol');
+ $this->recips = $this->collect_recips();
if(($this->type === 'Note') && (! $this->obj)) {
$this->obj = $this->data;
@@ -41,6 +43,45 @@ class ActivityStreams {
return $this->valid;
}
+ function collect_recips($base = '',$namespace = 'https://www.w3.org/ns/activitystreams') {
+ $x = [];
+ $fields = [ 'to','cc','bto','bcc','audience'];
+ foreach($fields as $f) {
+ $y = $this->get_compound_property($f,$base,$namespace);
+ if($y)
+ $x = array_merge($x,$y);
+ }
+// not yet ready for prime time
+// $x = $this->expand($x,$base,$namespace);
+ return $x;
+ }
+
+ function expand($arr,$base = '',$namespace = 'https://www.w3.org/ns/activitystreams') {
+ $ret = [];
+
+ // right now use a hardwired recursion depth of 5
+
+ for($z = 0; $z < 5; $z ++) {
+ if(is_array($arr) && $arr) {
+ foreach($arr as $a) {
+ if(is_array($a)) {
+ $ret[] = $a;
+ }
+ else {
+ $x = $this->get_compound_property($a,$base,$namespace);
+ if($x) {
+ $ret = array_merge($ret,$x);
+ }
+ }
+ }
+ }
+ }
+
+ // @fixme de-duplicate
+
+ return $ret;
+ }
+
function get_namespace($base,$namespace) {
$key = null;