mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 01:35:12 +00:00
couple of identity matcher fixes
This commit is contained in:
parent
eb225639c6
commit
3fc23a34b6
4 changed files with 60 additions and 7 deletions
|
@ -625,7 +625,6 @@ class Notifier implements DaemonInterface
|
|||
}
|
||||
|
||||
logger('notifier: recipients (may be delivered to more if public): ' . print_r($recip_list, true), LOGGER_DEBUG);
|
||||
|
||||
// Now we have collected recipients (except for external mentions, @FIXME)
|
||||
// Let's reduce this to a set of hubs; checking that the site is not dead.
|
||||
|
||||
|
@ -661,7 +660,6 @@ class Notifier implements DaemonInterface
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! $hubs) {
|
||||
logger('notifier: no hubs', LOGGER_NORMAL, LOG_NOTICE);
|
||||
return;
|
||||
|
@ -865,9 +863,7 @@ class Notifier implements DaemonInterface
|
|||
if ($parentItem['replyto']) {
|
||||
$ptr = unserialise($parentItem['replyto']);
|
||||
if (is_string($ptr)) {
|
||||
if (ActivityStreams::is_url($ptr)) {
|
||||
$audience[] = $ptr;
|
||||
}
|
||||
$audience[] = $ptr;
|
||||
} elseif (is_array($ptr)) {
|
||||
foreach ($ptr as $rto) {
|
||||
if (is_string($rto) && ActivityStreams::is_url($rto)) {
|
||||
|
|
|
@ -2407,9 +2407,10 @@ class Activity
|
|||
$ap_hubloc = null;
|
||||
|
||||
$hublocs = self::get_actor_hublocs($url);
|
||||
|
||||
if ($hublocs) {
|
||||
foreach ($hublocs as $hub) {
|
||||
if ($hub['hubloc_network'] === 'activitypub') {
|
||||
if (in_array($hub['hubloc_network'], ['activitypub', 'apnomadic'])) {
|
||||
$ap_hubloc = $hub;
|
||||
}
|
||||
if (in_array($hub['hubloc_network'],['zot6','nomad'])) {
|
||||
|
@ -2847,6 +2848,15 @@ class Activity
|
|||
return;
|
||||
}
|
||||
|
||||
$hublocs = self::get_actor_hublocs($portableId);
|
||||
if ($hublocs) {
|
||||
foreach ($hublocs as $hubloc) {
|
||||
if (in_array($hubloc['hubloc_network'], ['zot6', 'nomad'])) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
foreach ($gateways as $gateway) {
|
||||
|
||||
|
@ -4650,6 +4660,20 @@ class Activity
|
|||
public static function find_best_identity($xchan)
|
||||
{
|
||||
|
||||
$actorId = new ActorId($xchan);
|
||||
if ($actorId->getType() === ActorId::ACTORID_TYPE_DIDKEY) {
|
||||
$query = q("select * from xchan where xchan_epubkey = '%s'",
|
||||
dbesc(str_replace('did:key:', '', $actorId->getId()))
|
||||
);
|
||||
if ($query) {
|
||||
foreach ($query as $test) {
|
||||
if (in_array($test['xchan_network'], ['zot6', 'nomad'])) {
|
||||
return $test['xchan_hash'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$r = q(
|
||||
"select hubloc_hash, hubloc_network from hubloc where hubloc_id_url = '%s' and hubloc_deleted = 0 order by hubloc_id desc",
|
||||
dbesc($xchan)
|
||||
|
@ -5159,6 +5183,26 @@ class Activity
|
|||
}
|
||||
}
|
||||
|
||||
// Edge case. Communications from an apnomadic URL, but they also have a zot6 or nomad hubloc record
|
||||
// with a traditional hubloc_id_url. Pull out the xchan_hash of the zot6/nomad identity and use it
|
||||
// instead of the URL that was passed.
|
||||
|
||||
$actorId = new ActorId($url);
|
||||
if ($actorId->getType() === ActorId::ACTORID_TYPE_DIDKEY) {
|
||||
$ekey = str_replace('did:key:', '', $actorId->getId());
|
||||
$query = q("select * from xchan where epubkey = '%s'",
|
||||
dbesc($ekey)
|
||||
);
|
||||
if ($query) {
|
||||
foreach ($query as $test) {
|
||||
if (in_array($test['xchan_network'], ['nomad', 'zot6'])) {
|
||||
$url = $test['xchan_hash'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return match (trim($options_arr[0])) {
|
||||
'activitypub' => q(
|
||||
"select * from hubloc left join xchan on hubloc_hash = xchan_hash where hubloc_hash = '%s' $sql_options order by hubloc_id DESC ",
|
||||
|
|
|
@ -117,6 +117,12 @@ class ActivityStreams
|
|||
if (!$this->replyto) {
|
||||
$this->replyto = $this->get_property_obj('replyTo');
|
||||
}
|
||||
if ($this->replyto) {
|
||||
$actorId = new ActorId($this->replyto);
|
||||
if ($actorId->getType() !== ActorId::ACTORID_TYPE_URL) {
|
||||
$this->replyto = Activity::find_best_identity($actorId->getId());
|
||||
}
|
||||
}
|
||||
|
||||
$this->edsig = $this->get_compound_property('proof');
|
||||
if ($this->edsig) {
|
||||
|
|
|
@ -145,7 +145,14 @@ class Inbox extends Controller
|
|||
// if the sender has the ability to send messages over zot/nomad, ignore messages sent via activitypub
|
||||
// as observer aware features and client side markup will be unavailable
|
||||
|
||||
$test = Activity::get_actor_hublocs($hsig['portable_id'], 'all,not_deleted');
|
||||
if (str_starts_with($hsig['portable_id'], 'did:key:')) {
|
||||
$test = q("select xchan_network as hubloc_network from xchan where xchan_epubkey = '%s'",
|
||||
dbesc(str_replace('did:key:', '', $hsig['portable_id']))
|
||||
);
|
||||
}
|
||||
else {
|
||||
$test = Activity::get_actor_hublocs($hsig['portable_id'], 'all,not_deleted');
|
||||
}
|
||||
if ($test) {
|
||||
foreach ($test as $t) {
|
||||
if (in_array($t['hubloc_network'], ['zot6', 'nomad'])) {
|
||||
|
|
Loading…
Reference in a new issue