]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Proxy.php
Merge pull request #12549 from MrPetovan/task/12490-fakelink-button
[friendica.git] / src / Module / Proxy.php
index cff5ed90b00fbe7d827efa1e6bbcb216b3b58697..e8f8b7911dcb12a2dc45e7dc496d31ae72d9dd55 100644 (file)
@@ -74,8 +74,8 @@ class Proxy extends BaseModule
                        throw new \Friendica\Network\HTTPException\BadRequestException();
                }
 
-               if (!local_user()) {
-                       Logger::info('Redirecting not logged in user to original address', ['url' => $request['url']]);
+               if (!DI::userSession()->getLocalUserId()) {
+                       Logger::debug('Redirecting not logged in user to original address', ['url' => $request['url']]);
                        System::externalRedirect($request['url']);
                }
 
@@ -83,22 +83,22 @@ class Proxy extends BaseModule
                $request['url'] = str_replace(' ', '+', $request['url']);
 
                // Fetch the content with the local user
-               $fetchResult = HTTPSignature::fetchRaw($request['url'], local_user(), [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)) {
-                       Logger::info('Error fetching image', ['image' => $request['url'], 'return' => $fetchResult->getReturnCode(), 'empty' => empty($img_str)]);
+                       Logger::notice('Error fetching image', ['image' => $request['url'], 'return' => $fetchResult->getReturnCode(), 'empty' => empty($img_str)]);
                        self::responseError();
                        // stop.
                }
 
-               Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => local_user(), '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);
 
                $image = new Image($img_str, $mime);
                if (!$image->isValid()) {
-                       Logger::info('The image is invalid', ['image' => $request['url'], 'mime' => $mime]);
+                       Logger::notice('The image is invalid', ['image' => $request['url'], 'mime' => $mime]);
                        self::responseError();
                        // stop.
                }
@@ -193,7 +193,7 @@ class Proxy extends BaseModule
        private static function responseImageHttpCache(Image $img)
        {
                if (is_null($img) || !$img->isValid()) {
-                       Logger::info('The cached image is invalid');
+                       Logger::notice('The cached image is invalid');
                        self::responseError();
                        // stop.
                }