aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib/ActivityStreams.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2023-03-19 13:55:18 +0000
committerMario <mario@mariovavti.com>2023-03-19 13:55:18 +0000
commit89285f1408d21091bb80d45b391ddcbe06ba8d0f (patch)
treeb2eb07d9f3d91d77f89a4565a58e6e5231b20c1c /Zotlabs/Lib/ActivityStreams.php
parent0a679e503ef367eda3085c44af103ee53869a94f (diff)
parent17c0bb2069dcfe35d3febc5bfdb3a7295f15d49c (diff)
downloadvolse-hubzilla-8.2.tar.gz
volse-hubzilla-8.2.tar.bz2
volse-hubzilla-8.2.zip
Merge branch '8.2RC'8.2
Diffstat (limited to 'Zotlabs/Lib/ActivityStreams.php')
-rw-r--r--Zotlabs/Lib/ActivityStreams.php62
1 files changed, 43 insertions, 19 deletions
diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php
index a07fdacb7..cfed53b3c 100644
--- a/Zotlabs/Lib/ActivityStreams.php
+++ b/Zotlabs/Lib/ActivityStreams.php
@@ -113,7 +113,7 @@ class ActivityStreams {
// fetch recursive or embedded activities
if ($this->obj && is_array($this->obj) && array_key_exists('object', $this->obj)) {
- $this->obj['object'] = $this->get_compound_property($this->obj['object']);
+ $this->obj['object'] = $this->get_compound_property('object', $this->obj);
}
if ($this->obj && is_array($this->obj) && isset($this->obj['actor']))
@@ -146,35 +146,58 @@ class ActivityStreams {
}
/**
+ * @brief get single property from Activity object
+ *
+ * @param string $property
+ * @param mixed $default return value if property or object not set
+ * or object is a string id which could not be fetched.
+ * @return mixed
+ */
+ public function objprop(string $property, mixed $default = false): mixed {
+ $x = $this->get_property_obj($property,$this->obj);
+ return (isset($x)) ? $x : $default;
+ }
+
+ /**
* @brief Collects all recipients.
*
- * @param string $base
+ * @param mixed $base
* @param string $namespace (optional) default empty
* @return array
*/
- function collect_recips($base = '', $namespace = '') {
- $x = [];
+ public function collect_recips(mixed $base = '', string $namespace = ''): array {
+ $result = [];
+ $tmp = [];
$fields = ['to', 'cc', 'bto', 'bcc', 'audience'];
- foreach ($fields as $f) {
- $y = $this->get_compound_property($f, $base, $namespace);
- if ($y) {
- if (!is_array($this->raw_recips)) {
- $this->raw_recips = [];
- }
-
- if (!is_array($y)) {
- $y = [$y];
- }
- $this->raw_recips[$f] = $y;
- $x = array_merge($x, $y);
+ foreach ($fields as $field) {
+ // don't expand these yet
+ $values = $this->get_property_obj($field, $base, $namespace);
+ if ($values) {
+ $values = force_array($values);
+ $tmp[$field] = $values;
+ $result = array_values(array_unique(array_merge($result, $values)));
+ }
+ // Merge the object recipients if they exist.
+ $values = $this->objprop($field);
+ if ($values) {
+ $values = force_array($values);
+ $tmp[$field] = ((isset($tmp[$field])) ? array_merge($tmp[$field], $values) : $values);
+ $result = array_values(array_unique(array_merge($result, $values)));
+ }
+ // remove duplicates
+ if (isset($tmp[$field])) {
+ $tmp[$field] = array_values(array_unique($tmp[$field]));
}
}
-// not yet ready for prime time
-// $x = $this->expand($x,$base,$namespace);
- return $x;
+ $this->raw_recips = $tmp;
+
+ // not yet ready for prime time
+ // $result = $this->expand($result,$base,$namespace);
+ return $result;
}
+
function expand($arr, $base = '', $namespace = '') {
$ret = [];
@@ -341,6 +364,7 @@ class ActivityStreams {
*/
function get_compound_property($property, $base = '', $namespace = '', $first = false) {
$x = $this->get_property_obj($property, $base, $namespace);
+
if ($this->is_url($x)) {
$y = $this->fetch_property($x);
if (is_array($y)) {