Improved user agent string

This commit is contained in:
Michael 2024-05-10 09:01:43 +00:00
parent 0ae91b59ca
commit afff2b949f
18 changed files with 181 additions and 84 deletions

View file

@ -24,6 +24,7 @@ namespace Friendica\Protocol;
use Friendica\Core\Logger;
use Friendica\DI;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Network\HTTPClient\Client\HttpClientRequest;
use Friendica\Network\Probe;
use Friendica\Protocol\Salmon\Format\Magic;
use Friendica\Util\Crypto;
@ -49,7 +50,7 @@ class Salmon
{
$ret = [];
Logger::info('Fetching salmon key for '.$uri);
Logger::info('Fetching salmon key for ' . $uri);
$arr = Probe::lrdd($uri);
@ -67,7 +68,7 @@ class Salmon
// If it's inline, parse it - otherwise get the key
if (count($ret) > 0) {
for ($x = 0; $x < count($ret); $x ++) {
for ($x = 0; $x < count($ret); $x++) {
if (substr($ret[$x], 0, 5) === 'data:') {
if (strstr($ret[$x], ',')) {
$ret[$x] = substr($ret[$x], strpos($ret[$x], ',') + 1);
@ -120,12 +121,15 @@ class Salmon
}
if (!$owner['sprvkey']) {
Logger::notice(sprintf("user '%s' (%d) does not have a salmon private key. Send failed.",
$owner['name'], $owner['uid']));
Logger::notice(sprintf(
"user '%s' (%d) does not have a salmon private key. Send failed.",
$owner['name'],
$owner['uid']
));
return -1;
}
Logger::info('slapper called for '.$url.'. Data: ' . $slap);
Logger::info('slapper called for ' . $url . '. Data: ' . $slap);
// create a magic envelope
@ -166,7 +170,7 @@ class Salmon
$postResult = DI::httpClient()->post($url, $salmon, [
'Content-type' => 'application/magic-envelope+xml',
'Content-length' => strlen($salmon),
]);
], 0, HttpClientRequest::SALMON);
$return_code = $postResult->getReturnCode();
@ -193,7 +197,7 @@ class Salmon
$postResult = DI::httpClient()->post($url, $salmon, [
'Content-type' => 'application/magic-envelope+xml',
'Content-length' => strlen($salmon),
]);
], 0, HttpClientRequest::SALMON);
$return_code = $postResult->getReturnCode();
}
@ -217,13 +221,14 @@ class Salmon
// slap them
$postResult = DI::httpClient()->post($url, $salmon, [
'Content-type' => 'application/magic-envelope+xml',
'Content-length' => strlen($salmon)]);
'Content-length' => strlen($salmon)
], 0, HttpClientRequest::SALMON);
$return_code = $postResult->getReturnCode();
}
Logger::info('slapper for '.$url.' returned ' . $return_code);
Logger::info('slapper for ' . $url . ' returned ' . $return_code);
if (! $return_code) {
if (!$return_code) {
return -1;
}