fix(socialavatars): Fix HTTP client usage
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
parent
8a6cd9d767
commit
687ab6b81d
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue