convert randprof to use chanlink_hash() instead of chanlink_url() and filter sys channels by xchan.xchan_system instead of xchan_addr != sys@%

This commit is contained in:
git-marijus 2017-06-03 10:13:42 +02:00
parent 56f3b12171
commit c4ed04fc82
2 changed files with 7 additions and 7 deletions

View File

@ -8,7 +8,7 @@ class Randprof extends \Zotlabs\Web\Controller {
function init() { function init() {
$x = random_profile(); $x = random_profile();
if($x) if($x)
goaway(chanlink_url($x)); goaway(chanlink_hash($x));
/** FIXME this doesn't work at the moment as a fallback */ /** FIXME this doesn't work at the moment as a fallback */
goaway(z_root() . '/profile'); goaway(z_root() . '/profile');

View File

@ -415,9 +415,9 @@ function random_profile() {
for($i = 0; $i < $retryrandom; $i++) { for($i = 0; $i < $retryrandom; $i++) {
$r = q("select xchan_url from xchan left join hubloc on hubloc_hash = xchan_hash where xchan_addr not like '%s' and xchan_hidden = 0 and hubloc_connected > %s - interval %s order by $randfunc limit 1", $r = q("select xchan_url, xchan_hash from xchan left join hubloc on hubloc_hash = xchan_hash where xchan_hidden = 0 and xchan_system = 0 and hubloc_connected > %s - interval %s order by $randfunc limit 1",
dbesc('sys@%'), db_utcnow(),
db_utcnow(), db_quoteinterval('30 day') db_quoteinterval('30 day')
); );
if(!$r) return ''; // Couldn't get a random channel if(!$r) return ''; // Couldn't get a random channel
@ -425,12 +425,12 @@ function random_profile() {
if($checkrandom) { if($checkrandom) {
$x = z_fetch_url($r[0]['xchan_url']); $x = z_fetch_url($r[0]['xchan_url']);
if($x['success']) if($x['success'])
return $r[0]['xchan_url']; return $r[0]['xchan_hash'];
else else
logger('Random channel turned out to be bad.'); logger('Random channel turned out to be bad.');
} }
else { else {
return $r[0]['xchan_url']; return $r[0]['xchan_hash'];
} }
} }