Merge pull request '[various] Rename ICanHandleHttpResponses->getBody to getBodyString' (#1456) from MrPetovan/friendica-addons:bug/deprecated into develop

Reviewed-on: https://git.friendi.ca/friendica/friendica-addons/pulls/1456
pull/1457/head
heluecht 2024-01-13 21:38:31 +01:00
commit a179bab747
13 changed files with 26 additions and 26 deletions

View File

@ -1111,11 +1111,11 @@ function bluesky_process_post(stdClass $post, int $uid, int $post_reason, int $l
$uri = bluesky_get_uri($post); $uri = bluesky_get_uri($post);
if ($id = Post::selectFirst(['id'], ['uri' => $uri, 'uid' => $uid])) { if ($id = Post::selectFirst(['id'], ['uri' => $uri, 'uid' => $uid])) {
return $id['id']; return $id['id'];
} }
if ($id = Post::selectFirst(['id'], ['extid' => $uri, 'uid' => $uid])) { if ($id = Post::selectFirst(['id'], ['extid' => $uri, 'uid' => $uid])) {
return $id['id']; return $id['id'];
} }
Logger::debug('Importing post', ['uid' => $uid, 'indexedAt' => $post->indexedAt, 'uri' => $post->uri, 'cid' => $post->cid, 'root' => $post->record->reply->root ?? '']); Logger::debug('Importing post', ['uid' => $uid, 'indexedAt' => $post->indexedAt, 'uri' => $post->uri, 'cid' => $post->cid, 'root' => $post->record->reply->root ?? '']);
@ -1251,7 +1251,7 @@ function bluesky_get_text(stdClass $record, int $uri_id): string
$url = DI::baseUrl() . '/search?tag=' . urlencode($feature->tag); $url = DI::baseUrl() . '/search?tag=' . urlencode($feature->tag);
$linktext = '#' . $feature->tag; $linktext = '#' . $feature->tag;
break; break;
default: default:
Logger::notice('Unhandled feature type', ['type' => $feature->$type, 'feature' => $feature, 'record' => $record]); Logger::notice('Unhandled feature type', ['type' => $feature->$type, 'feature' => $feature, 'record' => $record]);
break; break;
@ -1736,13 +1736,13 @@ function bluesky_post(int $uid, string $url, string $params, array $headers): ?s
} }
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
Logger::notice('API Error', ['error' => json_decode($curlResult->getBody()) ?: $curlResult->getBody()]); Logger::notice('API Error', ['error' => json_decode($curlResult->getBodyString()) ?: $curlResult->getBodyString()]);
DI::pConfig()->set($uid, 'bluesky', 'status', BLUEKSY_STATUS_API_FAIL); DI::pConfig()->set($uid, 'bluesky', 'status', BLUEKSY_STATUS_API_FAIL);
return null; return null;
} }
DI::pConfig()->set($uid, 'bluesky', 'status', BLUEKSY_STATUS_SUCCESS); DI::pConfig()->set($uid, 'bluesky', 'status', BLUEKSY_STATUS_SUCCESS);
return json_decode($curlResult->getBody()); return json_decode($curlResult->getBodyString());
} }
function bluesky_xrpc_get(int $uid, string $url, array $parameters = []): ?stdClass function bluesky_xrpc_get(int $uid, string $url, array $parameters = []): ?stdClass
@ -1767,9 +1767,9 @@ function bluesky_get(string $url, string $accept_content = HttpClientAccept::DEF
} }
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
Logger::notice('API Error', ['error' => json_decode($curlResult->getBody()) ?: $curlResult->getBody()]); Logger::notice('API Error', ['error' => json_decode($curlResult->getBodyString()) ?: $curlResult->getBodyString()]);
return null; return null;
} }
return json_decode($curlResult->getBody()); return json_decode($curlResult->getBodyString());
} }

View File

@ -126,7 +126,7 @@ function discourse_fetch_post($host, $topic, $pid)
return false; return false;
} }
$raw = $curlResult->getBody(); $raw = $curlResult->getBodyString();
$data = json_decode($raw, true); $data = json_decode($raw, true);
$posts = $data['post_stream']['posts']; $posts = $data['post_stream']['posts'];
foreach($posts as $post) { foreach($posts as $post) {
@ -162,7 +162,7 @@ function discourse_fetch_post_from_api(&$message, $post, $host)
return false; return false;
} }
$raw = $curlResult->getBody(); $raw = $curlResult->getBodyString();
$data = json_decode($raw, true); $data = json_decode($raw, true);
if (empty($data)) { if (empty($data)) {
return false; return false;

View File

@ -192,7 +192,7 @@ EOT;
Logger::debug('dwpost: data: ' . $xml); Logger::debug('dwpost: data: ' . $xml);
if ($dw_blog !== 'test') { if ($dw_blog !== 'test') {
$x = DI::httpClient()->post($dw_blog, $xml, ['Content-Type' => 'text/xml'])->getBody(); $x = DI::httpClient()->post($dw_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString();
} }
Logger::info('posted to dreamwidth: ' . ($x) ? $x : ''); Logger::info('posted to dreamwidth: ' . ($x) ? $x : '');

View File

@ -186,7 +186,7 @@ EOT;
Logger::debug('ijpost: data: ' . $xml); Logger::debug('ijpost: data: ' . $xml);
if ($ij_blog !== 'test') { if ($ij_blog !== 'test') {
$x = DI::httpClient()->post($ij_blog, $xml, ['Content-Type' => 'text/xml'])->getBody(); $x = DI::httpClient()->post($ij_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString();
} }
Logger::info('posted to insanejournal: ' . $x ? $x : ''); Logger::info('posted to insanejournal: ' . $x ? $x : '');
} }

View File

@ -201,7 +201,7 @@ function libertree_send(array &$b)
// 'token' => $ltree_api_token // 'token' => $ltree_api_token
]; ];
$result = DI::httpClient()->post($ltree_blog, $params)->getBody(); $result = DI::httpClient()->post($ltree_blog, $params)->getBodyString();
Logger::notice('libertree: ' . $result); Logger::notice('libertree: ' . $result);
} }
} }

View File

