From 0f563525bd626fd7690b1dc0b9aa5075a3a1ed5e Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 6 Nov 2015 09:15:20 +0100 Subject: [PATCH] Optical adjustments for contacts/set "last_failure" when inaccessible --- include/Contact.php | 3 ++- include/socgraph.php | 12 ++++++++---- include/update_gcontact.php | 12 +++++++++++- view/theme/vier/style.css | 2 ++ 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/include/Contact.php b/include/Contact.php index 5138f276be..eeb38a5d7a 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -204,7 +204,8 @@ function get_contact_details_by_url($url, $uid = -1) { if ($r) { $profile = $r[0]; - if ($profile["addr"] == "") + if ((($profile["addr"] == "") OR ($profile["name"] == "")) AND + in_array($profile["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) proc_run('php',"include/update_gcontact.php", $profile["gid"]); } else { diff --git a/include/socgraph.php b/include/socgraph.php index c5aa08d086..69d3308986 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -1047,8 +1047,9 @@ function count_common_friends($uid,$cid) { $r = q("SELECT count(*) as `total` FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id` - where `glink`.`cid` = %d and `glink`.`uid` = %d - and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 and id != %d ) ", + WHERE `glink`.`cid` = %d AND `glink`.`uid` = %d AND + ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)) + AND `gcontact`.`nurl` IN (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 and id != %d ) ", intval($cid), intval($uid), intval($uid), @@ -1077,6 +1078,7 @@ function common_friends($uid,$cid,$start = 0,$limit=9999,$shuffle = false) { WHERE `glink`.`cid` = %d and `glink`.`uid` = %d AND `contact`.`uid` = %d AND `contact`.`self` = 0 AND `contact`.`blocked` = 0 AND `contact`.`hidden` = 0 AND `contact`.`id` != %d + AND ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)) $sql_extra LIMIT %d, %d", intval($cid), intval($uid), @@ -1134,7 +1136,8 @@ function count_all_friends($uid,$cid) { $r = q("SELECT count(*) as `total` FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id` - where `glink`.`cid` = %d and `glink`.`uid` = %d ", + where `glink`.`cid` = %d and `glink`.`uid` = %d AND + ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`))", intval($cid), intval($uid) ); @@ -1152,7 +1155,8 @@ function all_friends($uid,$cid,$start = 0, $limit = 80) { FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id` LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl` AND `contact`.`uid` = %d - WHERE `glink`.`cid` = %d AND `glink`.`uid` = %d + WHERE `glink`.`cid` = %d AND `glink`.`uid` = %d AND + ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)) ORDER BY `gcontact`.`name` ASC LIMIT %d, %d ", intval($uid), intval($cid), diff --git a/include/update_gcontact.php b/include/update_gcontact.php index ce2323f187..b5ea30a0a4 100644 --- a/include/update_gcontact.php +++ b/include/update_gcontact.php @@ -18,6 +18,7 @@ function update_gcontact_run(&$argv, &$argc){ require_once('include/pidfile.php'); require_once('include/Scrape.php'); + require_once("include/socgraph.php"); load_config('config'); load_config('system'); @@ -54,10 +55,19 @@ function update_gcontact_run(&$argv, &$argc){ if (!$r) return; + if (!in_array($r[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) + return; + $data = probe_url($r[0]["url"]); - if (!in_array($data["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) + if (!in_array($data["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) { + if ($r[0]["server_url"] != "") + poco_check_server($r[0]["server_url"], $r[0]["network"]); + + q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `id` = %d", + dbesc(datetime_convert()), intval($contact_id)); return; + } if (($data["name"] == "") AND ($r[0]['name'] != "")) $data["name"] = $r[0]['name']; diff --git a/view/theme/vier/style.css b/view/theme/vier/style.css index c48801d829..3f48d2ec3f 100644 --- a/view/theme/vier/style.css +++ b/view/theme/vier/style.css @@ -2301,6 +2301,8 @@ aside #id_password { .contact-entry-wrapper .contact-entry-photo-wrapper { float: left; margin-right: 10px; + width: 80px; + height: 80px; } .contact-entry-photo-wrapper { position: relative; -- 2.39.5