X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FMagic.php;h=c300e5971e4bddd4f0d550d443d906ec78c47f7d;hb=9115ec5f0deb71111d53a1eda0c1de7c4d8c6c53;hp=f6f3bbc5908120dd06ec1fcf9ed67fb8cc94701e;hpb=e56a53647bd5469551bf4f9ef2df50a5dd16b943;p=friendica.git diff --git a/src/Module/Magic.php b/src/Module/Magic.php index f6f3bbc590..c300e5971e 100644 --- a/src/Module/Magic.php +++ b/src/Module/Magic.php @@ -24,11 +24,13 @@ namespace Friendica\Module; use Friendica\App; use Friendica\BaseModule; use Friendica\Core\L10n; +use Friendica\Core\Session\Capability\IHandleUserSessions; use Friendica\Core\System; use Friendica\Database\Database; use Friendica\Model\Contact; use Friendica\Model\User; use Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests; +use Friendica\Network\HTTPClient\Client\HttpClientAccept; use Friendica\Network\HTTPClient\Client\HttpClientOptions; use Friendica\Util\HTTPSignature; use Friendica\Util\Profiler; @@ -48,14 +50,17 @@ class Magic extends BaseModule protected $dba; /** @var ICanSendHttpRequests */ protected $httpClient; + /** @var IHandleUserSessions */ + protected $userSession; - public function __construct(App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, Database $dba, ICanSendHttpRequests $httpClient, array $server, array $parameters = []) + public function __construct(App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, Database $dba, ICanSendHttpRequests $httpClient, IHandleUserSessions $userSession, $server, array $parameters = []) { parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); - $this->app = $app; - $this->dba = $dba; - $this->httpClient = $httpClient; + $this->app = $app; + $this->dba = $dba; + $this->httpClient = $httpClient; + $this->userSession = $userSession; } protected function rawContent(array $request = []) @@ -89,8 +94,8 @@ class Magic extends BaseModule } // OpenWebAuth - if (local_user() && $owa) { - $user = User::getById(local_user()); + if ($this->userSession->getLocalUserId() && $owa) { + $user = User::getById($this->userSession->getLocalUserId()); // Extract the basepath // NOTE: we need another solution because this does only work @@ -112,7 +117,7 @@ class Magic extends BaseModule ); // Try to get an authentication token from the other instance. - $curlResult = $this->httpClient->get($basepath . '/owa', [HttpClientOptions::HEADERS => $header]); + $curlResult = $this->httpClient->get($basepath . '/owa', HttpClientAccept::DEFAULT, [HttpClientOptions::HEADERS => $header]); if ($curlResult->isSuccess()) { $j = json_decode($curlResult->getBody(), true);