reduce the likelihood that a given channel will have 30-40 valid hublocs with the same hubloc_url.
This commit is contained in:
parent
e3f5c4458b
commit
64b467ea98
@ -18,33 +18,20 @@ function zot_new_uid($channel_nick) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @function zot_get_hublocs($hash)
|
||||||
* Given an array of zot hashes, return all distinct hubs
|
* Given a zot hash, return all distinct hubs
|
||||||
* If primary is true, return only primary hubs
|
* @param string $hash - xchan_hash
|
||||||
* Result is ordered by url to assist in batching.
|
* @retuns array
|
||||||
* Return only the first primary hub as there should only be one.
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function zot_get_hubloc($arr,$primary = false) {
|
function zot_get_hublocs($hash) {
|
||||||
|
|
||||||
$tmp = '';
|
$ret = q("select * from hubloc where hubloc_hash = '%s' group by hubloc_url ",
|
||||||
|
dbesc($hash)
|
||||||
if(is_array($arr)) {
|
);
|
||||||
foreach($arr as $e) {
|
|
||||||
if(strlen($tmp))
|
|
||||||
$tmp .= ',';
|
|
||||||
$tmp .= "'" . dbesc($e) . "'" ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(! strlen($tmp))
|
|
||||||
return array();
|
|
||||||
|
|
||||||
$sql_extra = (($primary) ? " and hubloc_flags & " . intval(HUBLOC_FLAGS_PRIMARY) : "" );
|
|
||||||
$limit = (($primary) ? " limit 1 " : "");
|
|
||||||
return q("select * from hubloc where hubloc_hash in ( $tmp ) $sql_extra order by hubloc_url $limit");
|
|
||||||
|
|
||||||
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -164,7 +164,7 @@ function zfinger_init(&$a) {
|
|||||||
|
|
||||||
$ret['locations'] = array();
|
$ret['locations'] = array();
|
||||||
|
|
||||||
$x = zot_get_hubloc(array($e['channel_hash']));
|
$x = zot_get_hublocs($e['channel_hash']);
|
||||||
if($x && count($x)) {
|
if($x && count($x)) {
|
||||||
foreach($x as $hub) {
|
foreach($x as $hub) {
|
||||||
if(! ($hub['hubloc_flags'] & HUBLOC_FLAGS_UNVERIFIED)) {
|
if(! ($hub['hubloc_flags'] & HUBLOC_FLAGS_UNVERIFIED)) {
|
||||||
|
Reference in New Issue
Block a user