@ -207,7 +207,7 @@ EOT;
Logger::debug('ljpost: data: ' . $xml); Logger::debug('ljpost: data: ' . $xml);
if ($lj_blog !== 'test') { if ($lj_blog !== 'test') {
$x = DI::httpClient()->post($lj_blog, $xml, ['Content-Type' => 'text/xml'])->getBody(); $x = DI::httpClient()->post($lj_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString();
} }
Logger::info('posted to livejournal: ' . ($x) ? $x : ''); Logger::info('posted to livejournal: ' . ($x) ? $x : '');

View File

@ -221,7 +221,7 @@ function mailstream_do_images(array &$item, array &$attachments)
continue; continue;
} }
$attachments[$url] = [ $attachments[$url] = [
'data' => $curlResult->getBody(), 'data' => $curlResult->getBodyString(),
'guid' => hash('crc32', $url), 'guid' => hash('crc32', $url),
'filename' => basename($components['path']), 'filename' => basename($components['path']),
'type' => $curlResult->getContentType() 'type' => $curlResult->getContentType()

View File

@ -82,7 +82,7 @@ function mastodoncustomemojis_fetch_custom_emojis_for_url($api_base_url)
$fetchResult = DI::httpClient()->fetchFull($api_url); $fetchResult = DI::httpClient()->fetchFull($api_url);
if ($fetchResult->isSuccess()) { if ($fetchResult->isSuccess()) {
$emojis_array = json_decode($fetchResult->getBody(), true); $emojis_array = json_decode($fetchResult->getBodyString(), true);
if (is_array($emojis_array) && count($emojis_array)) { if (is_array($emojis_array) && count($emojis_array)) {
foreach ($emojis_array as $emoji) { foreach ($emojis_array as $emoji) {

View File

@ -121,7 +121,7 @@ function openstreetmap_get_coordinates(array &$b)
if (is_null($j)) { if (is_null($j)) {
$curlResult = DI::httpClient()->get($nomserver . $args); $curlResult = DI::httpClient()->get($nomserver . $args);
if ($curlResult->isSuccess()) { if ($curlResult->isSuccess()) {
$j = json_decode($curlResult->getBody(), true); $j = json_decode($curlResult->getBodyString(), true);
DI::cache()->set($cachekey, $j, Duration::MONTH); DI::cache()->set($cachekey, $j, Duration::MONTH);
} }
} }

View File

@ -1244,7 +1244,7 @@ function tumblr_get_contact_by_url(string $url, int $uid): ?array
} catch (\Exception $e) { } catch (\Exception $e) {
return null; return null;
} }
$html = $curlResult->getBody(); $html = $curlResult->getBodyString();
if (empty($html)) { if (empty($html)) {
return null; return null;
} }
@ -1372,7 +1372,7 @@ function tumblr_delete(int $uid, string $url, array $parameters): stdClass
*/ */
function tumblr_format_result(ICanHandleHttpResponses $curlResult): stdClass function tumblr_format_result(ICanHandleHttpResponses $curlResult): stdClass
{ {
$result = json_decode($curlResult->getBody()); $result = json_decode($curlResult->getBodyString());
if (empty($result) || empty($result->meta)) { if (empty($result) || empty($result->meta)) {
$result = new stdClass; $result = new stdClass;
$result->meta = new stdClass; $result->meta = new stdClass;
@ -1426,11 +1426,11 @@ function tumblr_get_token(int $uid, string $code = ''): string
$curlResult = DI::httpClient()->post('https://api.tumblr.com/v2/oauth2/token', $parameters); $curlResult = DI::httpClient()->post('https://api.tumblr.com/v2/oauth2/token', $parameters);
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
Logger::info('Error fetching token', ['uid' => $uid, 'code' => $code, 'result' => $curlResult->getBody(), 'parameters' => $parameters]); Logger::info('Error fetching token', ['uid' => $uid, 'code' => $code, 'result' => $curlResult->getBodyString(), 'parameters' => $parameters]);
return ''; return '';
} }
$result = json_decode($curlResult->getBody()); $result = json_decode($curlResult->getBodyString());
if (empty($result)) { if (empty($result)) {
Logger::info('Invalid result when updating token', ['uid' => $uid]); Logger::info('Invalid result when updating token', ['uid' => $uid]);
return ''; return '';
@ -1479,7 +1479,7 @@ function tumblr_exchange_token(int $uid): stdClass
]); ]);
$response = $client->post('oauth2/exchange', ['auth' => 'oauth']); $response = $client->post('oauth2/exchange', ['auth' => 'oauth']);
return json_decode($response->getBody()->getContents()); return json_decode($response->getBodyString()->getContents());
} catch (RequestException $exception) { } catch (RequestException $exception) {
Logger::notice('Exchange failed', ['code' => $exception->getCode(), 'message' => $exception->getMessage()]); Logger::notice('Exchange failed', ['code' => $exception->getCode(), 'message' => $exception->getMessage()]);
return new stdClass; return new stdClass;

View File

@ -362,7 +362,7 @@ function twitter_post(int $uid, string $url, string $type, array $data): stdClas
]); ]);
$response = $client->post($url, ['auth' => 'oauth', $type => $data]); $response = $client->post($url, ['auth' => 'oauth', $type => $data]);
$body = $response->getBody()->getContents(); $body = $response->getBodyString()->getContents();
$status = [ $status = [
'code' => $response->getStatusCode(), 'code' => $response->getStatusCode(),
@ -399,7 +399,7 @@ function twitter_test_connection(int $uid)
$status = [ $status = [
'code' => $response->getStatusCode(), 'code' => $response->getStatusCode(),
'reason' => $response->getReasonPhrase(), 'reason' => $response->getReasonPhrase(),
'content' => $response->getBody()->getContents() 'content' => $response->getBodyString()->getContents()
]; ];
DI::pConfig()->set(1, 'twitter', 'last_status', $status); DI::pConfig()->set(1, 'twitter', 'last_status', $status);
Logger::info('Test successful', ['uid' => $uid]); Logger::info('Test successful', ['uid' => $uid]);

View File

@ -113,7 +113,7 @@ class WebDav implements ICanWriteToStorage
$response = $this->client->request('propfind', $uri, $opts); $response = $this->client->request('propfind', $uri, $opts);
$responseDoc = new \DOMDocument(); $responseDoc = new \DOMDocument();
$responseDoc->loadXML($response->getBody()); $responseDoc->loadXML($response->getBodyString());
$responseDoc->formatOutput = true; $responseDoc->formatOutput = true;
$xpath = new \DOMXPath($responseDoc); $xpath = new \DOMXPath($responseDoc);
@ -205,7 +205,7 @@ class WebDav implements ICanWriteToStorage
throw new ReferenceStorageException(sprintf('Invalid reference %s', $reference)); throw new ReferenceStorageException(sprintf('Invalid reference %s', $reference));
} }
return $response->getBody(); return $response->getBodyString();
} }
/** /**

View File

@ -269,7 +269,7 @@ EOT;
Logger::debug('wppost: data: ' . $xml); Logger::debug('wppost: data: ' . $xml);
if ($wp_blog !== 'test') { if ($wp_blog !== 'test') {
$x = DI::httpClient()->post($wp_blog, $xml)->getBody(); $x = DI::httpClient()->post($wp_blog, $xml)->getBodyString();
} }
Logger::info('posted to wordpress: ' . (($x) ? $x : '')); Logger::info('posted to wordpress: ' . (($x) ? $x : ''));
} }