diff options
author | Mario <mario@mariovavti.com> | 2021-12-18 19:09:15 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2021-12-18 19:09:15 +0000 |
commit | 5aefe0b74f00b199a1f690c1787d26e833d3a2d5 (patch) | |
tree | 11f0ffaeb43bae7e73e2947381198f2b2262ad21 /Zotlabs/Lib/Libsync.php | |
parent | 9c79b5be77da7e5626ca7f0671fe5ed9b1f9c955 (diff) | |
download | volse-hubzilla-5aefe0b74f00b199a1f690c1787d26e833d3a2d5.tar.gz volse-hubzilla-5aefe0b74f00b199a1f690c1787d26e833d3a2d5.tar.bz2 volse-hubzilla-5aefe0b74f00b199a1f690c1787d26e833d3a2d5.zip |
guest token xchan_network = "token" and remove permission checks since the guest tokens are now added to the abook automatically
Diffstat (limited to 'Zotlabs/Lib/Libsync.php')
-rw-r--r-- | Zotlabs/Lib/Libsync.php | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/Zotlabs/Lib/Libsync.php b/Zotlabs/Lib/Libsync.php index 23573e837..ef10e8046 100644 --- a/Zotlabs/Lib/Libsync.php +++ b/Zotlabs/Lib/Libsync.php @@ -384,19 +384,42 @@ class Libsync { // This relies on the undocumented behaviour that red sites send xchan info with the abook // and import_author_xchan will look them up on all federated networks - if ($abook['abook_xchan'] && $abook['xchan_addr']) { + $found = false; + if ($abook['abook_xchan'] && $abook['xchan_addr'] && (! in_array($abook['xchan_network'], [ 'token', 'unknown' ]))) { $h = Libzot::get_hublocs($abook['abook_xchan']); - if (!$h) { + if ($h) { + $found = true; + } + else { $xhash = import_author_xchan(encode_item_xchan($abook)); - if (!$xhash) { + if ($xhash) { + $found = true; + } + else { logger('Import of ' . $abook['xchan_addr'] . ' failed.'); - continue; } } } + if (!$found && !in_array($abook['xchan_network'], ['zot6', 'activitypub', 'diaspora'])) { + // just import the record. + $xc = []; + foreach ($abook as $k => $v) { + if (strpos($k,'xchan_') === 0) { + $xc[$k] = $v; + } + } + $r = q("select * from xchan where xchan_hash = '%s'", + dbesc($xc['xchan_hash']) + ); + if (! $r) { + xchan_store_lowlevel($xc); + } + } + + foreach ($abook as $k => $v) { - if (in_array($k, $disallowed) || (strpos($k, 'abook') !== 0)) { + if (in_array($k, $disallowed) || (strpos($k, 'abook_') !== 0)) { continue; } if (!in_array($k, $fields)) { @@ -410,6 +433,13 @@ class Libsync { if (array_key_exists('abook_instance', $clean) && $clean['abook_instance'] && strpos($clean['abook_instance'], z_root()) === false) { $clean['abook_not_here'] = 1; + + // guest pass or access token - don't try to probe since it is one-way + // we are relying on the undocumented behaviour that the abook record also contains the xchan + if ($abook['xchan_network'] === 'token') { + $clean['abook_instance'] .= ','; + $clean['abook_instance'] .= z_root(); + } } |