From 02488c853d0ad77de3a5498e3e321a8afe9f6ec5 Mon Sep 17 00:00:00 2001 From: Darshan Date: Wed, 7 Jan 2026 19:28:44 +0530 Subject: [PATCH] fix: paths error. --- .../Platform/Modules/Avatars/Http/Action.php | 5 ++++ .../Avatars/Http/Cards/Cloud/Back/Get.php | 4 +-- .../Avatars/Http/Cards/Cloud/Front/Get.php | 20 ++++++------- .../Avatars/Http/Cards/Cloud/OG/Get.php | 30 +++++++++---------- .../Modules/Avatars/Http/Initials/Get.php | 4 +-- 5 files changed, 34 insertions(+), 29 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Avatars/Http/Action.php b/src/Appwrite/Platform/Modules/Avatars/Http/Action.php index 44c1e1ae44..6c1c8c8b1a 100644 --- a/src/Appwrite/Platform/Modules/Avatars/Http/Action.php +++ b/src/Appwrite/Platform/Modules/Avatars/Http/Action.php @@ -16,6 +16,11 @@ use Utopia\Logger\Logger; class Action extends PlatformAction { + protected function getAppRoot(): string + { + return \dirname(__DIR__, 7); + } + protected function avatarCallback(string $type, string $code, int $width, int $height, int $quality, Response $response): void { $code = \strtolower($code); diff --git a/src/Appwrite/Platform/Modules/Avatars/Http/Cards/Cloud/Back/Get.php b/src/Appwrite/Platform/Modules/Avatars/Http/Cards/Cloud/Back/Get.php index e6bc72a6e6..1c0de4001e 100644 --- a/src/Appwrite/Platform/Modules/Avatars/Http/Cards/Cloud/Back/Get.php +++ b/src/Appwrite/Platform/Modules/Avatars/Http/Cards/Cloud/Back/Get.php @@ -90,14 +90,14 @@ class Get extends Action $imagePath = $isGolden ? 'back-golden.png' : ($isPlatinum ? 'back-platinum.png' : 'back.png'); - $baseImage = new Imagick(__DIR__ . '/../../../../../../../../public/images/cards/cloud/' . $imagePath); + $baseImage = new Imagick($this->getAppRoot() . '/public/images/cards/cloud/' . $imagePath); setlocale(LC_ALL, "en_US.utf8"); // $userId = \iconv("utf-8", "ascii//TRANSLIT", $userId); $text = new ImagickDraw(); $text->setTextAlignment(Imagick::ALIGN_CENTER); - $text->setFont(__DIR__ . '/../../../../../../../../public/fonts/SourceCodePro-Regular.ttf'); + $text->setFont($this->getAppRoot() . '/public/fonts/SourceCodePro-Regular.ttf'); $text->setFillColor(new ImagickPixel($isGolden ? '#664A1E' : ($isPlatinum ? '#555555' : '#E8E9F0'))); $text->setFontSize(28); $text->setFontWeight(400); diff --git a/src/Appwrite/Platform/Modules/Avatars/Http/Cards/Cloud/Front/Get.php b/src/Appwrite/Platform/Modules/Avatars/Http/Cards/Cloud/Front/Get.php index 841a0ae7b6..9d53991dd6 100644 --- a/src/Appwrite/Platform/Modules/Avatars/Http/Cards/Cloud/Front/Get.php +++ b/src/Appwrite/Platform/Modules/Avatars/Http/Cards/Cloud/Front/Get.php @@ -131,16 +131,16 @@ class Get extends Action $imagePath = $isGolden ? 'front-golden.png' : ($isPlatinum ? 'front-platinum.png' : 'front.png'); - $baseImage = new Imagick(__DIR__ . '/../../../../../../../../public/images/cards/cloud/' . $imagePath); + $baseImage = new Imagick($this->getAppRoot() . '/public/images/cards/cloud/' . $imagePath); if ($isEmployee) { - $image = new Imagick(__DIR__ . '/../../../../../../../../public/images/cards/cloud/employee.png'); + $image = new Imagick($this->getAppRoot() . '/public/images/cards/cloud/employee.png'); $image->setGravity(Imagick::GRAVITY_CENTER); $baseImage->compositeImage($image, Imagick::COMPOSITE_OVER, 793, 35); $text = new ImagickDraw(); $text->setTextAlignment(Imagick::ALIGN_CENTER); - $text->setFont(__DIR__ . '/../../../../../../../../public/fonts/Inter-Bold.ttf'); + $text->setFont($this->getAppRoot() . '/public/fonts/Inter-Bold.ttf'); $text->setFillColor(new ImagickPixel('#FFFADF')); $text->setFontSize(\strlen($employeeNumber) <= 2 ? 54 : 48); $text->setFontWeight(700); @@ -148,7 +148,7 @@ class Get extends Action $hashtag = new ImagickDraw(); $hashtag->setTextAlignment(Imagick::ALIGN_CENTER); - $hashtag->setFont(__DIR__ . '/../../../../../../../../public/fonts/Inter-Bold.ttf'); + $hashtag->setFont($this->getAppRoot() . '/public/fonts/Inter-Bold.ttf'); $hashtag->setFillColor(new ImagickPixel('#FFFADF')); $hashtag->setFontSize(28); $hashtag->setFontWeight(700); @@ -171,13 +171,13 @@ class Get extends Action } if ($isContributor) { - $image = new Imagick(__DIR__ . '/../../../../../../../../public/images/cards/cloud/contributor.png'); + $image = new Imagick($this->getAppRoot() . '/public/images/cards/cloud/contributor.png'); $image->setGravity(Imagick::GRAVITY_CENTER); $baseImage->compositeImage($image, Imagick::COMPOSITE_OVER, 793, 34); } if ($isHero) { - $image = new Imagick(__DIR__ . '/../../../../../../../../public/images/cards/cloud/hero.png'); + $image = new Imagick($this->getAppRoot() . '/public/images/cards/cloud/hero.png'); $image->setGravity(Imagick::GRAVITY_CENTER); $baseImage->compositeImage($image, Imagick::COMPOSITE_OVER, 793, 34); } @@ -189,7 +189,7 @@ class Get extends Action $text = new ImagickDraw(); $text->setTextAlignment(Imagick::ALIGN_CENTER); - $text->setFont(__DIR__ . '/../../../../../../../../public/fonts/Inter-Bold.ttf'); + $text->setFont($this->getAppRoot() . '/public/fonts/Inter-Bold.ttf'); $text->setFillColor(new ImagickPixel('#FFFFFF')); if (\strlen($name) > 32) { @@ -208,7 +208,7 @@ class Get extends Action $text = new ImagickDraw(); $text->setTextAlignment(Imagick::ALIGN_CENTER); - $text->setFont(__DIR__ . '/../../../../../../../../public/fonts/Inter-SemiBold.ttf'); + $text->setFont($this->getAppRoot() . '/public/fonts/Inter-SemiBold.ttf'); $text->setFillColor(new ImagickPixel($isGolden || $isPlatinum ? '#FFFFFF' : '#FFB9CC')); $text->setFontSize(27); $text->setFontWeight(600); @@ -218,7 +218,7 @@ class Get extends Action if (!empty($githubName)) { $text = new ImagickDraw(); $text->setTextAlignment(Imagick::ALIGN_CENTER); - $text->setFont(__DIR__ . '/../../../../../../../../public/fonts/Inter-Regular.ttf'); + $text->setFont($this->getAppRoot() . '/public/fonts/Inter-Regular.ttf'); $text->setFillColor(new ImagickPixel('#FFFFFF')); $text->setFontSize($scalingDown ? 28 : 32); $text->setFontWeight(400); @@ -226,7 +226,7 @@ class Get extends Action $baseImage->annotateImage($text, 512 + 20 + 4, 373 + ($scalingDown ? 2 : 0), 0, $githubName); - $image = new Imagick(__DIR__ . '/../../../../../../../../public/images/cards/cloud/github.png'); + $image = new Imagick($this->getAppRoot() . '/public/images/cards/cloud/github.png'); $image->setGravity(Imagick::GRAVITY_CENTER); $precisionFix = 5; $baseImage->compositeImage($image, Imagick::COMPOSITE_OVER, 512 - ($metrics['textWidth'] / 2) - 20 - 4, 373 - ($metrics['textHeight'] - $precisionFix)); diff --git a/src/Appwrite/Platform/Modules/Avatars/Http/Cards/Cloud/OG/Get.php b/src/Appwrite/Platform/Modules/Avatars/Http/Cards/Cloud/OG/Get.php index 9d3d6c1f87..f7c983db78 100644 --- a/src/Appwrite/Platform/Modules/Avatars/Http/Cards/Cloud/OG/Get.php +++ b/src/Appwrite/Platform/Modules/Avatars/Http/Cards/Cloud/OG/Get.php @@ -139,15 +139,15 @@ class Get extends Action $isPlatinum = $isGolden ? false : $isPlatinum; $memberSince = \strtoupper('Member since ' . $createdAt->format('M') . ' ' . $createdAt->format('d') . ', ' . $createdAt->format('o')); - $baseImage = new Imagick(__DIR__ . "/../../../../../../../../public/images/cards/cloud/og-background{$bgVariation}.png"); + $baseImage = new Imagick($this->getAppRoot() . "/public/images/cards/cloud/og-background{$bgVariation}.png"); $cardType = $isGolden ? '-golden' : ($isPlatinum ? '-platinum' : ''); - $image = new Imagick(__DIR__ . "/../../../../../../../../public/images/cards/cloud/og-card{$cardType}{$cardVariation}.png"); + $image = new Imagick($this->getAppRoot() . "/public/images/cards/cloud/og-card{$cardType}{$cardVariation}.png"); $baseImage->compositeImage($image, Imagick::COMPOSITE_OVER, 1008 / 2 - $image->getImageWidth() / 2, 1008 / 2 - $image->getImageHeight() / 2); - $imageLogo = new Imagick(__DIR__ . '/../../../../../../../../public/images/cards/cloud/og-background-logo.png'); - $imageShadow = new Imagick(__DIR__ . "/../../../../../../../../public/images/cards/cloud/og-shadow{$cardType}.png"); + $imageLogo = new Imagick($this->getAppRoot() . '/public/images/cards/cloud/og-background-logo.png'); + $imageShadow = new Imagick($this->getAppRoot() . "/public/images/cards/cloud/og-shadow{$cardType}.png"); if ($cardVariation === '1') { $baseImage->compositeImage($imageLogo, Imagick::COMPOSITE_OVER, 32, 1008 - $imageLogo->getImageHeight() - 32); $baseImage->compositeImage($imageShadow, Imagick::COMPOSITE_OVER, -450, 700); @@ -161,19 +161,19 @@ class Get extends Action if ($isEmployee) { $file = $cardVariation === '3' ? 'employee-skew.png' : 'employee.png'; - $image = new Imagick(__DIR__ . '/../../../../../../../../public/images/cards/cloud/' . $file); + $image = new Imagick($this->getAppRoot() . '/public/images/cards/cloud/' . $file); $image->setGravity(Imagick::GRAVITY_CENTER); $hashtag = new ImagickDraw(); $hashtag->setTextAlignment(Imagick::ALIGN_LEFT); - $hashtag->setFont(__DIR__ . '/../../../../../../../../public/fonts/Inter-Bold.ttf'); + $hashtag->setFont($this->getAppRoot() . '/public/fonts/Inter-Bold.ttf'); $hashtag->setFillColor(new ImagickPixel('#FFFADF')); $hashtag->setFontSize(20); $hashtag->setFontWeight(700); $text = new ImagickDraw(); $text->setTextAlignment(Imagick::ALIGN_LEFT); - $text->setFont(__DIR__ . '/../../../../../../../../public/fonts/Inter-Bold.ttf'); + $text->setFont($this->getAppRoot() . '/public/fonts/Inter-Bold.ttf'); $text->setFillColor(new ImagickPixel('#FFFADF')); $text->setFontSize(\strlen($employeeNumber) <= 1 ? 36 : 28); $text->setFontWeight(700); @@ -247,7 +247,7 @@ class Get extends Action if ($isContributor) { $file = $cardVariation === '3' ? 'contributor-skew.png' : 'contributor.png'; - $image = new Imagick(__DIR__ . '/../../../../../../../../public/images/cards/cloud/' . $file); + $image = new Imagick($this->getAppRoot() . '/public/images/cards/cloud/' . $file); $image->setGravity(Imagick::GRAVITY_CENTER); if ($cardVariation === '1') { @@ -265,7 +265,7 @@ class Get extends Action if ($isHero) { $file = $cardVariation === '3' ? 'hero-skew.png' : 'hero.png'; - $image = new Imagick(__DIR__ . '/../../../../../../../../public/images/cards/cloud/' . $file); + $image = new Imagick($this->getAppRoot() . '/public/images/cards/cloud/' . $file); $image->setGravity(Imagick::GRAVITY_CENTER); if ($cardVariation === '1') { @@ -288,7 +288,7 @@ class Get extends Action $textName = new ImagickDraw(); $textName->setTextAlignment(Imagick::ALIGN_CENTER); - $textName->setFont(__DIR__ . '/../../../../../../../../public/fonts/Inter-Bold.ttf'); + $textName->setFont($this->getAppRoot() . '/public/fonts/Inter-Bold.ttf'); $textName->setFillColor(new ImagickPixel('#FFFFFF')); if (\strlen($name) > 32) { @@ -325,7 +325,7 @@ class Get extends Action $textMember = new ImagickDraw(); $textMember->setTextAlignment(Imagick::ALIGN_CENTER); - $textMember->setFont(__DIR__ . '/../../../../../../../../public/fonts/Inter-Medium.ttf'); + $textMember->setFont($this->getAppRoot() . '/public/fonts/Inter-Medium.ttf'); $textMember->setFillColor(new ImagickPixel($isGolden || $isPlatinum ? '#FFFFFF' : '#FFB9CC')); $textMember->setFontWeight(500); $textMember->setTextKerning(1.12); @@ -358,7 +358,7 @@ class Get extends Action if (!empty($githubName)) { $text = new ImagickDraw(); $text->setTextAlignment(Imagick::ALIGN_LEFT); - $text->setFont(__DIR__ . '/../../../../../../../../public/fonts/Inter-Regular.ttf'); + $text->setFont($this->getAppRoot() . '/public/fonts/Inter-Regular.ttf'); $text->setFillColor(new ImagickPixel('#FFFFFF')); $text->setFontSize($scalingDown ? 16 : 20); $text->setFontWeight(400); @@ -369,7 +369,7 @@ class Get extends Action $group = new Imagick(); $groupWidth = $metrics['textWidth'] + 32 + 4; $group->newImage($groupWidth, $metrics['textHeight'] + 10, '#00000000'); - $image = new Imagick(__DIR__ . '/../../../../../../../../public/images/cards/cloud/github.png'); + $image = new Imagick($this->getAppRoot() . '/public/images/cards/cloud/github.png'); $image->setGravity(Imagick::GRAVITY_CENTER); $image->resizeImage(32, 32, Imagick::FILTER_LANCZOS, 1); $precisionFix = -1; @@ -387,7 +387,7 @@ class Get extends Action $group = new Imagick(); $groupWidth = $metrics['textWidth'] + 32 + 4; $group->newImage($groupWidth, $metrics['textHeight'] + 10, '#00000000'); - $image = new Imagick(__DIR__ . '/../../../../../../../../public/images/cards/cloud/github.png'); + $image = new Imagick($this->getAppRoot() . '/public/images/cards/cloud/github.png'); $image->setGravity(Imagick::GRAVITY_CENTER); $image->resizeImage(32, 32, Imagick::FILTER_LANCZOS, 1); $precisionFix = -1; @@ -407,7 +407,7 @@ class Get extends Action $text->annotation(320 + 15 + 2, 640, $githubName); $metrics = $baseImage->queryFontMetrics($text, $githubName); - $image = new Imagick(__DIR__ . '/../../../../../../../../public/images/cards/cloud/github-skew.png'); + $image = new Imagick($this->getAppRoot() . '/public/images/cards/cloud/github-skew.png'); $image->setGravity(Imagick::GRAVITY_CENTER); $baseImage->compositeImage($image, Imagick::COMPOSITE_OVER, 512 - ($metrics['textWidth'] / 2), 518 + \strlen($githubName) * 1.3); diff --git a/src/Appwrite/Platform/Modules/Avatars/Http/Initials/Get.php b/src/Appwrite/Platform/Modules/Avatars/Http/Initials/Get.php index ee4d62b8f4..8278a43ea3 100644 --- a/src/Appwrite/Platform/Modules/Avatars/Http/Initials/Get.php +++ b/src/Appwrite/Platform/Modules/Avatars/Http/Initials/Get.php @@ -103,8 +103,8 @@ class Get extends Action $punch->newImage($width, $height, 'transparent'); - $draw->setFont(__DIR__ . "/../../../../../../assets/fonts/inter-v8-latin-regular.woff2"); - $image->setFont(__DIR__ . "/../../../../../../assets/fonts/inter-v8-latin-regular.woff2"); + $draw->setFont($this->getAppRoot() . '/app/assets/fonts/inter-v8-latin-regular.woff2'); + $image->setFont($this->getAppRoot() . '/app/assets/fonts/inter-v8-latin-regular.woff2'); $draw->setFillColor(new ImagickPixel('black')); $draw->setFontSize($fontSize);