Provide a fallback channel to probe for magic-auth when we have no prior communications with a site.

This will be a system channel if one exists, otherwise any channel will do. We'll try to use the first
valid channel on the site because that was probably created when the site was installed and is the
closest thing to a system channel we've got.
This commit is contained in:
friendica
2013-12-15 14:36:43 -08:00
parent 950bd72e02
commit 0272ab4cd9
6 changed files with 58 additions and 21 deletions

View File

@@ -33,21 +33,28 @@ function magic_init(&$a) {
if(! $x) {
// Somebody new? Finger them if they've never been seen here before
/*
* We have no records for, or prior communications with this hub.
* If an address was supplied, let's finger them to create a hub record.
* Otherwise we'll use the special address '[system]' which will return
* either a system channel or the first available normal channel. We don't
* really care about what channel is returned - we need the hub information
* from that response so that we can create signed auth packets destined
* for that hub.
*
*/
if($addr) {
$ret = zot_finger($addr,null);
if($ret['success']) {
$j = json_decode($ret['body'],true);
if($j)
import_xchan($j);
$ret = zot_finger((($addr) ? $addr : '[system]@' . $parsed['host']),null);
if($ret['success']) {
$j = json_decode($ret['body'],true);
if($j)
import_xchan($j);
// Now try again
// Now try again
$x = q("select * from hubloc where hubloc_url = '%s' order by hubloc_connected desc limit 1",
dbesc($basepath)
);
}
$x = q("select * from hubloc where hubloc_url = '%s' order by hubloc_connected desc limit 1",
dbesc($basepath)
);
}
}