aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-01-30 15:33:57 +0000
committerMario <mario@mariovavti.com>2022-01-30 15:33:57 +0000
commitd619192b22484fa21700b5c6d2ce5d029897ee76 (patch)
tree2d02cae066ebbd1377590c0f3b5720d3924710af /Zotlabs/Lib
parent46eff1c937af05664c5e62e86909e8b4709966f9 (diff)
downloadvolse-hubzilla-d619192b22484fa21700b5c6d2ce5d029897ee76.tar.gz
volse-hubzilla-d619192b22484fa21700b5c6d2ce5d029897ee76.tar.bz2
volse-hubzilla-d619192b22484fa21700b5c6d2ce5d029897ee76.zip
attach iconfig to the activity and adjust ap raw message retrieval to handle both cases. also add a possibility to manually redeliver single hubs for debuging
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r--Zotlabs/Lib/Activity.php42
1 files changed, 33 insertions, 9 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 74a146345..881bd04e2 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -660,11 +660,11 @@ class Activity {
return $ret;
}
- static function encode_attachment($item) {
+ static function encode_attachment($item, $iconfig = false) {
$ret = [];
- if (array_key_exists('attach', $item)) {
+ if (!$iconfig && array_key_exists('attach', $item)) {
$atts = ((is_array($item['attach'])) ? $item['attach'] : json_decode($item['attach'], true));
if ($atts) {
foreach ($atts as $att) {
@@ -677,7 +677,7 @@ class Activity {
}
}
}
- if (array_key_exists('iconfig', $item) && is_array($item['iconfig'])) {
+ if ($iconfig && array_key_exists('iconfig', $item) && is_array($item['iconfig'])) {
foreach ($item['iconfig'] as $att) {
if ($att['sharing']) {
$value = ((is_string($att['v']) && preg_match('|^a:[0-9]+:{.*}$|s', $att['v'])) ? unserialize($att['v']) : $att['v']);
@@ -930,6 +930,11 @@ class Activity {
$ret['tag'] = $t;
}
+ $a = self::encode_attachment($i, true);
+ if ($a) {
+ $ret['attachment'] = $a;
+ }
+
// addressing madness
$public = (($i['item_private']) ? false : true);
@@ -2638,28 +2643,47 @@ class Activity {
}
}
- $zot_rawmsg = '';
+ $ap_rawmsg = '';
$raw_arr = [];
$raw_arr = json_decode($act->raw, true);
// This is a zot6 packet and the raw activitypub message json
// is possibly available in the attachement.
- if (array_key_exists('signed', $raw_arr) && is_array($act->obj) && is_array($act->obj['attachment'])) {
- foreach($act->obj['attachment'] as $a) {
+ if (array_key_exists('signed', $raw_arr) && is_array($act->data['attachment'])) {
+ foreach($act->data['attachment'] as $a) {
if (
isset($a['type']) && $a['type'] === 'PropertyValue' &&
isset($a['name']) && $a['name'] === 'zot.activitypub.rawmsg' &&
isset($a['value'])
) {
- $zot_rawmsg = $a['value'];
+ $ap_rawmsg = $a['value'];
break;
}
}
}
- if ($zot_rawmsg) {
- set_iconfig($s, 'activitypub', 'rawmsg', $zot_rawmsg, 1);
+ // old style: can be removed after most hubs are on 7.0.2
+ if (!$ap_rawmsg && array_key_exists('signed', $raw_arr) && is_array($act->obj) && is_array($act->obj['attachment'])) {
+ foreach($act->obj['attachment'] as $a) {
+ if (
+ isset($a['type']) && $a['type'] === 'propertyvalue' &&
+ isset($a['name']) && $a['name'] === 'zot.activitypub.rawmsg' &&
+ isset($a['value'])
+ ) {
+ $ap_rawmsg = $a['value'];
+ break;
+ }
+ }
+ }
+
+ if (!$ap_rawmsg && $response_activity) {
+ $ap_rawmsg = json_encode($act->data, JSON_UNESCAPED_SLASHES);
+ }
+ // end old style
+
+ if ($ap_rawmsg) {
+ set_iconfig($s, 'activitypub', 'rawmsg', $ap_rawmsg, 1);
}
else {
set_iconfig($s, 'activitypub', 'rawmsg', $act->raw, 1);