mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
make gprobe deal with URLs, fix issue in get_actor_protocols and fix missing author issue if wall2wall comment arrives and author is not yet known
This commit is contained in:
@@ -15,19 +15,31 @@ class Gprobe {
|
||||
return;
|
||||
|
||||
$url = hex2bin($argv[1]);
|
||||
$is_webbie = false;
|
||||
$r = null;
|
||||
|
||||
if (!strpos($url, '@'))
|
||||
return;
|
||||
if (filter_var($url, FILTER_VALIDATE_EMAIL)) {
|
||||
$is_webbie = true;
|
||||
|
||||
$r = q("select * from hubloc where hubloc_addr = '%s' and hubloc_network = 'zot6' limit 1",
|
||||
dbesc($url)
|
||||
);
|
||||
$r = q("select * from hubloc where hubloc_addr = '%s' and hubloc_network = 'zot6' limit 1",
|
||||
dbesc($url)
|
||||
);
|
||||
}
|
||||
elseif (filter_var($url, FILTER_VALIDATE_URL)) {
|
||||
$r = q("select * from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6' limit 1",
|
||||
dbesc($url)
|
||||
);
|
||||
}
|
||||
|
||||
if (!$r) {
|
||||
$href = Webfinger::zot_url(punify($url));
|
||||
if ($href) {
|
||||
$zf = Zotfinger::exec($href, null);
|
||||
if ($is_webbie) {
|
||||
$url = Webfinger::zot_url(punify($url));
|
||||
}
|
||||
|
||||
if ($url) {
|
||||
$zf = Zotfinger::exec($url, null);
|
||||
}
|
||||
|
||||
if (is_array($zf) && array_path_exists('signature/signer', $zf) && $zf['signature']['signer'] === $href && intval($zf['signature']['header_valid'])) {
|
||||
Libzot::import_xchan($zf['data']);
|
||||
}
|
||||
|
||||
@@ -1618,6 +1618,7 @@ class Activity {
|
||||
$ap_hubloc = null;
|
||||
|
||||
$hublocs = self::get_actor_hublocs($url);
|
||||
$has_zot_hubloc = false;
|
||||
|
||||
if ($hublocs) {
|
||||
foreach ($hublocs as $hub) {
|
||||
@@ -1625,6 +1626,7 @@ class Activity {
|
||||
$ap_hubloc = $hub;
|
||||
}
|
||||
if ($hub['hubloc_network'] === 'zot6') {
|
||||
$has_zot_hubloc = true;
|
||||
Libzot::update_cached_hubloc($hub);
|
||||
}
|
||||
}
|
||||
@@ -1648,16 +1650,18 @@ class Activity {
|
||||
return;
|
||||
}
|
||||
|
||||
$inbox = $person_obj['inbox'];
|
||||
$inbox = $person_obj['inbox'] ?? null;
|
||||
|
||||
// invalid identity
|
||||
// invalid AP identity
|
||||
|
||||
if (!$inbox || strpos($inbox, z_root()) !== false) {
|
||||
return;
|
||||
}
|
||||
|
||||
// store the actor record in XConfig
|
||||
XConfig::Set($url, 'system', 'actor_record', $person_obj);
|
||||
|
||||
// we already store this in Activity::fetch()
|
||||
// XConfig::Set($url, 'system', 'actor_record', $person_obj);
|
||||
|
||||
$name = $person_obj['name'];
|
||||
if (!$name) {
|
||||
@@ -1814,12 +1818,12 @@ class Activity {
|
||||
// Adding zot discovery urls to the actor record will cause federation to fail with the 20-30 projects which don't accept arrays in the url field.
|
||||
|
||||
$actor_protocols = self::get_actor_protocols($person_obj);
|
||||
if (in_array('zot6', $actor_protocols)) {
|
||||
if (!$has_zot_hubloc && in_array('zot6', $actor_protocols)) {
|
||||
$zx = q("select * from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6'",
|
||||
dbesc($url)
|
||||
);
|
||||
if (!$zx && $webfinger_addr) {
|
||||
Master::Summon(['Gprobe', bin2hex($webfinger_addr)]);
|
||||
if (!$zx) {
|
||||
Master::Summon(['Gprobe', bin2hex($url)]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3796,7 +3800,7 @@ class Activity {
|
||||
return $ret;
|
||||
}
|
||||
|
||||
foreach ($tag as $t) {
|
||||
foreach ($actor['tag'] as $t) {
|
||||
if ((isset($t['type']) && $t['type'] === 'PropertyValue') &&
|
||||
(isset($t['name']) && $t['name'] === 'Protocol') &&
|
||||
(isset($t['value']) && in_array($t['value'], ['zot6', 'activitypub', 'diaspora']))
|
||||
|
||||
@@ -1227,6 +1227,16 @@ class Libzot {
|
||||
dbesc($AS->actor['id'])
|
||||
);
|
||||
|
||||
if (! $r) {
|
||||
// Author is unknown to this site. Perform channel discovery and try again.
|
||||
$z = discover_by_webbie($AS->actor['id']);
|
||||
if ($z) {
|
||||
$r = q("select hubloc_hash, hubloc_network, hubloc_url from hubloc where hubloc_id_url = '%s'",
|
||||
dbesc($AS->actor['id'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($r) {
|
||||
$r = self::zot_record_preferred($r);
|
||||
$arr['author_xchan'] = $r['hubloc_hash'];
|
||||
|
||||
Reference in New Issue
Block a user