This commit is contained in:
Tobias Diekershoff 2022-11-05 19:48:51 +01:00
parent 1c65098013
commit 5530b6fc75

View File

@ -28,6 +28,7 @@ use Friendica\Model\Profile;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Network\HTTPClient\Client\HttpClientAccept; use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Network\HTTPClient\Client\HttpClientOptions; use Friendica\Network\HTTPClient\Client\HttpClientOptions;
use Friendica\Util\Network;
use Friendica\Util\Strings; use Friendica\Util\Strings;
/* This class is used to verify the homepage link of a user profile. /* This class is used to verify the homepage link of a user profile.
@ -74,27 +75,26 @@ class CheckRelMeProfileLink
} else { } else {
foreach ($doc->getElementsByTagName('a') as $link) { foreach ($doc->getElementsByTagName('a') as $link) {
$rel = $link->getAttribute('rel'); $rel = $link->getAttribute('rel');
if ($rel=='me') { if ($rel == 'me') {
$href = $link->getAttribute('href'); $href = $link->getAttribute('href');
if (strpos($href, 'http')!==false) { if (strpos($href, 'http')!==false && !$homepageUrlVerified && Network::isUrlValid($href)) {
if (!$homepageUrlVerified) { $homepageUrlVerified = Strings::compareLink($owner['url'], $href);
$homepageUrlVerified = Strings::compareLink($owner['url'], $href);
}
} }
} }
} }
} }
if ($homepageUrlVerified) { if ($homepageUrlVerified) {
Profile::update(['homepage_verified' => 1], $uid); Profile::update(['homepage_verified' => true], $uid);
Logger::notice('Homepage URL verified', [$uid, $owner['homepage']]); Logger::notice('Homepage URL verified', [$uid, $owner['homepage']]);
} else { } else {
Profile::update(['homepage_verified' => 0], $uid); Profile::update(['homepage_verified' => false], $uid);
Logger::notice('Homepage URL could not be verified', [$uid, $owner['homepage']]); Logger::notice('Homepage URL could not be verified', [$uid, $owner['homepage']]);
} }
} }
} }
} else { } else {
Logger::notice('The user has no homepage link.', [$uid]); Logger::notice('The user has no homepage link.', [$uid]);
Profile::update(['homepage_verified' => false], $uid);
} }
} }
} }