Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(socialavatars): Fix HTTP client usage #3681

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/Service/Social/DiasporaProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -36,7 +37,7 @@
public $name = 'diaspora';

public function __construct(IClientService $httpClient) {
$this->httpClient = $httpClient->NewClient();
$this->httpClient = $httpClient->newClient();

Check warning on line 40 in lib/Service/Social/DiasporaProvider.php

View check run for this annotation

Codecov / codecov/patch

lib/Service/Social/DiasporaProvider.php#L40

Added line #L40 was not covered by tests
$this->looping = false;
}

Expand Down
5 changes: 3 additions & 2 deletions lib/Service/Social/FacebookProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Check warning on line 37 in lib/Service/Social/FacebookProvider.php

View check run for this annotation

Codecov / codecov/patch

lib/Service/Social/FacebookProvider.php#L37

Added line #L37 was not covered by tests
}

/**
Expand Down
5 changes: 3 additions & 2 deletions lib/Service/Social/InstagramProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -42,7 +43,7 @@

public function __construct(IClientService $httpClient,
LoggerInterface $logger) {
$this->httpClient = $httpClient->NewClient();
$this->httpClient = $httpClient->newClient();

Check warning on line 46 in lib/Service/Social/InstagramProvider.php

View check run for this annotation

Codecov / codecov/patch

lib/Service/Social/InstagramProvider.php#L46

Added line #L46 was not covered by tests
$this->logger = $logger;
}

Expand Down
5 changes: 3 additions & 2 deletions lib/Service/Social/MastodonProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Check warning on line 37 in lib/Service/Social/MastodonProvider.php

View check run for this annotation

Codecov / codecov/patch

lib/Service/Social/MastodonProvider.php#L37

Added line #L37 was not covered by tests
}

/**
Expand Down
5 changes: 3 additions & 2 deletions lib/Service/Social/TelegramProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -41,7 +42,7 @@

public function __construct(IClientService $httpClient,
LoggerInterface $logger) {
$this->httpClient = $httpClient->NewClient();
$this->httpClient = $httpClient->newClient();

Check warning on line 45 in lib/Service/Social/TelegramProvider.php

View check run for this annotation

Codecov / codecov/patch

lib/Service/Social/TelegramProvider.php#L45

Added line #L45 was not covered by tests
$this->logger = $logger;
}

Expand Down
5 changes: 3 additions & 2 deletions lib/Service/Social/XingProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Check warning on line 37 in lib/Service/Social/XingProvider.php

View check run for this annotation

Codecov / codecov/patch

lib/Service/Social/XingProvider.php#L37

Added line #L37 was not covered by tests
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/SocialApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@

foreach ($urls as $url) {
try {
$httpResult = $this->clientService->NewClient()->get($url);
$httpResult = $this->clientService->newClient()->get($url);

Check warning on line 221 in lib/Service/SocialApiService.php

View check run for this annotation

Codecov / codecov/patch

lib/Service/SocialApiService.php#L221

Added line #L221 was not covered by tests
$socialdata = $httpResult->getBody();
$imageType = $httpResult->getHeader('content-type');
if (isset($socialdata) && isset($imageType)) {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Service/Social/DiasporaProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Service/Social/FacebookProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Service/Social/InstagramProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Service/Social/MastodonProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Service/Social/TelegramProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Service/Social/XingProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/Service/SocialApiServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -237,7 +237,7 @@ public function testUpdateContactWithNetworkVersion3() {
->method('get')
->willReturn($response);
$this->clientService
->method('NewClient')
->method('newClient')
->willReturn($client);
$this->imageResizer
->expects($this->once())
Expand Down Expand Up @@ -310,7 +310,7 @@ public function testUpdateContactWithNetworkVersion4() {
->method('get')
->willReturn($response);
$this->clientService
->method('NewClient')
->method('newClient')
->willReturn($client);
$this->imageResizer
->expects($this->once())
Expand Down Expand Up @@ -438,7 +438,7 @@ protected function setupAddressbooks() {
->method('get')
->willReturn($validResponse);
$this->clientService
->method('NewClient')
->method('newClient')
->willReturn($client);
$this->imageResizer
->method('resizeImage')
Expand Down
Loading