fix(socialavatars): Fix HTTP client usage

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
Christoph Wurst 2023-10-31 14:06:39 +01:00
parent 8a6cd9d767
commit 687ab6b81d
No known key found for this signature in database
GPG Key ID: CC42AC2A7F0E56D8
14 changed files with 29 additions and 23 deletions

View File

@ -23,10 +23,11 @@
namespace OCA\Contacts\Service\Social;
use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
class DiasporaProvider implements ISocialProvider {
/** @var IClientService */
/** @var IClient */
private $httpClient;
/** @var bool */
@ -36,7 +37,7 @@ class DiasporaProvider implements ISocialProvider {
public $name = 'diaspora';
public function __construct(IClientService $httpClient) {
$this->httpClient = $httpClient->NewClient();
$this->httpClient = $httpClient->newClient();
$this->looping = false;
}

View File

@ -23,17 +23,18 @@
namespace OCA\Contacts\Service\Social;
use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
class FacebookProvider implements ISocialProvider {
/** @var IClientService */
/** @var IClient */
private $httpClient;
/** @var string */
public $name = 'facebook';
public function __construct(IClientService $httpClient) {
$this->httpClient = $httpClient->NewClient();
$this->httpClient = $httpClient->newClient();
}
/**

View File

@ -27,11 +27,12 @@ use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\RequestOptions;
use OC\AppFramework\Http\Request;
use OCA\Contacts\AppInfo\Application;
use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
use Psr\Log\LoggerInterface;
class InstagramProvider implements ISocialProvider {
/** @var IClientService */
/** @var IClient */
private $httpClient;
/** @var LoggerInterface */
@ -42,7 +43,7 @@ class InstagramProvider implements ISocialProvider {
public function __construct(IClientService $httpClient,
LoggerInterface $logger) {
$this->httpClient = $httpClient->NewClient();
$this->httpClient = $httpClient->newClient();
$this->logger = $logger;
}

View File

@ -23,17 +23,18 @@
namespace OCA\Contacts\Service\Social;
use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
class MastodonProvider implements ISocialProvider {
/** @var IClientService */
/** @var IClient */
private $httpClient;
/** @var string */
public $name = 'mastodon';
public function __construct(IClientService $httpClient) {
$this->httpClient = $httpClient->NewClient();
$this->httpClient = $httpClient->newClient();
}
/**

View File

@ -26,11 +26,12 @@ namespace OCA\Contacts\Service\Social;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\RequestOptions;
use OCA\Contacts\AppInfo\Application;
use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
use Psr\Log\LoggerInterface;
class TelegramProvider implements ISocialProvider {
/** @var IClientService */
/** @var IClient */
private $httpClient;
/** @var LoggerInterface */
@ -41,7 +42,7 @@ class TelegramProvider implements ISocialProvider {
public function __construct(IClientService $httpClient,
LoggerInterface $logger) {
$this->httpClient = $httpClient->NewClient();
$this->httpClient = $httpClient->newClient();
$this->logger = $logger;
}

View File

@ -23,17 +23,18 @@
namespace OCA\Contacts\Service\Social;
use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
class XingProvider implements ISocialProvider {
/** @var IClientService */
/** @var IClient */
private $httpClient;
/** @var string */
public $name = 'xing';
public function __construct(IClientService $httpClient) {
$this->httpClient = $httpClient->NewClient();
$this->httpClient = $httpClient->newClient();
}
/**

View File

@ -218,7 +218,7 @@ class SocialApiService {
foreach ($urls as $url) {
try {
$httpResult = $this->clientService->NewClient()->get($url);
$httpResult = $this->clientService->newClient()->get($url);
$socialdata = $httpResult->getBody();
$imageType = $httpResult->getHeader('content-type');
if (isset($socialdata) && isset($imageType)) {

View File

@ -49,7 +49,7 @@ class DiasporaProviderTest extends TestCase {
$this->client = $this->createMock(IClient::class);
$this->clientService
->method('NewClient')
->method('newClient')
->willReturn($this->client);
$this->provider = new DiasporaProvider(

View File

@ -49,7 +49,7 @@ class FacebookProviderTest extends TestCase {
$this->client = $this->createMock(IClient::class);
$this->clientService
->method('NewClient')
->method('newClient')
->willReturn($this->client);
$this->provider = new FacebookProvider(

View File

@ -54,7 +54,7 @@ class InstagramProviderTest extends TestCase {
$this->logger = $this->createMock(LoggerInterface::class);
$this->clientService
->method('NewClient')
->method('newClient')
->willReturn($this->client);
$this->provider = new InstagramProvider(

View File

@ -49,7 +49,7 @@ class MastodonProviderTest extends TestCase {
$this->client = $this->createMock(IClient::class);
$this->clientService
->method('NewClient')
->method('newClient')
->willReturn($this->client);
$this->provider = new MastodonProvider(

View File

@ -54,7 +54,7 @@ class TelegramProviderTest extends TestCase {
$this->client = $this->createMock(IClient::class);
$this->clientService
->method('NewClient')
->method('newClient')
->willReturn($this->client);
$this->provider = new TelegramProvider(

View File

@ -49,7 +49,7 @@ class XingProviderTest extends TestCase {
$this->client = $this->createMock(IClient::class);
$this->clientService
->method('NewClient')
->method('newClient')
->willReturn($this->client);
$this->provider = new XingProvider(

View File

@ -176,7 +176,7 @@ class SocialApiServiceTest extends TestCase {
->method('get')
->willReturn($response);
$this->clientService
->method('NewClient')
->method('newClient')
->willReturn($client);
$this->imageResizer
->expects($body ? $this->once() : $this->never())
@ -237,7 +237,7 @@ class SocialApiServiceTest extends TestCase {
->method('get')
->willReturn($response);
$this->clientService
->method('NewClient')
->method('newClient')
->willReturn($client);
$this->imageResizer
->expects($this->once())
@ -310,7 +310,7 @@ class SocialApiServiceTest extends TestCase {
->method('get')
->willReturn($response);
$this->clientService
->method('NewClient')
->method('newClient')
->willReturn($client);
$this->imageResizer
->expects($this->once())
@ -438,7 +438,7 @@ class SocialApiServiceTest extends TestCase {
->method('get')
->willReturn($validResponse);
$this->clientService
->method('NewClient')
->method('newClient')
->willReturn($client);
$this->imageResizer
->method('resizeImage')