mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-11 09:34:26 +02:00
Improved user agent string
This commit is contained in:
parent
0ae91b59ca
commit
afff2b949f
18 changed files with 181 additions and 84 deletions
|
@ -44,6 +44,7 @@ use Friendica\Model\Post;
|
|||
use Friendica\Model\Profile;
|
||||
use Friendica\Model\Tag;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientRequest;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Util\Crypto;
|
||||
|
@ -1009,7 +1010,7 @@ class DFRN
|
|||
|
||||
$content_type = ($public_batch ? 'application/magic-envelope+xml' : 'application/json');
|
||||
|
||||
$postResult = DI::httpClient()->post($dest_url, $envelope, ['Content-Type' => $content_type]);
|
||||
$postResult = DI::httpClient()->post($dest_url, $envelope, ['Content-Type' => $content_type], 0, HttpClientRequest::DFRN);
|
||||
$xml = $postResult->getBodyString();
|
||||
|
||||
$curl_stat = $postResult->getReturnCode();
|
||||
|
|
|
@ -41,6 +41,7 @@ use Friendica\Model\Post;
|
|||
use Friendica\Model\Tag;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientRequest;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Protocol\Delivery;
|
||||
|
@ -2937,7 +2938,7 @@ class Diaspora
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
private static function transmit(array $owner, array $contact, string $envelope, bool $public_batch, string $guid = ''): int
|
||||
private static function transmit(array $contact, string $envelope, bool $public_batch, string $guid = ''): int
|
||||
{
|
||||
$enabled = intval(DI::config()->get('system', 'diaspora_enabled'));
|
||||
if (!$enabled) {
|
||||
|
@ -2968,7 +2969,7 @@ class Diaspora
|
|||
if (!intval(DI::config()->get('system', 'diaspora_test'))) {
|
||||
$content_type = (($public_batch) ? 'application/magic-envelope+xml' : 'application/json');
|
||||
|
||||
$postResult = DI::httpClient()->post($dest_url . '/', $envelope, ['Content-Type' => $content_type]);
|
||||
$postResult = DI::httpClient()->post($dest_url . '/', $envelope, ['Content-Type' => $content_type], 0, HttpClientRequest::DIASPORA);
|
||||
$return_code = $postResult->getReturnCode();
|
||||
} else {
|
||||
Logger::notice('test_mode');
|
||||
|
@ -3042,7 +3043,7 @@ class Diaspora
|
|||
|
||||
$envelope = self::buildMessage($msg, $owner, $contact, $owner['uprvkey'], $pubkey ?? '', $public_batch);
|
||||
|
||||
$return_code = self::transmit($owner, $contact, $envelope, $public_batch, $guid);
|
||||
$return_code = self::transmit($contact, $envelope, $public_batch, $guid);
|
||||
|
||||
Logger::info('Transmitted message', ['owner' => $owner['uid'], 'target' => $contact['addr'], 'type' => $type, 'guid' => $guid, 'result' => $return_code]);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue