X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Ffollow.php;h=d5651ea39e79a397f9cf42eae9c98979d0291ad2;hb=e59377d96b09c8d7bc0090ce2cea0e99517c7d9b;hp=7ac9a50c315ca2c4fee0ef0203ba49b68132f2c9;hpb=c16f314ec348205f4741e0171335168720e652d2;p=friendica.git diff --git a/mod/follow.php b/mod/follow.php index 7ac9a50c31..d5651ea39e 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -50,6 +50,14 @@ function follow_post(&$a) { if($hcard) { $vcard = scrape_vcard($hcard); + + // Google doesn't use absolute url in profile photos + + if((x($vcard,'photo')) && substr($vcard['photo'],0,1) == '/') { + $h = parse_url($hcard); + if($h) + $vcard['photo'] = $h['scheme'] . '://' . $h['host'] . $vcard['photo']; + } } if(! $profile) @@ -61,24 +69,33 @@ function follow_post(&$a) { if(x($vcard,'nick')) $vcard['fn'] = $vcard['nick']; - if(! ((x($vcard['fn'])) && ($poll) && ($notify) && ($profile))) { + logger('follow: poll=' . $poll . ' notify=' . $notify . ' profile=' . $profile . ' vcard=' . print_r($vcard,true)); + + if(! ((x($vcard['fn'])) && ($poll) && ($profile))) { notice( t('The profile address specified does not provide adequate information.') . EOL); goaway($_SESSION['return_url']); - } + } + + if(! $notify) { + notice( t('Limited profile. This person will be unable to receive direct/personal notifications from you.') . EOL); + } if(! x($vcard,'photo')) $vcard['photo'] = $a->get_baseurl() . '/images/default-profile.jpg' ; // check if we already have a contact + // the poll url is more reliable than the profile url, as we may have + // indirect links or webfinger links $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `poll` = '%s' LIMIT 1", intval(local_user()), dbesc($poll) ); - if($r) { + + if(count($r)) { // update contact if($r[0]['rel'] == REL_VIP) { - q("UPDATE `contact` SET `rel` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", + q("UPDATE `contact` SET `rel` = %d , `readonly` = 0 WHERE `id` = %d AND `uid` = %d LIMIT 1", intval(REL_BUD), intval($r[0]['id']), intval(local_user()) @@ -102,10 +119,12 @@ function follow_post(&$a) { intval(REL_FAN) ); } + $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1", dbesc($profile), intval(local_user()) ); + if(! count($r)) { notice( t('Unable to retrieve contact information.') . EOL); goaway($_SESSION['return_url']); @@ -117,49 +136,19 @@ function follow_post(&$a) { require_once("Photo.php"); - $photo_failure = false; - - $filename = basename($vcard['photo']); - $img_str = fetch_url($vcard['photo'],true); - $img = new Photo($img_str); - if($img->is_valid()) { - - $img->scaleImageSquare(175); - - $hash = photo_new_resource(); - - $r = $img->store(local_user(), $contact_id, $hash, $filename, t('Contact Photos'), 4 ); - - if($r === false) - $photo_failure = true; - - $img->scaleImage(80); - - $r = $img->store(local_user(), $contact_id, $hash, $filename, t('Contact Photos'), 5 ); - - if($r === false) - $photo_failure = true; - - $photo = $a->get_baseurl() . '/photo/' . $hash . '-4.jpg'; - $thumb = $a->get_baseurl() . '/photo/' . $hash . '-5.jpg'; - } - else - $photo_failure = true; - - if($photo_failure) { - $photo = $a->get_baseurl() . '/images/default-profile.jpg'; - $thumb = $a->get_baseurl() . '/images/default-profile-sm.jpg'; - } + $photos = import_profile_photo($vcard['photo'],local_user(),$contact_id); $r = q("UPDATE `contact` SET `photo` = '%s', - `thumb` = '%s', + `thumb` = '%s', + `micro` = '%s', `name-date` = '%s', `uri-date` = '%s', `avatar-date` = '%s' WHERE `id` = %d LIMIT 1 ", - dbesc($photo), - dbesc($thumb), + dbesc($photos[0]), + dbesc($photos[1]), + dbesc($photos[2]), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(datetime_convert()), @@ -192,8 +181,11 @@ function follow_post(&$a) { intval(local_user()) ); - require_once('include/salmon.php'); - slapper($r[0],$contact,$slap); + + if((x($contact,'notify')) && (strlen($contact['notify']))) { + require_once('include/salmon.php'); + slapper($r[0],$contact['notify'],$slap); + } goaway($_SESSION['return_url']); // NOTREACHED