X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2FContact.php;h=920ec3c2b406f91054815e6927a09734a5c1106d;hb=abe31d7e60b2c6640abf799f807b8258bed10ab8;hp=59c40599bc5d161c3fead85bff66e70491eb4176;hpb=b95d34f9dbb7dd46d059ebff36b38084ddcb2282;p=friendica.git diff --git a/include/Contact.php b/include/Contact.php index 59c40599bc..920ec3c2b4 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -46,6 +46,10 @@ function user_remove($uid) { // q("DELETE FROM `user` WHERE `uid` = %d", intval($uid)); q("UPDATE `user` SET `account_removed` = 1, `account_expires_on` = UTC_TIMESTAMP() WHERE `uid` = %d", intval($uid)); proc_run('php', "include/notifier.php", "removeme", $uid); + + // Send an update to the directory + proc_run('php', "include/directory.php", $r[0]['url']); + if($uid == local_user()) { unset($_SESSION['authenticated']); unset($_SESSION['uid']); @@ -109,7 +113,7 @@ function terminate_friendship($user,$self,$contact) { '$photo' => $self['photo'], '$thumb' => $self['thumb'], '$published' => datetime_convert('UTC','UTC', 'now', ATOM_TIME), - '$item_id' => 'urn:X-dfrn:' . $a->get_hostname() . ':unfollow:' . random_string(), + '$item_id' => 'urn:X-dfrn:' . $a->get_hostname() . ':unfollow:' . get_guid(32), '$title' => '', '$type' => 'text', '$content' => t('stopped following'), @@ -263,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 ''; @@ -312,19 +321,22 @@ function get_contact($url, $uid = 0) { intval($uid)); if (!$contact) - $contact = q("SELECT `id`, `avatar-date` FROM `contact` WHERE `alias` = '%s' AND `uid` = %d", + $contact = q("SELECT `id`, `avatar-date` FROM `contact` WHERE `alias` IN ('%s', '%s') AND `uid` = %d", + dbesc($url), dbesc(normalise_link($url)), intval($uid)); if ($contact) { $contactid = $contact[0]["id"]; - //$update_photo = ($contact[0]['avatar-date'] < datetime_convert('','','now -2 days')); - $update_photo = ($contact[0]['avatar-date'] < datetime_convert('','','now -12 hours')); + // Update the contact every 7 days + $update_photo = ($contact[0]['avatar-date'] < datetime_convert('','','now -7 days')); + //$update_photo = ($contact[0]['avatar-date'] < datetime_convert('','','now -12 hours')); if (!$update_photo) return($contactid); - } + } elseif ($uid != 0) + return 0; if (!count($data)) $data = probe_url($url);