Merge branch 'master' of https://github.com/friendica/red
This commit is contained in:
commit
a512f54d93
@ -117,14 +117,25 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// attempt network auto-discovery
|
|
||||||
|
|
||||||
$my_perms = 0;
|
$my_perms = 0;
|
||||||
$their_perms = 0;
|
$their_perms = 0;
|
||||||
$xchan_hash = '';
|
$xchan_hash = '';
|
||||||
|
|
||||||
|
$r = q("select * from xchan where xchan_hash = '%s' limit 1",
|
||||||
|
dbesc($url)
|
||||||
|
);
|
||||||
|
|
||||||
|
if(! $r) {
|
||||||
|
// attempt network auto-discovery
|
||||||
|
if(strpos($url,'@')) {
|
||||||
|
$r = discover_by_webbie($url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($r) {
|
||||||
|
$xchan_hash = $url;
|
||||||
|
$their_perms = 0;
|
||||||
|
$my_perms = PERMS_W_STREAM|PERMS_W_MAIL;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -822,11 +822,13 @@ function email_send($addr, $subject, $headers, $item) {
|
|||||||
function discover_by_webbie($webbie) {
|
function discover_by_webbie($webbie) {
|
||||||
require_once('library/HTML5/Parser.php');
|
require_once('library/HTML5/Parser.php');
|
||||||
|
|
||||||
|
$webbie = strtolower($webbie);
|
||||||
|
|
||||||
$x = webfinger_rfc7033($webbie);
|
$x = webfinger_rfc7033($webbie);
|
||||||
if($x && array_key_exists('links',$x) && $x['links']) {
|
if($x && array_key_exists('links',$x) && $x['links']) {
|
||||||
foreach($x['links'] as $link) {
|
foreach($x['links'] as $link) {
|
||||||
if(array_key_exists('rel',$link) && $link['rel'] == 'http://purl.org/zot/protocol') {
|
if(array_key_exists('rel',$link) && $link['rel'] == 'http://purl.org/zot/protocol') {
|
||||||
logger('discover_by_webbie: zot found for ' . $webbie);
|
logger('discover_by_webbie: zot found for ' . $webbie, LOGGER_DEBUG);
|
||||||
$z = z_fetch_url($link['href']);
|
$z = z_fetch_url($link['href']);
|
||||||
if($z['success']) {
|
if($z['success']) {
|
||||||
$j = json_decode($z['body'],true);
|
$j = json_decode($z['body'],true);
|
||||||
@ -881,23 +883,87 @@ function discover_by_webbie($webbie) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($diaspora && $diaspora_base && $diaspora_guid) {
|
if($diaspora && $diaspora_base && $diaspora_guid) {
|
||||||
$notify = $diaspora_base . 'receive/users/' . $diaspora_guid;
|
$guid = $diaspora_guid;
|
||||||
$batch = $diaspora_base . 'receive/public' ;
|
$diaspora_base = trim($diaspora_base,'/');
|
||||||
if(strpos($webbie,'@'))
|
|
||||||
|
$notify = $diaspora_base . '/receive';
|
||||||
|
|
||||||
|
// // '/users/' . $diaspora_guid;
|
||||||
|
// $batch = $diaspora_base . '/receive/public' ;
|
||||||
|
if(strpos($webbie,'@')) {
|
||||||
$addr = str_replace('acct:', '', $webbie);
|
$addr = str_replace('acct:', '', $webbie);
|
||||||
|
$hostname = substr($webbie,strpos($webbie,'@')+1);
|
||||||
|
}
|
||||||
$network = 'diaspora';
|
$network = 'diaspora';
|
||||||
|
// until we get a dfrn layer, we'll use diaspora protocols for Friendica,
|
||||||
|
// but give it a different network so we can go back and fix these when we get proper support.
|
||||||
|
// It really should be just 'friendica' but we also want to distinguish
|
||||||
|
// between Friendica sites that we can use D* protocols with and those we can't.
|
||||||
|
// Some Friendica sites will have Diaspora disabled.
|
||||||
if($dfrn)
|
if($dfrn)
|
||||||
$network = 'f-diaspora';
|
$network = 'friendica-over-diaspora';
|
||||||
if($hcard)
|
if($hcard) {
|
||||||
$vcard = scrape_vcard($hcard);
|
$vcard = scrape_vcard($hcard);
|
||||||
|
$vcard['nick'] = substr($webbie,0,strpos($webbie,'@'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$r = q("select * from xchan where xchan_hash = '%s' limit 1",
|
||||||
|
dbesc($webbie)
|
||||||
|
);
|
||||||
|
if($r)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
$r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_pubkey, xchan_addr, xchan_url, xchan_name, xchan_network, xchan_instance_url, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ",
|
||||||
|
dbesc($addr),
|
||||||
|
dbesc($guid),
|
||||||
|
dbesc($pubkey),
|
||||||
|
dbesc($addr),
|
||||||
|
dbesc($profile),
|
||||||
|
dbesc($vcard['fn']),
|
||||||
|
dbesc($network),
|
||||||
|
dbesc(z_root()),
|
||||||
|
dbesc(datetime_convert())
|
||||||
|
);
|
||||||
|
|
||||||
|
$r = q("select * from hubloc where hubloc_hash = '%s' limit 1",
|
||||||
|
dbesc($webbie)
|
||||||
|
);
|
||||||
|
if(! $r) {
|
||||||
|
$r = q("insert into hubloc ( hubloc_guid, hubloc_hash, hubloc_addr, hubloc_network, hubloc_url, hubloc_host, hubloc_callback, hubloc_updated ) values ('%s','%s','%s','%s','%s','%s','%s','%s')",
|
||||||
|
dbesc($guid),
|
||||||
|
dbesc($addr),
|
||||||
|
dbesc($addr),
|
||||||
|
dbesc($network),
|
||||||
|
dbesc(trim($diaspora_base,'/')),
|
||||||
|
dbesc($hostname),
|
||||||
|
dbesc($notify),
|
||||||
|
dbesc(datetime_convert())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$photos = import_profile_photo($vcard['photo'],$addr);
|
||||||
|
$r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s' limit 1",
|
||||||
|
dbesc(datetime_convert('UTC','UTC',$arr['photo_updated'])),
|
||||||
|
dbesc($photos[0]),
|
||||||
|
dbesc($photos[1]),
|
||||||
|
dbesc($photos[2]),
|
||||||
|
dbesc($photos[3]),
|
||||||
|
dbesc($addr)
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/*
|
||||||
$vcard['fn'] = notags($vcard['fn']);
|
$vcard['fn'] = notags($vcard['fn']);
|
||||||
$vcard['nick'] = str_replace(' ','',notags($vcard['nick']));
|
$vcard['nick'] = str_replace(' ','',notags($vcard['nick']));
|
||||||
|
|
||||||
$result['name'] = $vcard['fn'];
|
$result['name'] = $vcard['fn'];
|
||||||
$result['nick'] = $vcard['nick'];
|
$result['nick'] = $vcard['nick'];
|
||||||
|
$result['guid'] = $guid;
|
||||||
$result['url'] = $profile;
|
$result['url'] = $profile;
|
||||||
|
$result['hostname'] = $hostname;
|
||||||
$result['addr'] = $addr;
|
$result['addr'] = $addr;
|
||||||
$result['batch'] = $batch;
|
$result['batch'] = $batch;
|
||||||
$result['notify'] = $notify;
|
$result['notify'] = $notify;
|
||||||
@ -914,15 +980,21 @@ function discover_by_webbie($webbie) {
|
|||||||
logger('probe_url: ' . print_r($result,true), LOGGER_DEBUG);
|
logger('probe_url: ' . print_r($result,true), LOGGER_DEBUG);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
/*
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Sample Diaspora result.
|
||||||
|
|
||||||
Array
|
Array
|
||||||
(
|
(
|
||||||
[name] => Mike Macgirvin
|
[name] => Mike Macgirvin
|
||||||
[nick] => MikeMacgirvin
|
[nick] => macgirvin
|
||||||
|
[guid] => a9174a618f8d269a
|
||||||
[url] => https://joindiaspora.com/u/macgirvin
|
[url] => https://joindiaspora.com/u/macgirvin
|
||||||
|
[hostname] => joindiaspora.com
|
||||||
[addr] => macgirvin@joindiaspora.com
|
[addr] => macgirvin@joindiaspora.com
|
||||||
[batch] => https://joindiaspora.com/receive/public
|
[batch] =>
|
||||||
[notify] => https://joindiaspora.com/receive/users/a9174a618f8d269a
|
[notify] => https://joindiaspora.com/receive
|
||||||
[poll] => https://joindiaspora.com/public/macgirvin.atom
|
[poll] => https://joindiaspora.com/public/macgirvin.atom
|
||||||
[request] =>
|
[request] =>
|
||||||
[confirm] =>
|
[confirm] =>
|
||||||
|
Reference in New Issue
Block a user