From 016f9cb8c35ce5157fb9ad2c23a67f1204c0ac21 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Wed, 29 Jul 2015 07:32:00 +0200 Subject: [PATCH] Only suggest friendica contacts that where recently active --- include/Contact.php | 7 ++++++- include/socgraph.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/Contact.php b/include/Contact.php index 103dbe9add..1215f40e75 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -267,7 +267,12 @@ function contact_photo_menu($contact) { function random_profile() { - $r = q("select url from gcontact where url like '%%://%%/profile/%%' order by rand() limit 1"); + $r = q("SELECT `url` FROM `gcontact` WHERE `network` = '%s' + AND `last_contact` >= `last_failure` + AND `updated` > UTC_TIMESTAMP - INTERVAL 1 MONTH + ORDER BY rand() LIMIT 1", + dbesc(NETWORK_DFRN)); + if(count($r)) return dirname($r[0]['url']); return ''; diff --git a/include/socgraph.php b/include/socgraph.php index 618a9bf3ea..872b730e05 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -1211,7 +1211,7 @@ function poco_discover($complete = false) { $last_update = date("c", time() - (60 * 60 * 6)); // 24 $last_update = date("c", time() - (60 * 60 * 24)); // 24 - $r = q("SELECT `poco`, `nurl`, `url`, `network` FROM `gserver` WHERE `last_contact` > `last_failure` AND `poco` != '' AND `last_poco_query` < '%s' ORDER BY RAND()", dbesc($last_update)); + $r = q("SELECT `poco`, `nurl`, `url`, `network` FROM `gserver` WHERE `last_contact` >= `last_failure` AND `poco` != '' AND `last_poco_query` < '%s' ORDER BY RAND()", dbesc($last_update)); if ($r) foreach ($r AS $server) {