From 8c5b68037a47350f191623b1ab10a99fba84466a Mon Sep 17 00:00:00 2001
From: Jonas Leder <jonas@jonasled.de>
Date: Sat, 16 Apr 2022 23:34:35 +0200
Subject: [PATCH] render images through imgproxy

---
 public/API/graphql.php        | 4 +++-
 public/API/queries/skills.php | 6 +++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/public/API/graphql.php b/public/API/graphql.php
index b778f21..84ee939 100644
--- a/public/API/graphql.php
+++ b/public/API/graphql.php
@@ -1,6 +1,7 @@
 <?php
 use GraphQL\Server\StandardServer;
 use GraphQL\Type\Schema;
+use GraphQL\Error\DebugFlag;
 
 require 'vendor/autoload.php';
 require "./lib/config.php";
@@ -17,7 +18,8 @@ try {
         'schema' => $schema,
         'rootValue' => [
             'db' =>$conn,
-        ]
+        ],
+        'debugFlag' => DebugFlag::INCLUDE_DEBUG_MESSAGE | DebugFlag::INCLUDE_TRACE,
     ];
     $server = new StandardServer($serverConfig);
 
diff --git a/public/API/queries/skills.php b/public/API/queries/skills.php
index 93b00de..a9b9f47 100644
--- a/public/API/queries/skills.php
+++ b/public/API/queries/skills.php
@@ -28,7 +28,11 @@ function getSkills() {
                 
                 // Get the actual presigned-url
                 $downloadURL =  (string)  $presignedRequest->getUri();
-                array_push($response, $downloadURL);
+                $encodedUrl = rtrim(strtr(base64_encode($downloadURL), '+/', '-_'), '=');
+                $path = "/rs:fit:0:80:1/g:no/{$encodedUrl}.png";
+
+                $signature = rtrim(strtr(base64_encode(hash_hmac('sha256', $imgProxySalt.$path, $imgProxyKey, true)), '+/', '-_'), '=');
+                array_push($response, $imgProxyUrl . "/" . $signature . $path);
         }
         return $response;
 }
-- 
GitLab