From 8250cb1e8daefc67b5bdfe966a95aee197145012 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 26 Jan 2022 09:35:08 +0000 Subject: always store the raw message --- Zotlabs/Lib/Activity.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'Zotlabs/Lib/Activity.php') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 2de25885a..09aaeae25 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -2639,11 +2639,7 @@ class Activity { } set_iconfig($s, 'activitypub', 'recips', $act->raw_recips); - - $parent = (($s['parent_mid'] && $s['parent_mid'] === $s['mid']) ? true : false); - if ($parent) { - set_iconfig($s, 'activitypub', 'rawmsg', $act->raw, 1); - } + set_iconfig($s, 'activitypub', 'rawmsg', $act->raw, 1); $hookinfo = [ 'act' => $act, -- cgit v1.2.3 From 7a1c6b64c2dd03adc005e43586b2f76d9cea855f Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 26 Jan 2022 13:02:51 +0000 Subject: $act->raw will not always hold the AP raw message. Look for it in iconfig. --- Zotlabs/Lib/Activity.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Lib/Activity.php') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 09aaeae25..3ba8339f6 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -2638,8 +2638,23 @@ class Activity { } } + if (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']) + ) { + $rawmsg = $a['value']; + break; + } + } + } + + if ($rawmsg) { + set_iconfig($s, 'activitypub', 'rawmsg', $rawmsg, 1); + } + set_iconfig($s, 'activitypub', 'recips', $act->raw_recips); - set_iconfig($s, 'activitypub', 'rawmsg', $act->raw, 1); $hookinfo = [ 'act' => $act, -- cgit v1.2.3 From 67e64287afc6c41c80065614f7beebe8a552a76b Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 26 Jan 2022 19:28:04 +0000 Subject: missing define of variable, remove deprecated zot-info and ofeed from webfinger --- Zotlabs/Lib/Activity.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Zotlabs/Lib/Activity.php') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 3ba8339f6..33183de76 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -2638,6 +2638,8 @@ class Activity { } } + $rawmsg = ''; + if (is_array($act->obj) && is_array($act->obj['attachment'])) { foreach($act->obj['attachment'] as $a) { if (isset($a['type']) && $a['type'] === 'PropertyValue' && -- cgit v1.2.3 From 38ecff1220a6b11261ba9f11edbefb5e5bfaa53b Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 27 Jan 2022 20:27:02 +0000 Subject: some refinement on storing the raw ap message, some comments and make sure the AS->raw is always a json string --- Zotlabs/Lib/Activity.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'Zotlabs/Lib/Activity.php') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 33183de76..4a5d42026 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -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); -- cgit v1.2.3 From 0aa67ad7f9f8aac8691962171a9d69e0a521a15f Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 27 Jan 2022 20:34:21 +0000 Subject: typo --- Zotlabs/Lib/Activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib/Activity.php') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 4a5d42026..ec79e32fe 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -2644,7 +2644,7 @@ class Activity { $raw_arr = json_decode($act->raw, true); // This is a zot6 packet and the raw activitypub message json - // is possible available in the attachement. + // 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 ( -- cgit v1.2.3 From 36e244060c3593f918676a61c788743a04555d9a Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 27 Jan 2022 21:51:56 +0000 Subject: escape_tags() will turn & to & and there for mess up the xchan hash --- Zotlabs/Lib/Activity.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'Zotlabs/Lib/Activity.php') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index ec79e32fe..d999d5ecf 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -1748,7 +1748,7 @@ class Activity { // update existing xchan record q("update xchan set xchan_name = '%s', xchan_guid = '%s', xchan_pubkey = '%s', xchan_addr = '%s', xchan_network = 'activitypub', xchan_name_date = '%s' where xchan_hash = '%s'", dbesc(escape_tags($name)), - dbesc(escape_tags($url)), + dbesc($url), dbesc(escape_tags($pubkey)), dbesc(escape_tags($webfinger_addr)), dbescdate(datetime_convert()), @@ -1757,13 +1757,13 @@ class Activity { // update existing hubloc record q("update hubloc set hubloc_guid = '%s', hubloc_addr = '%s', hubloc_network = 'activitypub', hubloc_url = '%s', hubloc_host = '%s', hubloc_callback = '%s', hubloc_updated = '%s', hubloc_id_url = '%s' where hubloc_hash = '%s'", - dbesc(escape_tags($url)), + dbesc($url), dbesc(escape_tags($webfinger_addr)), dbesc(escape_tags($baseurl)), dbesc(escape_tags($hostname)), dbesc(escape_tags($inbox)), dbescdate(datetime_convert()), - dbesc(escape_tags($profile)), + dbesc($profile), dbesc($url) ); } @@ -1772,8 +1772,8 @@ class Activity { xchan_store_lowlevel( [ - 'xchan_hash' => escape_tags($url), - 'xchan_guid' => escape_tags($url), + 'xchan_hash' => $url, + 'xchan_guid' => $url, 'xchan_pubkey' => escape_tags($pubkey), 'xchan_addr' => $webfinger_addr, 'xchan_url' => escape_tags($profile), @@ -1785,8 +1785,8 @@ class Activity { hubloc_store_lowlevel( [ - 'hubloc_guid' => escape_tags($url), - 'hubloc_hash' => escape_tags($url), + 'hubloc_guid' => $url, + 'hubloc_hash' => $url, 'hubloc_addr' => $webfinger_addr, 'hubloc_network' => 'activitypub', 'hubloc_url' => escape_tags($baseurl), @@ -1794,7 +1794,7 @@ class Activity { 'hubloc_callback' => escape_tags($inbox), 'hubloc_updated' => datetime_convert(), 'hubloc_primary' => 1, - 'hubloc_id_url' => escape_tags($profile) + 'hubloc_id_url' => $profile ] ); } -- cgit v1.2.3 From 0da69cb9c772dce33496a9ea642fab89195277a3 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 27 Jan 2022 21:56:13 +0000 Subject: do not use escape_tags() for inbox --- Zotlabs/Lib/Activity.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Zotlabs/Lib/Activity.php') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index d999d5ecf..74a146345 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -1759,9 +1759,9 @@ class Activity { q("update hubloc set hubloc_guid = '%s', hubloc_addr = '%s', hubloc_network = 'activitypub', hubloc_url = '%s', hubloc_host = '%s', hubloc_callback = '%s', hubloc_updated = '%s', hubloc_id_url = '%s' where hubloc_hash = '%s'", dbesc($url), dbesc(escape_tags($webfinger_addr)), - dbesc(escape_tags($baseurl)), - dbesc(escape_tags($hostname)), - dbesc(escape_tags($inbox)), + dbesc($baseurl), + dbesc($hostname), + dbesc($inbox), dbescdate(datetime_convert()), dbesc($profile), dbesc($url) @@ -1789,9 +1789,9 @@ class Activity { 'hubloc_hash' => $url, 'hubloc_addr' => $webfinger_addr, 'hubloc_network' => 'activitypub', - 'hubloc_url' => escape_tags($baseurl), - 'hubloc_host' => escape_tags($hostname), - 'hubloc_callback' => escape_tags($inbox), + 'hubloc_url' => $baseurl, + 'hubloc_host' => $hostname, + 'hubloc_callback' => $inbox, 'hubloc_updated' => datetime_convert(), 'hubloc_primary' => 1, 'hubloc_id_url' => $profile -- cgit v1.2.3