some refinement on storing the raw ap message, some comments and make sure the AS->raw is always a json string

This commit is contained in:
Mario
2022-01-27 20:27:02 +00:00
parent 67e64287af
commit 38ecff1220
2 changed files with 16 additions and 6 deletions

View File

@@ -2638,22 +2638,31 @@ class Activity {
}
}
$rawmsg = '';
$zot_rawmsg = '';
$raw_arr = [];
if (is_array($act->obj) && is_array($act->obj['attachment'])) {
$raw_arr = json_decode($act->raw, true);
// This is a zot6 packet and the raw activitypub message json
// is possible 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 (isset($a['type']) && $a['type'] === 'PropertyValue' &&
if (
isset($a['type']) && $a['type'] === 'PropertyValue' &&
isset($a['name']) && $a['name'] === 'zot.activitypub.rawmsg' &&
isset($a['value'])
) {
$rawmsg = $a['value'];
$zot_rawmsg = $a['value'];
break;
}
}
}
if ($rawmsg) {
set_iconfig($s, 'activitypub', 'rawmsg', $rawmsg, 1);
if ($zot_rawmsg) {
set_iconfig($s, 'activitypub', 'rawmsg', $zot_rawmsg, 1);
}
else {
set_iconfig($s, 'activitypub', 'rawmsg', $act->raw, 1);
}
set_iconfig($s, 'activitypub', 'recips', $act->raw_recips);

View File

@@ -40,6 +40,7 @@ class ActivityStreams {
if (is_array($string)) {
$this->data = $string;
$this->raw = json_encode($string, JSON_UNESCAPED_SLASHES);
}
else {
$this->data = json_decode($string, true);