mirror of
https://github.com/friendica/friendica
synced 2025-04-25 06:30:11 +00:00
UserSession class [5] - Refactor src/Module/ files with DI
This commit is contained in:
parent
a729f3255d
commit
eecc456e0c
78 changed files with 455 additions and 530 deletions
|
@ -23,7 +23,6 @@ namespace Friendica\Module;
|
|||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
|
@ -75,7 +74,7 @@ class Proxy extends BaseModule
|
|||
throw new \Friendica\Network\HTTPException\BadRequestException();
|
||||
}
|
||||
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
Logger::debug('Redirecting not logged in user to original address', ['url' => $request['url']]);
|
||||
System::externalRedirect($request['url']);
|
||||
}
|
||||
|
@ -84,7 +83,7 @@ class Proxy extends BaseModule
|
|||
$request['url'] = str_replace(' ', '+', $request['url']);
|
||||
|
||||
// Fetch the content with the local user
|
||||
$fetchResult = HTTPSignature::fetchRaw($request['url'], Session::getLocalUser(), [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE], 'timeout' => 10]);
|
||||
$fetchResult = HTTPSignature::fetchRaw($request['url'], DI::userSession()->getLocalUserId(), [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE], 'timeout' => 10]);
|
||||
$img_str = $fetchResult->getBody();
|
||||
|
||||
if (!$fetchResult->isSuccess() || empty($img_str)) {
|
||||
|
@ -93,7 +92,7 @@ class Proxy extends BaseModule
|
|||
// stop.
|
||||
}
|
||||
|
||||
Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => Session::getLocalUser(), 'image' => $request['url']]);
|
||||
Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => DI::userSession()->getLocalUserId(), 'image' => $request['url']]);
|
||||
|
||||
$mime = Images::getMimeTypeByData($img_str);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue