mirror of
https://github.com/friendica/friendica
synced 2025-04-26 12:30:11 +00:00
Check and add a server
This commit is contained in:
parent
8cbe2f025b
commit
8d999f54d0
5 changed files with 63 additions and 84 deletions
|
@ -22,6 +22,7 @@
|
|||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\GServer;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
|
@ -32,7 +33,7 @@ class UpdateGServer
|
|||
* @param string $server_url Server URL
|
||||
* @param boolean $only_nodeinfo Only use nodeinfo for server detection
|
||||
*/
|
||||
public static function execute(string $server_url, bool $only_nodeinfo = false, bool $force = false)
|
||||
public static function execute(string $server_url, bool $only_nodeinfo = false)
|
||||
{
|
||||
if (empty($server_url)) {
|
||||
return;
|
||||
|
@ -40,11 +41,22 @@ class UpdateGServer
|
|||
|
||||
$filtered = filter_var($server_url, FILTER_SANITIZE_URL);
|
||||
if (substr(Strings::normaliseLink($filtered), 0, 7) != 'http://') {
|
||||
GServer::setFailure($filtered);
|
||||
GServer::setFailure($server_url);
|
||||
return;
|
||||
}
|
||||
|
||||
$ret = GServer::check($filtered, '', $force, $only_nodeinfo);
|
||||
if (($filtered != $server_url) && DBA::exists('gserver', ['nurl' => Strings::normaliseLink($server_url)])) {
|
||||
GServer::setFailure($server_url);
|
||||
return;
|
||||
}
|
||||
|
||||
$cleaned = GServer::cleanURL($server_url);
|
||||
if (($cleaned != $server_url) && DBA::exists('gserver', ['nurl' => Strings::normaliseLink($server_url)])) {
|
||||
GServer::setFailure($server_url);
|
||||
return;
|
||||
}
|
||||
|
||||
$ret = GServer::check($filtered, '', true, $only_nodeinfo);
|
||||
Logger::info('Updated gserver', ['url' => $filtered, 'result' => $ret]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue