From 687ab6b81d61d6a8cfa278d01f491df21ed6eb03 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Tue, 31 Oct 2023 14:06:39 +0100 Subject: [PATCH] fix(socialavatars): Fix HTTP client usage Signed-off-by: Christoph Wurst --- lib/Service/Social/DiasporaProvider.php | 5 +++-- lib/Service/Social/FacebookProvider.php | 5 +++-- lib/Service/Social/InstagramProvider.php | 5 +++-- lib/Service/Social/MastodonProvider.php | 5 +++-- lib/Service/Social/TelegramProvider.php | 5 +++-- lib/Service/Social/XingProvider.php | 5 +++-- lib/Service/SocialApiService.php | 2 +- tests/unit/Service/Social/DiasporaProviderTest.php | 2 +- tests/unit/Service/Social/FacebookProviderTest.php | 2 +- tests/unit/Service/Social/InstagramProviderTest.php | 2 +- tests/unit/Service/Social/MastodonProviderTest.php | 2 +- tests/unit/Service/Social/TelegramProviderTest.php | 2 +- tests/unit/Service/Social/XingProviderTest.php | 2 +- tests/unit/Service/SocialApiServiceTest.php | 8 ++++---- 14 files changed, 29 insertions(+), 23 deletions(-) diff --git a/lib/Service/Social/DiasporaProvider.php b/lib/Service/Social/DiasporaProvider.php index 080762507..d729cf0f2 100644 --- a/lib/Service/Social/DiasporaProvider.php +++ b/lib/Service/Social/DiasporaProvider.php @@ -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; } diff --git a/lib/Service/Social/FacebookProvider.php b/lib/Service/Social/FacebookProvider.php index 4ea79d872..9318ece87 100644 --- a/lib/Service/Social/FacebookProvider.php +++ b/lib/Service/Social/FacebookProvider.php @@ -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(); } /** diff --git a/lib/Service/Social/InstagramProvider.php b/lib/Service/Social/InstagramProvider.php index a61e36bec..1b046f871 100644 --- a/lib/Service/Social/InstagramProvider.php +++ b/lib/Service/Social/InstagramProvider.php @@ -27,11 +27,12 @@ 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; } diff --git a/lib/Service/Social/MastodonProvider.php b/lib/Service/Social/MastodonProvider.php index fb7f5cf22..b4b71924b 100644 --- a/lib/Service/Social/MastodonProvider.php +++ b/lib/Service/Social/MastodonProvider.php @@ -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(); } /** diff --git a/lib/Service/Social/TelegramProvider.php b/lib/Service/Social/TelegramProvider.php index c17fc9632..56bb6f505 100644 --- a/lib/Service/Social/TelegramProvider.php +++ b/lib/Service/Social/TelegramProvider.php @@ -26,11 +26,12 @@ 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; } diff --git a/lib/Service/Social/XingProvider.php b/lib/Service/Social/XingProvider.php index 78443d56f..b7fc6aa6e 100644 --- a/lib/Service/Social/XingProvider.php +++ b/lib/Service/Social/XingProvider.php @@ -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(); } /** diff --git a/lib/Service/SocialApiService.php b/lib/Service/SocialApiService.php index ef0dfb83e..1c6e48279 100644 --- a/lib/Service/SocialApiService.php +++ b/lib/Service/SocialApiService.php @@ -218,7 +218,7 @@ public function updateContact(string $addressbookId, string $contactId, ?string 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)) { diff --git a/tests/unit/Service/Social/DiasporaProviderTest.php b/tests/unit/Service/Social/DiasporaProviderTest.php index ab48866d0..e23613958 100644 --- a/tests/unit/Service/Social/DiasporaProviderTest.php +++ b/tests/unit/Service/Social/DiasporaProviderTest.php @@ -49,7 +49,7 @@ protected function setUp(): void { $this->client = $this->createMock(IClient::class); $this->clientService - ->method('NewClient') + ->method('newClient') ->willReturn($this->client); $this->provider = new DiasporaProvider( diff --git a/tests/unit/Service/Social/FacebookProviderTest.php b/tests/unit/Service/Social/FacebookProviderTest.php index fd55b7186..2537bd3b4 100644 --- a/tests/unit/Service/Social/FacebookProviderTest.php +++ b/tests/unit/Service/Social/FacebookProviderTest.php @@ -49,7 +49,7 @@ protected function setUp(): void { $this->client = $this->createMock(IClient::class); $this->clientService - ->method('NewClient') + ->method('newClient') ->willReturn($this->client); $this->provider = new FacebookProvider( diff --git a/tests/unit/Service/Social/InstagramProviderTest.php b/tests/unit/Service/Social/InstagramProviderTest.php index fc032651f..cba8de919 100644 --- a/tests/unit/Service/Social/InstagramProviderTest.php +++ b/tests/unit/Service/Social/InstagramProviderTest.php @@ -54,7 +54,7 @@ protected function setUp(): void { $this->logger = $this->createMock(LoggerInterface::class); $this->clientService - ->method('NewClient') + ->method('newClient') ->willReturn($this->client); $this->provider = new InstagramProvider( diff --git a/tests/unit/Service/Social/MastodonProviderTest.php b/tests/unit/Service/Social/MastodonProviderTest.php index bcb4c75de..802364d15 100644 --- a/tests/unit/Service/Social/MastodonProviderTest.php +++ b/tests/unit/Service/Social/MastodonProviderTest.php @@ -49,7 +49,7 @@ protected function setUp(): void { $this->client = $this->createMock(IClient::class); $this->clientService - ->method('NewClient') + ->method('newClient') ->willReturn($this->client); $this->provider = new MastodonProvider( diff --git a/tests/unit/Service/Social/TelegramProviderTest.php b/tests/unit/Service/Social/TelegramProviderTest.php index 259ad9013..666158bbb 100644 --- a/tests/unit/Service/Social/TelegramProviderTest.php +++ b/tests/unit/Service/Social/TelegramProviderTest.php @@ -54,7 +54,7 @@ protected function setUp(): void { $this->client = $this->createMock(IClient::class); $this->clientService - ->method('NewClient') + ->method('newClient') ->willReturn($this->client); $this->provider = new TelegramProvider( diff --git a/tests/unit/Service/Social/XingProviderTest.php b/tests/unit/Service/Social/XingProviderTest.php index ec9280f32..e5d94ee6c 100644 --- a/tests/unit/Service/Social/XingProviderTest.php +++ b/tests/unit/Service/Social/XingProviderTest.php @@ -49,7 +49,7 @@ protected function setUp(): void { $this->client = $this->createMock(IClient::class); $this->clientService - ->method('NewClient') + ->method('newClient') ->willReturn($this->client); $this->provider = new XingProvider( diff --git a/tests/unit/Service/SocialApiServiceTest.php b/tests/unit/Service/SocialApiServiceTest.php index a45d25437..0bee78bde 100644 --- a/tests/unit/Service/SocialApiServiceTest.php +++ b/tests/unit/Service/SocialApiServiceTest.php @@ -176,7 +176,7 @@ public function testUpdateContactWithoutNetwork($addressbooks, $providers, $body ->method('get') ->willReturn($response); $this->clientService - ->method('NewClient') + ->method('newClient') ->willReturn($client); $this->imageResizer ->expects($body ? $this->once() : $this->never()) @@ -237,7 +237,7 @@ public function testUpdateContactWithNetworkVersion3() { ->method('get') ->willReturn($response); $this->clientService - ->method('NewClient') + ->method('newClient') ->willReturn($client); $this->imageResizer ->expects($this->once()) @@ -310,7 +310,7 @@ public function testUpdateContactWithNetworkVersion4() { ->method('get') ->willReturn($response); $this->clientService - ->method('NewClient') + ->method('newClient') ->willReturn($client); $this->imageResizer ->expects($this->once()) @@ -438,7 +438,7 @@ protected function setupAddressbooks() { ->method('get') ->willReturn($validResponse); $this->clientService - ->method('NewClient') + ->method('newClient') ->willReturn($client); $this->imageResizer ->method('resizeImage')