Optical adjustments for contacts/set "last_failure" when inaccessible
This commit is contained in:
		
					parent
					
						
							
								721e7e410c
							
						
					
				
			
			
				commit
				
					
						0f563525bd
					
				
			
		
					 4 changed files with 23 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -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 {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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'];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue