diff --git a/README-CN.md b/README-CN.md index 8942c2220e..59dad38cd2 100644 --- a/README-CN.md +++ b/README-CN.md @@ -66,7 +66,7 @@ docker run -it --rm \ --volume /var/run/docker.sock:/var/run/docker.sock \ --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \ --entrypoint="install" \ - appwrite/appwrite:1.5.3 + appwrite/appwrite:1.5.4 ``` ### Windows @@ -78,7 +78,7 @@ docker run -it --rm ^ --volume //var/run/docker.sock:/var/run/docker.sock ^ --volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^ --entrypoint="install" ^ - appwrite/appwrite:1.5.3 + appwrite/appwrite:1.5.4 ``` #### PowerShell @@ -88,7 +88,7 @@ docker run -it --rm ` --volume /var/run/docker.sock:/var/run/docker.sock ` --volume ${pwd}/appwrite:/usr/src/code/appwrite:rw ` --entrypoint="install" ` - appwrite/appwrite:1.5.3 + appwrite/appwrite:1.5.4 ``` 运行后,可以在浏览器上访问 http://localhost 找到 Appwrite 控制台。在非 Linux 的本机主机上完成安装后,服务器可能需要几分钟才能启动。 diff --git a/README.md b/README.md index ea37336d62..792a5482ef 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ docker run -it --rm \ --volume /var/run/docker.sock:/var/run/docker.sock \ --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \ --entrypoint="install" \ - appwrite/appwrite:1.5.3 + appwrite/appwrite:1.5.4 ``` ### Windows @@ -88,7 +88,7 @@ docker run -it --rm ^ --volume //var/run/docker.sock:/var/run/docker.sock ^ --volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^ --entrypoint="install" ^ - appwrite/appwrite:1.5.3 + appwrite/appwrite:1.5.4 ``` #### PowerShell @@ -98,7 +98,7 @@ docker run -it --rm ` --volume /var/run/docker.sock:/var/run/docker.sock ` --volume ${pwd}/appwrite:/usr/src/code/appwrite:rw ` --entrypoint="install" ` - appwrite/appwrite:1.5.3 + appwrite/appwrite:1.5.4 ``` Once the Docker installation is complete, go to http://localhost to access the Appwrite console from your browser. Please note that on non-Linux native hosts, the server might take a few minutes to start after completing the installation. diff --git a/app/cli.php b/app/cli.php index 1a8c785a30..bde8159f24 100644 --- a/app/cli.php +++ b/app/cli.php @@ -8,7 +8,6 @@ use Appwrite\Event\Delete; use Appwrite\Event\Func; use Appwrite\Event\Hamster; use Appwrite\Platform\Appwrite; -use Utopia\App; use Utopia\Cache\Adapter\Sharding; use Utopia\Cache\Cache; use Utopia\CLI\CLI; @@ -22,6 +21,7 @@ use Utopia\Platform\Service; use Utopia\Pools\Group; use Utopia\Queue\Connection; use Utopia\Registry\Registry; +use Utopia\System\System; Authorization::disable(); @@ -145,7 +145,7 @@ CLI::setResource('logError', function (Registry $register) { $logger = $register->get('logger'); if ($logger) { - $version = App::getEnv('_APP_VERSION', 'UNKNOWN'); + $version = System::getEnv('_APP_VERSION', 'UNKNOWN'); $log = new Log(); $log->setNamespace($namespace); @@ -164,7 +164,7 @@ CLI::setResource('logError', function (Registry $register) { $log->setAction($action); - $isProduction = App::getEnv('_APP_ENV', 'development') === 'production'; + $isProduction = System::getEnv('_APP_ENV', 'development') === 'production'; $log->setEnvironment($isProduction ? Log::ENVIRONMENT_PRODUCTION : Log::ENVIRONMENT_STAGING); $responseCode = $logger->addLog($log); diff --git a/app/config/locale/translations/af.json b/app/config/locale/translations/af.json index d238e65c18..117aae46ac 100644 --- a/app/config/locale/translations/af.json +++ b/app/config/locale/translations/af.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Baie dankie", "emails.verification.signature": "Die {{project}} span", "emails.magicSession.subject": "Teken aan", - "emails.magicSession.hello": "Goeie dag,", + "emails.magicSession.hello": "Goeie dag", "emails.magicSession.body": "Volg hierdie skakel om in te teken.", "emails.magicSession.footer": "Ignoreer gerus hierdie boodskap as u nie die versoek gestuur het om met die' adres in te teken nie.", "emails.magicSession.thanks": "Baie dankie", diff --git a/app/config/locale/translations/ar.json b/app/config/locale/translations/ar.json index 7da5219a64..c2597c3dac 100644 --- a/app/config/locale/translations/ar.json +++ b/app/config/locale/translations/ar.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "شكرا", "emails.verification.signature": "فريق {{project}}", "emails.magicSession.subject": "تسجيل الدخول", - "emails.magicSession.hello": "أهلا،", + "emails.magicSession.hello": "أهلا", "emails.magicSession.body": "اتبع هذا الرابط لتسجيل الدخول", "emails.magicSession.footer": "لو لم تطلب تسجيل الدخول بهذا البريد الاكتروني ، يمكنك تجاهل هذه الرسالة", "emails.magicSession.thanks": "شكرا", diff --git a/app/config/locale/translations/as.json b/app/config/locale/translations/as.json index 21369bc613..3c306a4e4f 100644 --- a/app/config/locale/translations/as.json +++ b/app/config/locale/translations/as.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "ধন্যবাদ", "emails.verification.signature": "{{project}} দল", "emails.magicSession.subject": "লগইন", - "emails.magicSession.hello": "নমস্কাৰ,", + "emails.magicSession.hello": "নমস্কাৰ", "emails.magicSession.body": "লগইন কৰিবলৈ এই লিংকটো অনুসৰণ কৰক।", "emails.magicSession.footer": "যদি আপুনি এই ইমেইল ব্যৱহাৰ কৰি লগইন কৰিবলৈ কোৱা নাছিল, আপুনি এই বাৰ্তাটো উপেক্ষা কৰিব পাৰে।", "emails.magicSession.thanks": "ধন্যবাদ", diff --git a/app/config/locale/translations/az.json b/app/config/locale/translations/az.json index c43335f671..327f0c2cb6 100644 --- a/app/config/locale/translations/az.json +++ b/app/config/locale/translations/az.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Təşəkkürlər", "emails.verification.signature": "{{project}} komandası", "emails.magicSession.subject": "Daxil Olmaq", - "emails.magicSession.hello": "Salam,", + "emails.magicSession.hello": "Salam", "emails.magicSession.body": "Daxil olmaq üçün bu linki izləyin.", "emails.magicSession.footer": "Bu e-poçtdan istifadə edərək giriş istəməmisinizsə, bu mesajı görməməzlikdən gələ bilərsiniz.", "emails.magicSession.thanks": "Təşəkkürlər", diff --git a/app/config/locale/translations/be.json b/app/config/locale/translations/be.json index 02772ba1ef..f5b517153b 100644 --- a/app/config/locale/translations/be.json +++ b/app/config/locale/translations/be.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Дзякуем", "emails.verification.signature": "каманда {{project}}", "emails.magicSession.subject": "Лагін", - "emails.magicSession.hello": "Прывітанне,", + "emails.magicSession.hello": "Прывітанне", "emails.magicSession.body": "Перайдзіце па спасылцы, каб увайсці.", "emails.magicSession.footer": "Калі вы не прасілі ўвайсці, выкарыстоўваючы гэты адрас электроннай пошты, праігнаруйце гэтае паведамленне.", "emails.magicSession.thanks": "Дзякуем", diff --git a/app/config/locale/translations/ca.json b/app/config/locale/translations/ca.json index 736a96987c..1fa020fee8 100644 --- a/app/config/locale/translations/ca.json +++ b/app/config/locale/translations/ca.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Gràcies", "emails.verification.signature": "Equip {{project}}", "emails.magicSession.subject": "Entrar", - "emails.magicSession.hello": "Hola,", + "emails.magicSession.hello": "Hola", "emails.magicSession.body": "Accedeix a aquest enllaç per a entrar.", "emails.magicSession.footer": "Si no has sol·licitat entrar amb aquesta adreça electrònica, pots ignorar aquest missatge.", "emails.magicSession.thanks": "Gràcies", diff --git a/app/config/locale/translations/da.json b/app/config/locale/translations/da.json index 5f666ec5cb..8d5bbc6fec 100644 --- a/app/config/locale/translations/da.json +++ b/app/config/locale/translations/da.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Tak", "emails.verification.signature": "{{project}} team", "emails.magicSession.subject": "Login", - "emails.magicSession.hello": "Hej,", + "emails.magicSession.hello": "Hej", "emails.magicSession.body": "Følg dette link for at logge ind.", "emails.magicSession.footer": "Hvis du ikke har bedt om at logge ind med denne email, ignorer venligst denne besked.", "emails.magicSession.thanks": "Tak", diff --git a/app/config/locale/translations/de.json b/app/config/locale/translations/de.json index f22945fb7f..e94c61acd2 100644 --- a/app/config/locale/translations/de.json +++ b/app/config/locale/translations/de.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Danke", "emails.verification.signature": "{{project}}-Team", "emails.magicSession.subject": "Login", - "emails.magicSession.hello": "Hey,", + "emails.magicSession.hello": "Hey", "emails.magicSession.body": "Folge diesem Link, um dich einzuloggen.", "emails.magicSession.footer": "Solltest du keinen Login für diese E-Mail-Adresse angefordert haben, kannst du diese Nachricht ignorieren.", "emails.magicSession.thanks": "Danke", diff --git a/app/config/locale/translations/el.json b/app/config/locale/translations/el.json index 0f78c5a1ea..d8b12700fa 100644 --- a/app/config/locale/translations/el.json +++ b/app/config/locale/translations/el.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Ευχαριστούμε", "emails.verification.signature": "Η ομάδα του {{project}}", "emails.magicSession.subject": "Είσοδος", - "emails.magicSession.hello": "Γεια σου,", + "emails.magicSession.hello": "Γεια σου", "emails.magicSession.body": "Ακολουθήστε αυτό το link για να συνδεθείτε", "emails.magicSession.footer": "Εάν δεν ζητήσατε να συνδεθείτε χρησιμοποιώντας αυτό το email, μπορείτε να αγνοήσετε αυτό το μήνυμα.", "emails.magicSession.thanks": "Ευχαριστούμε", diff --git a/app/config/locale/translations/eo.json b/app/config/locale/translations/eo.json index 5031fe5096..8e528bc076 100644 --- a/app/config/locale/translations/eo.json +++ b/app/config/locale/translations/eo.json @@ -9,7 +9,7 @@ "emails.verification.thanks": "Dankegon.", "emails.verification.signature": "Teamo {{project}}", "emails.magicSession.subject": "Login", - "emails.magicSession.hello": "Saluton,", + "emails.magicSession.hello": "Saluton", "emails.magicSession.body": "Alklaku ĉi tiun ligon por eniri.", "emails.magicSession.footer": "Se vi ne petis ĉi tiun konfirmon de ĉi tiu retpoŝto, vi povas ignori ĉi tiun mesaĝon.", "emails.magicSession.thanks": "Dankegon", diff --git a/app/config/locale/translations/fr.json b/app/config/locale/translations/fr.json index 08e73d9578..09ebedf6ad 100644 --- a/app/config/locale/translations/fr.json +++ b/app/config/locale/translations/fr.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Merci", "emails.verification.signature": "Équipe {{project}}", "emails.magicSession.subject": "Connexion", - "emails.magicSession.hello": "Bonjour,", + "emails.magicSession.hello": "Bonjour", "emails.magicSession.body": "Suivez ce lien pour vous connecter.", "emails.magicSession.footer": "Si vous n'avez pas demandé à vous connecter en utilisant cet e-mail, vous pouvez ignorer ce message.", "emails.magicSession.thanks": "Merci", diff --git a/app/config/locale/translations/ga.json b/app/config/locale/translations/ga.json index a10f302d9e..f1e61c7ab4 100644 --- a/app/config/locale/translations/ga.json +++ b/app/config/locale/translations/ga.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Go raibh maith agat", "emails.verification.signature": "{{project}} foireann", "emails.magicSession.subject": "Logáil isteach", - "emails.magicSession.hello": "Haigh,", + "emails.magicSession.hello": "Haigh", "emails.magicSession.body": "Lean an nasc seo chun logáil isteach.", "emails.magicSession.footer": "Mura ndearna tú iarratas logáil isteach leis an ríomhphost seo, déan neamhaird den teachtaireacht seo.", "emails.magicSession.thanks": "Go raibh maith agat", diff --git a/app/config/locale/translations/gu.json b/app/config/locale/translations/gu.json index 76dbb4fed7..23bc52d958 100644 --- a/app/config/locale/translations/gu.json +++ b/app/config/locale/translations/gu.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "આભાર", "emails.verification.signature": "{{project}} ટીમ", "emails.magicSession.subject": "પ્રવેશ કરો", - "emails.magicSession.hello": "નમસ્કાર,", + "emails.magicSession.hello": "નમસ્કાર", "emails.magicSession.body": "પ્રવેશ કરવા માટે આ લિંકને અનુસરો.", "emails.magicSession.footer": "જો તમે આ ઇમેઇલનો ઉપયોગ કરીને પ્રવેશ કરવાનું ન કહ્યું હોય, તો તમે આ સંદેશને અવગણી શકો છો.", "emails.magicSession.thanks": "આભાર", diff --git a/app/config/locale/translations/he.json b/app/config/locale/translations/he.json index 5a28ef9d6e..7d0bcebb69 100644 --- a/app/config/locale/translations/he.json +++ b/app/config/locale/translations/he.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "תודה", "emails.verification.signature": "צוות {{project}}", "emails.magicSession.subject": "כניסה למערכת", - "emails.magicSession.hello": "שלום,", + "emails.magicSession.hello": "שלום", "emails.magicSession.body": "לחץ על קישור זה כדי להיכנס.", "emails.magicSession.footer": "אם לא ביקשת להיכנס באמצעות דוא\"ל זה, תוכל להתעלם מהודעה זו.", "emails.magicSession.thanks": "תודה", diff --git a/app/config/locale/translations/hi.json b/app/config/locale/translations/hi.json index c0494806ec..28cb30184e 100644 --- a/app/config/locale/translations/hi.json +++ b/app/config/locale/translations/hi.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "धन्यवाद", "emails.verification.signature": "{{project}} टीम", "emails.magicSession.subject": "लॉग इन", - "emails.magicSession.hello": "नमस्ते,", + "emails.magicSession.hello": "नमस्ते", "emails.magicSession.body": "इस लिंक के माध्यम से लॉग-इन करें।", "emails.magicSession.footer": "यदि आप इस ईमेल द्वारा लॉगिन नहीं करना चाहते हैं, तो आप इस संदेश को नज़रअंदाज़ कर सकते हैं।", "emails.magicSession.thanks": "धन्यवाद", diff --git a/app/config/locale/translations/hr.json b/app/config/locale/translations/hr.json index d2db29c977..afacf18b64 100644 --- a/app/config/locale/translations/hr.json +++ b/app/config/locale/translations/hr.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Hvala", "emails.verification.signature": "{{project}} tim", "emails.magicSession.subject": "Prijavite se", - "emails.magicSession.hello": "Pozdrav,", + "emails.magicSession.hello": "Pozdrav", "emails.magicSession.body": "Slijedite ovu poveznicu za prijavu.", "emails.magicSession.footer": "Ako niste zatražili prijavu putem ove e-pošte, možete zanemariti ovu poruku.", "emails.magicSession.thanks": "Hvala", diff --git a/app/config/locale/translations/hu.json b/app/config/locale/translations/hu.json index 265c549f87..0900a9c152 100644 --- a/app/config/locale/translations/hu.json +++ b/app/config/locale/translations/hu.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Köszönettel", "emails.verification.signature": "a {{project}} csapat", "emails.magicSession.subject": "Bejelentkezés", - "emails.magicSession.hello": "Szia,", + "emails.magicSession.hello": "Szia", "emails.magicSession.body": "Kattints a linkre a bejelentkezéshez.", "emails.magicSession.footer": "Ha nem te szerettél volna bejelentkezni ezzel az email címmel, akkor nyugodtan hagyd figyelmen kívül ezt az üzenetet.", "emails.magicSession.thanks": "Köszönettel", diff --git a/app/config/locale/translations/id.json b/app/config/locale/translations/id.json index 195e522f45..40f0b6800d 100644 --- a/app/config/locale/translations/id.json +++ b/app/config/locale/translations/id.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Terima kasih", "emails.verification.signature": "Tim {{project}}", "emails.magicSession.subject": "Masuk", - "emails.magicSession.hello": "Hai,", + "emails.magicSession.hello": "Hai", "emails.magicSession.body": "Ikuti tautan ini untuk masuk.", "emails.magicSession.footer": "Jika Anda tidak meminta untuk masuk menggunakan email ini, Anda dapat mengabaikan pesan ini.", "emails.magicSession.thanks": "Terima kasih", diff --git a/app/config/locale/translations/it.json b/app/config/locale/translations/it.json index 8f31ce705c..eafe4aac89 100644 --- a/app/config/locale/translations/it.json +++ b/app/config/locale/translations/it.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Grazie", "emails.verification.signature": "Il team {{project}}", "emails.magicSession.subject": "Login", - "emails.magicSession.hello": "Ciao,", + "emails.magicSession.hello": "Ciao", "emails.magicSession.body": "Clicca questo link per accedere.", "emails.magicSession.footer": "Se non hai richiesto di effettuare l’accesso, puoi ignorare questo messaggio.", "emails.magicSession.thanks": "Grazie", diff --git a/app/config/locale/translations/jv.json b/app/config/locale/translations/jv.json index 5749f92a45..31c9ff4e28 100644 --- a/app/config/locale/translations/jv.json +++ b/app/config/locale/translations/jv.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Matur nuwun", "emails.verification.signature": "Tim {{project}}", "emails.magicSession.subject": "Masuk", - "emails.magicSession.hello": "Hai,", + "emails.magicSession.hello": "Hai", "emails.magicSession.body": "Klik link iki kanggo masuk.", "emails.magicSession.footer": "Yen sampeyan ora njaluk masuk nggunakake alamat email iki, sampeyan iso nglirwakake pesen iki.", "emails.magicSession.thanks": "Matur nuwun", diff --git a/app/config/locale/translations/kn.json b/app/config/locale/translations/kn.json index 28ee3cf3ea..7745e7c531 100644 --- a/app/config/locale/translations/kn.json +++ b/app/config/locale/translations/kn.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "ಧನ್ಯವಾದಗಳು", "emails.verification.signature": "{{project}} ತಂಡ", "emails.magicSession.subject": "ಲಾಗಿನ್", - "emails.magicSession.hello": "ನಮಸ್ಕಾರ,", + "emails.magicSession.hello": "ನಮಸ್ಕಾರ", "emails.magicSession.body": "ಲಾಗಿನ್ ಮಾಡಲಿಕ್ಕೆ ಈ ಲಿಂಕನ್ನು ಅನುಸರಿಸಿ", "emails.magicSession.footer": "ನೀವು ಈ ಇಮೇಲನಿಂದ ಲಾಗಿನ್ ಮಾಡಲು ಕೇಳದಿದ್ದರೆ, ಈ ಸಂದೇಶವನ್ನು ನಿರ್ಲಕ್ಷಿಸಿ", "emails.magicSession.thanks": "ಧನ್ಯವಾದಗಳು", diff --git a/app/config/locale/translations/ko.json b/app/config/locale/translations/ko.json index 96a0db9aeb..20ef90bdef 100644 --- a/app/config/locale/translations/ko.json +++ b/app/config/locale/translations/ko.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "감사합니다", "emails.verification.signature": "{{project}} 팀", "emails.magicSession.subject": "로그인", - "emails.magicSession.hello": "안녕하세요,", + "emails.magicSession.hello": "안녕하세요", "emails.magicSession.body": "로그인 하시려면 링크를 클릭하여주세요.", "emails.magicSession.footer": "이 이메일 계정으로 로그인 신청을 하지 않으셨다면 이 메세지를 무시하여주세요.", "emails.magicSession.thanks": "감사합니다", diff --git a/app/config/locale/translations/la.json b/app/config/locale/translations/la.json index a5d2155c7b..345bb2c437 100644 --- a/app/config/locale/translations/la.json +++ b/app/config/locale/translations/la.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Gratias", "emails.verification.signature": "{{project}} Team", "emails.magicSession.subject": "Log in", - "emails.magicSession.hello": "Salve ibi,", + "emails.magicSession.hello": "Salve ibi", "emails.magicSession.body": "Hanc nexum cum login", "emails.magicSession.footer": "Si verificationem huius inscriptionis non postulasti, nuntium hunc ignorare potes.", "emails.magicSession.thanks": "Gratias", diff --git a/app/config/locale/translations/lb.json b/app/config/locale/translations/lb.json index fd21091801..b652ae2c9f 100644 --- a/app/config/locale/translations/lb.json +++ b/app/config/locale/translations/lb.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Merci", "emails.verification.signature": "{{project}} équipe", "emails.magicSession.subject": "Login", - "emails.magicSession.hello": "Hey,", + "emails.magicSession.hello": "Hey", "emails.magicSession.body": "Follegt dëse Link fir umellen.", "emails.magicSession.footer": "Wann Dir net gefrot hutt Iech mat dëser E -Mail anzemelden, kënnt Dir dëse Message ignoréieren.", "emails.magicSession.thanks": "Merci", diff --git a/app/config/locale/translations/lt.json b/app/config/locale/translations/lt.json index c5c104427b..bff7569411 100644 --- a/app/config/locale/translations/lt.json +++ b/app/config/locale/translations/lt.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Ačiū", "emails.verification.signature": "{{project}} komanda", "emails.magicSession.subject": "Prisijungti", - "emails.magicSession.hello": "Labas,", + "emails.magicSession.hello": "Labas", "emails.magicSession.body": "Spauskite šią nuorodą, kad prisijungtumėte.", "emails.magicSession.footer": "Jei neprašėte prisijungti naudojantis šiuo el. paštu, galite ignoruoti šį pranešimą.", "emails.magicSession.thanks": "Ačiū", diff --git a/app/config/locale/translations/lv.json b/app/config/locale/translations/lv.json index e2917b51a0..ebc26eb2c1 100644 --- a/app/config/locale/translations/lv.json +++ b/app/config/locale/translations/lv.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Paldies", "emails.verification.signature": "{{project}} komanda", "emails.magicSession.subject": "Ieiet", - "emails.magicSession.hello": "Sveicināti,", + "emails.magicSession.hello": "Sveicināti", "emails.magicSession.body": "Sekojiet saitei, lai ieietu.", "emails.magicSession.footer": "Ja Jūs nepieprasījāt ieiet ar šo e-pasta adresi, lūdzu, ignorējiet šo ziņu.", "emails.magicSession.thanks": "Paldies", diff --git a/app/config/locale/translations/ml.json b/app/config/locale/translations/ml.json index aff02854f4..a04955a34a 100644 --- a/app/config/locale/translations/ml.json +++ b/app/config/locale/translations/ml.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "നന്ദി", "emails.verification.signature": "{{project}} ടീം", "emails.magicSession.subject": "ലോഗിൻ", - "emails.magicSession.hello": "നമസ്കാരം,", + "emails.magicSession.hello": "നമസ്കാരം", "emails.magicSession.body": "ലോഗിൻ ചെയ്യുന്നതിനായി ഈ ലിങ്ക് പിന്തുടരുക.", "emails.magicSession.footer": "ഈ ഇമെയിൽ ഉപയോഗിച്ച് ലോഗിൻ ചെയ്യാൻ നിങ്ങൾ ആവശ്യപ്പെട്ടില്ലെങ്കിൽ, ഈ സന്ദേശം അവഗണിക്കാവുന്നതാണ്.", "emails.magicSession.thanks": "നന്ദി", diff --git a/app/config/locale/translations/mr.json b/app/config/locale/translations/mr.json index aba1588413..c9c13d232a 100644 --- a/app/config/locale/translations/mr.json +++ b/app/config/locale/translations/mr.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "धन्यवाद", "emails.verification.signature": "{{project}} संघ", "emails.magicSession.subject": "लॉगिन करा", - "emails.magicSession.hello": "नमस्कार ,", + "emails.magicSession.hello": "नमस्कार ", "emails.magicSession.body": "लॉगिन करण्यासाठी या लिंकचे अनुसरण करा.", "emails.magicSession.footer": "आपण या ईमेलचा वापर करून लॉगिन करण्यास सांगितले नसल्यास, आपण या संदेशाकडे दुर्लक्ष करू शकता.", "emails.magicSession.thanks": "धन्यवाद", diff --git a/app/config/locale/translations/ms.json b/app/config/locale/translations/ms.json index 7580247614..bfee137bdd 100644 --- a/app/config/locale/translations/ms.json +++ b/app/config/locale/translations/ms.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Terima kasih", "emails.verification.signature": "{{project}} team", "emails.magicSession.subject": "Log masuk", - "emails.magicSession.hello": "Hey,", + "emails.magicSession.hello": "Hey", "emails.magicSession.body": "Tekan pautan ini untuk log masuk.", "emails.magicSession.footer": "Sekiranya anda tidak membuat permintaan untuk log masuk menggunakan email ini, sila abaikan mesej ini.", "emails.magicSession.thanks": "Terima kasih", diff --git a/app/config/locale/translations/nb.json b/app/config/locale/translations/nb.json index 36b09a09cb..4561345336 100644 --- a/app/config/locale/translations/nb.json +++ b/app/config/locale/translations/nb.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Takk", "emails.verification.signature": "{{project}} team", "emails.magicSession.subject": "Pålogging", - "emails.magicSession.hello": "Hei,", + "emails.magicSession.hello": "Hei", "emails.magicSession.body": "Følg denne lenken for å logge på.", "emails.magicSession.footer": "Dersom du ikke ba om å logge på med denne e-postadressen, kan du se bort fra denne meldingen.", "emails.magicSession.thanks": "Takk", diff --git a/app/config/locale/translations/ne.json b/app/config/locale/translations/ne.json index 688bfea44e..ef5201ad9d 100644 --- a/app/config/locale/translations/ne.json +++ b/app/config/locale/translations/ne.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "धन्यवाद", "emails.verification.signature": "{{project}} समूह", "emails.magicSession.subject": "लगइन", - "emails.magicSession.hello": "नमस्ते,", + "emails.magicSession.hello": "नमस्ते", "emails.magicSession.body": "लगइन गर्नको लागी यो लिंकमा जानुहोस।", "emails.magicSession.footer": "यदि तपाइँले यो इमेल प्रयोग गरेर लगइन गर्न सोध्नु भएको छैन भने तपाइँले यो सन्देश लाई बेवास्ता गर्न सक्नुहुन्छ।", "emails.magicSession.thanks": "धन्यवाद", diff --git a/app/config/locale/translations/nl.json b/app/config/locale/translations/nl.json index f228b4e776..154df95b84 100644 --- a/app/config/locale/translations/nl.json +++ b/app/config/locale/translations/nl.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Bedankt", "emails.verification.signature": "{{project}} team", "emails.magicSession.subject": "Login", - "emails.magicSession.hello": "Hoi,", + "emails.magicSession.hello": "Hoi", "emails.magicSession.body": "Volg deze link om in te loggen", "emails.magicSession.footer": "Als u geen aanvraag heeft gemaakt om met deze mail in te loggen, kan u deze mail negeren", "emails.magicSession.thanks": "Bedankt", diff --git a/app/config/locale/translations/nn.json b/app/config/locale/translations/nn.json index d394c2a83f..bf2d338047 100644 --- a/app/config/locale/translations/nn.json +++ b/app/config/locale/translations/nn.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Takk", "emails.verification.signature": "{{project}} team", "emails.magicSession.subject": "Pålogging", - "emails.magicSession.hello": "Hei,", + "emails.magicSession.hello": "Hei", "emails.magicSession.body": "Følg denne lenkja for å logge på.", "emails.magicSession.footer": "Om du ikkje ba om å logge på med denne e-postadressa, kan du ignorera denne meldinga.", "emails.magicSession.thanks": "Takk", diff --git a/app/config/locale/translations/or.json b/app/config/locale/translations/or.json index 5afc1248bc..4039264859 100644 --- a/app/config/locale/translations/or.json +++ b/app/config/locale/translations/or.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "ଧନ୍ୟବାଦ", "emails.verification.signature": "{{project}} ଦଳ", "emails.magicSession.subject": "ଲଗଇନ୍ କରନ୍ତୁ", - "emails.magicSession.hello": "ନମସ୍କାର,", + "emails.magicSession.hello": "ନମସ୍କାର", "emails.magicSession.body": "ଲଗଇନ୍ କରିବାକୁ ଏହି ଲିଙ୍କ୍ ଅନୁସରଣ କରନ୍ତୁ |", "emails.magicSession.footer": "ଯଦି ଆପଣ ଏହି ଇମେଲ୍ ବ୍ୟବହାର କରି ଲଗଇନ୍ କରିବାକୁ କହି ନାହାଁନ୍ତି, ତେବେ ଆପଣ ଏହି ସନ୍ଦେଶକୁ ଉପେକ୍ଷା କରିପାରିବେ |", "emails.magicSession.thanks": "ଧନ୍ୟବାଦ", diff --git a/app/config/locale/translations/pl.json b/app/config/locale/translations/pl.json index 6275806f56..e295df738b 100644 --- a/app/config/locale/translations/pl.json +++ b/app/config/locale/translations/pl.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Dziękujemy", "emails.verification.signature": "Zespół {{project}}", "emails.magicSession.subject": "Logowanie", - "emails.magicSession.hello": "Cześć,", + "emails.magicSession.hello": "Cześć", "emails.magicSession.body": "Kliknij w ten link, aby zalogować się.", "emails.magicSession.footer": "Jeśli to nie Ty prosiłeś o logowanie przy użyciu tego adresu e-mail, zignoruj tę wiadomość.", "emails.magicSession.thanks": "Dziękujemy", diff --git a/app/config/locale/translations/pt-br.json b/app/config/locale/translations/pt-br.json index 849a0c6d82..23df374eea 100644 --- a/app/config/locale/translations/pt-br.json +++ b/app/config/locale/translations/pt-br.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Muito obrigado", "emails.verification.signature": "Time {{project}}", "emails.magicSession.subject": "Login", - "emails.magicSession.hello": "Olá,", + "emails.magicSession.hello": "Olá", "emails.magicSession.body": "Clique neste link para entrar.", "emails.magicSession.footer": "Se você não solicitou conectar-se com este e-mail, ignore essa mensagem.", "emails.magicSession.thanks": "Muito obrigado", diff --git a/app/config/locale/translations/pt-pt.json b/app/config/locale/translations/pt-pt.json index e849f616ff..7044aa0dc7 100644 --- a/app/config/locale/translations/pt-pt.json +++ b/app/config/locale/translations/pt-pt.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Obrigado", "emails.verification.signature": "Equipa {{project}}", "emails.magicSession.subject": "Login", - "emails.magicSession.hello": "Olá ,", + "emails.magicSession.hello": "Olá ", "emails.magicSession.body": "Siga esta ligação para iniciar sessão.", "emails.magicSession.footer": "Se não pediu para entrar usando este e-mail, pode ignorar esta mensagem.", "emails.magicSession.thanks": "Obrigado", diff --git a/app/config/locale/translations/ro.json b/app/config/locale/translations/ro.json index a01b060bd2..20d4a79f67 100644 --- a/app/config/locale/translations/ro.json +++ b/app/config/locale/translations/ro.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Mulțumim", "emails.verification.signature": "Echipa {{project}}", "emails.magicSession.subject": "Login", - "emails.magicSession.hello": "Bună ziua,", + "emails.magicSession.hello": "Bună ziua", "emails.magicSession.body": "Urmează acest link pentru logare.", "emails.magicSession.footer": "Dacă nu ai incercat să te loghezi folosing această adresa de email, poți ignora acest mesaj.", "emails.magicSession.thanks": "Mulțumim", diff --git a/app/config/locale/translations/ru.json b/app/config/locale/translations/ru.json index 7d8e9e3d50..10a9ca8a30 100644 --- a/app/config/locale/translations/ru.json +++ b/app/config/locale/translations/ru.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Спасибо", "emails.verification.signature": "команда {{project}}", "emails.magicSession.subject": "Логин", - "emails.magicSession.hello": "Здравствуйте,", + "emails.magicSession.hello": "Здравствуйте", "emails.magicSession.body": "Перейдите по ссылке, чтобы войти.", "emails.magicSession.footer": "Если вы не просили войти, используя этот адрес электронной почты, проигнорируйте это сообщение.", "emails.magicSession.thanks": "Спасибо", diff --git a/app/config/locale/translations/sa.json b/app/config/locale/translations/sa.json index 2f699d2f71..97ded60509 100644 --- a/app/config/locale/translations/sa.json +++ b/app/config/locale/translations/sa.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "धन्यवादः", "emails.verification.signature": "{{project}} गणः", "emails.magicSession.subject": "संप्रवेशः", - "emails.magicSession.hello": "अयि,", + "emails.magicSession.hello": "अयि", "emails.magicSession.body": "संप्रवेशार्थमिदं संयोगसूत्रमनुसरतु।", "emails.magicSession.footer": "अनेन ई-पत्रण यदि संप्रवेशो नेष्यते तर्हि वात्र्तामिमामुपेक्षताम्‌।", "emails.magicSession.thanks": "धन्यवादः", diff --git a/app/config/locale/translations/si.json b/app/config/locale/translations/si.json index ef3db15e1b..b63462a67a 100644 --- a/app/config/locale/translations/si.json +++ b/app/config/locale/translations/si.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "ස්තුතියි", "emails.verification.signature": "{{project}} කණ්ඩායම", "emails.magicSession.subject": "ප්‍රවේශ වන්න", - "emails.magicSession.hello": "හේයි,", + "emails.magicSession.hello": "හේයි", "emails.magicSession.body": "ප්‍රවේශ වීමට මෙම සම්බන්ධකය අනුගමනය කරන්න.", "emails.magicSession.footer": "මෙම විද්‍යුත් තැපෑල භාවිතයෙන් ප්‍රවේශ වීමට ඔබ ඉල්ලුවේ නැත්නම්, ඔබට මෙම පණිවිඩය නොසලකා හැරිය හැක.", "emails.magicSession.thanks": "ස්තුතියි", diff --git a/app/config/locale/translations/sk.json b/app/config/locale/translations/sk.json index 928eba2a49..ae4a46affa 100644 --- a/app/config/locale/translations/sk.json +++ b/app/config/locale/translations/sk.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Ďakujeme.", "emails.verification.signature": "{{project}} tím", "emails.magicSession.subject": "Prihlásenie", - "emails.magicSession.hello": "Ahoj,", + "emails.magicSession.hello": "Ahoj", "emails.magicSession.body": "Použi tento link pre prihlásenie.", "emails.magicSession.footer": "Ak si nepožiadal o prihlásenie cez email, túto správu môžeš ignorovať.", "emails.magicSession.thanks": "Ďakujeme", diff --git a/app/config/locale/translations/sn.json b/app/config/locale/translations/sn.json index 6c1ace9f04..a9aab0a661 100644 --- a/app/config/locale/translations/sn.json +++ b/app/config/locale/translations/sn.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Ndatenda", "emails.verification.signature": "Chikwata che{{project}}", "emails.magicSession.subject": "Pinda", - "emails.magicSession.hello": "Hesi,", + "emails.magicSession.hello": "Hesi", "emails.magicSession.body": "Baya chinongedzo ichi kuti upinde muakaundi yako.", "emails.magicSession.footer": "Kana usina kukumbira kupinda muakaundi yako uchishandisa email iyi, unogona kufuratira meseji iyi.", "emails.magicSession.thanks": "Ndatenda", diff --git a/app/config/locale/translations/sv.json b/app/config/locale/translations/sv.json index a5f459a2bc..98b826c515 100644 --- a/app/config/locale/translations/sv.json +++ b/app/config/locale/translations/sv.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Tack", "emails.verification.signature": "{{project}} teamet", "emails.magicSession.subject": "Logga in", - "emails.magicSession.hello": "Hej,", + "emails.magicSession.hello": "Hej", "emails.magicSession.body": "Klicka på denna länk för att logga in.", "emails.magicSession.footer": "Om du inte bad om att logga in med denna e-postadress kan du ignorera detta mail.", "emails.magicSession.thanks": "Tack", diff --git a/app/config/locale/translations/ta.json b/app/config/locale/translations/ta.json index 27d01a2519..ed45a1fddd 100644 --- a/app/config/locale/translations/ta.json +++ b/app/config/locale/translations/ta.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "நன்றி", "emails.verification.signature": "{{project}} குழு ", "emails.magicSession.subject": "உள்நுழைய", - "emails.magicSession.hello": "ஏய்,", + "emails.magicSession.hello": "ஏய்", "emails.magicSession.body": "இந்த இணைப்பைப் பின்தொடரவும் உள்நுழைய", "emails.magicSession.footer": "இந்த மின்னஞ்சலைப் பயன்படுத்தி உள்நுழையுமாறு உங்களிடம் கேட்கப்படாவிட்டால், இந்தச் செய்தியைப் புறக்கணிக்கலாம்.", "emails.magicSession.thanks": "நன்றி", diff --git a/app/config/locale/translations/te.json b/app/config/locale/translations/te.json index 045f2ff448..78937f8522 100644 --- a/app/config/locale/translations/te.json +++ b/app/config/locale/translations/te.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "ధన్యవాదాలు", "emails.verification.signature": "{{project}} జట్", "emails.magicSession.subject": "లాగిన్", - "emails.magicSession.hello": "నమస్కారము,", + "emails.magicSession.hello": "నమస్కారము", "emails.magicSession.body": "లాగిన్ చేయడానికి ఈ లింక్ ని అనుసరించండి", "emails.magicSession.footer": "మీరు ఈ ఇమెయిల్ ని ఉపయోగించి లాగిన్ చేయమని అడగకపోతే, మీరు ఈ సందేశాన్ని విస్మరించవచ్చు", "emails.magicSession.thanks": "ధన్యవాదాలు", diff --git a/app/config/locale/translations/th.json b/app/config/locale/translations/th.json index 2140ce33ce..98cce8fc4a 100644 --- a/app/config/locale/translations/th.json +++ b/app/config/locale/translations/th.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "ขอบคุณ", "emails.verification.signature": "ทีม {{project}}", "emails.magicSession.subject": "เข้าสู่ระบบ", - "emails.magicSession.hello": "เรียนผู้ใช้งาน,", + "emails.magicSession.hello": "เรียนผู้ใช้งาน", "emails.magicSession.body": "กดเข้าไปที่ลิงก์นี้เพื่อเข้าสู่ระบบ", "emails.magicSession.footer": "หากท่านไม่ได้ต้องการที่จะเข้าสู่ระบบด้วยอีเมลนี้ ท่านสามารถเพิกเฉยข้อความนี้ได้", "emails.magicSession.thanks": "ขอบคุณ", diff --git a/app/config/locale/translations/tl.json b/app/config/locale/translations/tl.json index 58ada0bb38..e50589fd53 100644 --- a/app/config/locale/translations/tl.json +++ b/app/config/locale/translations/tl.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Salamat", "emails.verification.signature": "Pangkat ng {{project}}", "emails.magicSession.subject": "Mag log in", - "emails.magicSession.hello": "Kamusta, ", + "emails.magicSession.hello": "Kamusta ", "emails.magicSession.body": "Sundin ang link na ito upang mag-login.", "emails.magicSession.footer": "Kung hindi mo hiningi na mag-login gamit ang email na ito, maaari mong balewalain ang mensahe na ito.", "emails.magicSession.thanks": "Salamat", diff --git a/app/config/locale/translations/tr.json b/app/config/locale/translations/tr.json index 534eaecc0e..da1fb00c61 100644 --- a/app/config/locale/translations/tr.json +++ b/app/config/locale/translations/tr.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Teşekkürler", "emails.verification.signature": "{{project}} takımı", "emails.magicSession.subject": "Giriş", - "emails.magicSession.hello": "Merhaba,", + "emails.magicSession.hello": "Merhaba", "emails.magicSession.body": "Giriş yapmak için tıklayın.", "emails.magicSession.footer": "Eğer bu eposta adresini kullanarak giriş yapmak istemediyseniz devam etmeyin.", "emails.magicSession.thanks": "Teşekkürler", diff --git a/app/config/locale/translations/uk.json b/app/config/locale/translations/uk.json index bd50cdee33..4427bfe196 100644 --- a/app/config/locale/translations/uk.json +++ b/app/config/locale/translations/uk.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Дякуємо", "emails.verification.signature": "команда {{project}}", "emails.magicSession.subject": "Логін", - "emails.magicSession.hello": "Вітаємо,", + "emails.magicSession.hello": "Вітаємо", "emails.magicSession.body": "Перейдіть за цим посиланням, щоб увійти.", "emails.magicSession.footer": "Якщо ви не просили увійти за допомогою цієї електронної пошти, ви можете ігнорувати це повідомлення.", "emails.magicSession.thanks": "Дякуємо", diff --git a/app/config/locale/translations/ur.json b/app/config/locale/translations/ur.json index 6e9128c39a..45f2f88ada 100644 --- a/app/config/locale/translations/ur.json +++ b/app/config/locale/translations/ur.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "شکریہ", "emails.verification.signature": "ٹیم۔ {{project}}", "emails.magicSession.subject": "اگ ان کریں", - "emails.magicSession.hello": "خوش آمدید,", + "emails.magicSession.hello": "خوش آمدید", "emails.magicSession.body": "لاگ ان کرنے کے لیے اس لنک پر عمل کریں۔", "emails.magicSession.footer": "اگر آپ نے اس ای میل کا استعمال کرتے ہوئے لاگ ان کرنے کے لیے نہیں کہا تو آپ اس پیغام کو نظر انداز کر سکتے ہیں۔", "emails.magicSession.thanks": "شکریہ", diff --git a/app/config/locale/translations/vi.json b/app/config/locale/translations/vi.json index b3e67eac11..79b743c3fc 100644 --- a/app/config/locale/translations/vi.json +++ b/app/config/locale/translations/vi.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "Cảm ơn", "emails.verification.signature": "Nhóm {{project}}", "emails.magicSession.subject": "Đăng nhập", - "emails.magicSession.hello": "Chào,", + "emails.magicSession.hello": "Chào", "emails.magicSession.body": "Nhấn vào đường dẫn sau để đăng nhập.", "emails.magicSession.footer": "Nếu bạn không yêu cầu đăng nhập bằng email, bạn có thể bỏ qua email này.", "emails.magicSession.thanks": "Cảm ơn", diff --git a/app/config/locale/translations/zh-cn.json b/app/config/locale/translations/zh-cn.json index 1ab47c57f5..d7b9288a8c 100644 --- a/app/config/locale/translations/zh-cn.json +++ b/app/config/locale/translations/zh-cn.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "谢谢", "emails.verification.signature": "{{project}} 团队", "emails.magicSession.subject": "登录", - "emails.magicSession.hello": "你好,", + "emails.magicSession.hello": "你好", "emails.magicSession.body": "点此链接登录。", "emails.magicSession.footer": "如果您没有要求使用此电子邮件登录,则可忽略此消息。", "emails.magicSession.thanks": "谢谢", diff --git a/app/config/locale/translations/zh-tw.json b/app/config/locale/translations/zh-tw.json index e0c5aa52ea..26037b2503 100644 --- a/app/config/locale/translations/zh-tw.json +++ b/app/config/locale/translations/zh-tw.json @@ -10,7 +10,7 @@ "emails.verification.thanks": "謝謝", "emails.verification.signature": "{{project}} 團隊", "emails.magicSession.subject": "登入", - "emails.magicSession.hello": "嗨,", + "emails.magicSession.hello": "嗨", "emails.magicSession.body": "點此連結登入。", "emails.magicSession.footer": "如果您沒有要求使用此電子郵件登入,則可以忽略此消息。", "emails.magicSession.thanks": "謝謝", diff --git a/app/config/runtimes-v2.php b/app/config/runtimes-v2.php index d249946d05..6957c694b2 100644 --- a/app/config/runtimes-v2.php +++ b/app/config/runtimes-v2.php @@ -5,11 +5,11 @@ */ use Appwrite\Runtimes\Runtimes; -use Utopia\App; +use Utopia\System\System; $runtimes = new Runtimes('v2'); -$allowList = empty(App::getEnv('_APP_FUNCTIONS_RUNTIMES')) ? [] : \explode(',', App::getEnv('_APP_FUNCTIONS_RUNTIMES')); +$allowList = empty(System::getEnv('_APP_FUNCTIONS_RUNTIMES')) ? [] : \explode(',', System::getEnv('_APP_FUNCTIONS_RUNTIMES')); $runtimes = $runtimes->getAll(true, $allowList); diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 89ccb1e30a..ee7dc076db 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -46,6 +46,7 @@ use Utopia\Database\Validator\Query\Limit; use Utopia\Database\Validator\Query\Offset; use Utopia\Database\Validator\UID; use Utopia\Locale\Locale; +use Utopia\System\System; use Utopia\Validator\ArrayList; use Utopia\Validator\Assoc; use Utopia\Validator\Boolean; @@ -1012,7 +1013,7 @@ App::get('/v1/account/sessions/oauth2/:provider') $appSecret = $project->getAttribute('oAuthProviders', [])[$provider . 'Secret'] ?? '{}'; if (!empty($appSecret) && isset($appSecret['version'])) { - $key = App::getEnv('_APP_OPENSSL_KEY_V' . $appSecret['version']); + $key = System::getEnv('_APP_OPENSSL_KEY_V' . $appSecret['version']); $appSecret = OpenSSL::decrypt($appSecret['data'], $appSecret['method'], $key, 0, \hex2bin($appSecret['iv']), \hex2bin($appSecret['tag'])); } @@ -1210,7 +1211,7 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') } if (!empty($appSecret) && isset($appSecret['version'])) { - $key = App::getEnv('_APP_OPENSSL_KEY_V' . $appSecret['version']); + $key = System::getEnv('_APP_OPENSSL_KEY_V' . $appSecret['version']); $appSecret = OpenSSL::decrypt($appSecret['data'], $appSecret['method'], $key, 0, \hex2bin($appSecret['iv']), \hex2bin($appSecret['tag'])); } @@ -1594,7 +1595,7 @@ App::get('/v1/account/tokens/oauth2/:provider') $appSecret = $project->getAttribute('oAuthProviders', [])[$provider . 'Secret'] ?? '{}'; if (!empty($appSecret) && isset($appSecret['version'])) { - $key = App::getEnv('_APP_OPENSSL_KEY_V' . $appSecret['version']); + $key = System::getEnv('_APP_OPENSSL_KEY_V' . $appSecret['version']); $appSecret = OpenSSL::decrypt($appSecret['data'], $appSecret['method'], $key, 0, \hex2bin($appSecret['iv']), \hex2bin($appSecret['tag'])); } @@ -1660,7 +1661,7 @@ App::post('/v1/account/tokens/magic-url') ->inject('queueForMails') ->action(function (string $userId, string $email, string $url, bool $phrase, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Locale $locale, Event $queueForEvents, Mail $queueForMails) { - if (empty(App::getEnv('_APP_SMTP_HOST'))) { + if (empty(System::getEnv('_APP_SMTP_HOST'))) { throw new Exception(Exception::GENERAL_SMTP_DISABLED, 'SMTP disabled'); } @@ -1788,8 +1789,8 @@ App::post('/v1/account/tokens/magic-url') $smtp = $project->getAttribute('smtp', []); $smtpEnabled = $smtp['enabled'] ?? false; - $senderEmail = App::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM); - $senderName = App::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server'); + $senderEmail = System::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM); + $senderName = System::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server'); $replyTo = ""; if ($smtpEnabled) { @@ -1901,7 +1902,7 @@ App::post('/v1/account/tokens/email') ->inject('queueForEvents') ->inject('queueForMails') ->action(function (string $userId, string $email, bool $phrase, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Locale $locale, Event $queueForEvents, Mail $queueForMails) { - if (empty(App::getEnv('_APP_SMTP_HOST'))) { + if (empty(System::getEnv('_APP_SMTP_HOST'))) { throw new Exception(Exception::GENERAL_SMTP_DISABLED, 'SMTP disabled'); } @@ -2017,8 +2018,8 @@ App::post('/v1/account/tokens/email') $smtp = $project->getAttribute('smtp', []); $smtpEnabled = $smtp['enabled'] ?? false; - $senderEmail = App::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM); - $senderName = App::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server'); + $senderEmail = System::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM); + $senderName = System::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server'); $replyTo = ""; if ($smtpEnabled) { @@ -2190,7 +2191,7 @@ App::post('/v1/account/tokens/phone') ->inject('queueForMessaging') ->inject('locale') ->action(function (string $userId, string $phone, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Event $queueForEvents, Messaging $queueForMessaging, Locale $locale) { - if (empty(App::getEnv('_APP_SMS_PROVIDER'))) { + if (empty(System::getEnv('_APP_SMS_PROVIDER'))) { throw new Exception(Exception::GENERAL_PHONE_DISABLED, 'Phone provider not configured'); } @@ -2364,7 +2365,7 @@ App::post('/v1/account/jwt') throw new Exception(Exception::USER_SESSION_NOT_FOUND); } - $jwt = new JWT(App::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', 900, 10); // Instantiate with key, algo, maxAge and leeway. + $jwt = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', 900, 10); // Instantiate with key, algo, maxAge and leeway. $response ->setStatusCode(Response::STATUS_CODE_CREATED) @@ -2845,7 +2846,7 @@ App::post('/v1/account/recovery') ->inject('queueForEvents') ->action(function (string $email, string $url, Request $request, Response $response, Document $user, Database $dbForProject, Document $project, Locale $locale, Mail $queueForMails, Event $queueForEvents) { - if (empty(App::getEnv('_APP_SMTP_HOST'))) { + if (empty(System::getEnv('_APP_SMTP_HOST'))) { throw new Exception(Exception::GENERAL_SMTP_DISABLED, 'SMTP Disabled'); } @@ -2915,8 +2916,8 @@ App::post('/v1/account/recovery') $smtp = $project->getAttribute('smtp', []); $smtpEnabled = $smtp['enabled'] ?? false; - $senderEmail = App::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM); - $senderName = App::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server'); + $senderEmail = System::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM); + $senderName = System::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server'); $replyTo = ""; if ($smtpEnabled) { @@ -3106,7 +3107,7 @@ App::post('/v1/account/verification') ->inject('queueForMails') ->action(function (string $url, Request $request, Response $response, Document $project, Document $user, Database $dbForProject, Locale $locale, Event $queueForEvents, Mail $queueForMails) { - if (empty(App::getEnv('_APP_SMTP_HOST'))) { + if (empty(System::getEnv('_APP_SMTP_HOST'))) { throw new Exception(Exception::GENERAL_SMTP_DISABLED, 'SMTP Disabled'); } @@ -3163,8 +3164,8 @@ App::post('/v1/account/verification') $smtp = $project->getAttribute('smtp', []); $smtpEnabled = $smtp['enabled'] ?? false; - $senderEmail = App::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM); - $senderName = App::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server'); + $senderEmail = System::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM); + $senderName = System::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server'); $replyTo = ""; if ($smtpEnabled) { @@ -3326,7 +3327,7 @@ App::post('/v1/account/verification/phone') ->inject('project') ->inject('locale') ->action(function (Request $request, Response $response, Document $user, Database $dbForProject, Event $queueForEvents, Messaging $queueForMessaging, Document $project, Locale $locale) { - if (empty(App::getEnv('_APP_SMS_PROVIDER'))) { + if (empty(System::getEnv('_APP_SMS_PROVIDER'))) { throw new Exception(Exception::GENERAL_PHONE_DISABLED, 'Phone provider not configured'); } @@ -3889,7 +3890,7 @@ App::post('/v1/account/mfa/challenge') switch ($factor) { case Type::PHONE: - if (empty(App::getEnv('_APP_SMS_PROVIDER'))) { + if (empty(System::getEnv('_APP_SMS_PROVIDER'))) { throw new Exception(Exception::GENERAL_PHONE_DISABLED, 'Phone provider not configured'); } if (empty($user->getAttribute('phone'))) { @@ -3927,7 +3928,7 @@ App::post('/v1/account/mfa/challenge') ->setProviderType(MESSAGE_TYPE_SMS); break; case Type::EMAIL: - if (empty(App::getEnv('_APP_SMTP_HOST'))) { + if (empty(System::getEnv('_APP_SMTP_HOST'))) { throw new Exception(Exception::GENERAL_SMTP_DISABLED, 'SMTP disabled'); } if (empty($user->getAttribute('email'))) { @@ -3958,8 +3959,8 @@ App::post('/v1/account/mfa/challenge') $smtp = $project->getAttribute('smtp', []); $smtpEnabled = $smtp['enabled'] ?? false; - $senderEmail = App::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM); - $senderName = App::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server'); + $senderEmail = System::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM); + $senderName = System::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server'); $replyTo = ""; if ($smtpEnabled) { diff --git a/app/controllers/api/avatars.php b/app/controllers/api/avatars.php index 6304482b14..fb4439344f 100644 --- a/app/controllers/api/avatars.php +++ b/app/controllers/api/avatars.php @@ -17,6 +17,7 @@ use Utopia\Domains\Domain; use Utopia\Image\Image; use Utopia\Logger\Log; use Utopia\Logger\Logger; +use Utopia\System\System; use Utopia\Validator\Boolean; use Utopia\Validator\HexColor; use Utopia\Validator\Range; @@ -155,7 +156,7 @@ $getUserGitHub = function (string $userId, Document $project, Database $dbForPro ]; } catch (Exception $error) { if ($logger) { - $version = App::getEnv('_APP_VERSION', 'UNKNOWN'); + $version = System::getEnv('_APP_VERSION', 'UNKNOWN'); $log = new Log(); $log->setNamespace('console'); @@ -174,7 +175,7 @@ $getUserGitHub = function (string $userId, Document $project, Database $dbForPro $log->setAction('avatarsGetGitHub'); - $isProduction = App::getEnv('_APP_ENV', 'development') === 'production'; + $isProduction = System::getEnv('_APP_ENV', 'development') === 'production'; $log->setEnvironment($isProduction ? Log::ENVIRONMENT_PRODUCTION : Log::ENVIRONMENT_STAGING); $responseCode = $logger->addLog($log); @@ -348,8 +349,8 @@ App::get('/v1/avatars/favicon') CURLOPT_URL => $url, CURLOPT_USERAGENT => \sprintf( APP_USERAGENT, - App::getEnv('_APP_VERSION', 'UNKNOWN'), - App::getEnv('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY) + System::getEnv('_APP_VERSION', 'UNKNOWN'), + System::getEnv('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY) ), ]); diff --git a/app/controllers/api/console.php b/app/controllers/api/console.php index 5abcd0fa23..82d7c75592 100644 --- a/app/controllers/api/console.php +++ b/app/controllers/api/console.php @@ -4,6 +4,7 @@ use Appwrite\Extend\Exception; use Appwrite\Utopia\Response; use Utopia\App; use Utopia\Database\Document; +use Utopia\System\System; use Utopia\Validator\Text; App::init() @@ -29,24 +30,24 @@ App::get('/v1/console/variables') ->label('sdk.response.model', Response::MODEL_CONSOLE_VARIABLES) ->inject('response') ->action(function (Response $response) { - $isDomainEnabled = !empty(App::getEnv('_APP_DOMAIN', '')) - && !empty(App::getEnv('_APP_DOMAIN_TARGET', '')) - && App::getEnv('_APP_DOMAIN', '') !== 'localhost' - && App::getEnv('_APP_DOMAIN_TARGET', '') !== 'localhost'; + $isDomainEnabled = !empty(System::getEnv('_APP_DOMAIN', '')) + && !empty(System::getEnv('_APP_DOMAIN_TARGET', '')) + && System::getEnv('_APP_DOMAIN', '') !== 'localhost' + && System::getEnv('_APP_DOMAIN_TARGET', '') !== 'localhost'; - $isVcsEnabled = !empty(App::getEnv('_APP_VCS_GITHUB_APP_NAME', '')) - && !empty(App::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY', '')) - && !empty(App::getEnv('_APP_VCS_GITHUB_APP_ID', '')) - && !empty(App::getEnv('_APP_VCS_GITHUB_CLIENT_ID', '')) - && !empty(App::getEnv('_APP_VCS_GITHUB_CLIENT_SECRET', '')); + $isVcsEnabled = !empty(System::getEnv('_APP_VCS_GITHUB_APP_NAME', '')) + && !empty(System::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY', '')) + && !empty(System::getEnv('_APP_VCS_GITHUB_APP_ID', '')) + && !empty(System::getEnv('_APP_VCS_GITHUB_CLIENT_ID', '')) + && !empty(System::getEnv('_APP_VCS_GITHUB_CLIENT_SECRET', '')); - $isAssistantEnabled = !empty(App::getEnv('_APP_ASSISTANT_OPENAI_API_KEY', '')); + $isAssistantEnabled = !empty(System::getEnv('_APP_ASSISTANT_OPENAI_API_KEY', '')); $variables = new Document([ - '_APP_DOMAIN_TARGET' => App::getEnv('_APP_DOMAIN_TARGET'), - '_APP_STORAGE_LIMIT' => +App::getEnv('_APP_STORAGE_LIMIT'), - '_APP_FUNCTIONS_SIZE_LIMIT' => +App::getEnv('_APP_FUNCTIONS_SIZE_LIMIT'), - '_APP_USAGE_STATS' => App::getEnv('_APP_USAGE_STATS'), + '_APP_DOMAIN_TARGET' => System::getEnv('_APP_DOMAIN_TARGET'), + '_APP_STORAGE_LIMIT' => +System::getEnv('_APP_STORAGE_LIMIT'), + '_APP_FUNCTIONS_SIZE_LIMIT' => +System::getEnv('_APP_FUNCTIONS_SIZE_LIMIT'), + '_APP_USAGE_STATS' => System::getEnv('_APP_USAGE_STATS'), '_APP_VCS_ENABLED' => $isVcsEnabled, '_APP_DOMAIN_ENABLED' => $isDomainEnabled, '_APP_ASSISTANT_ENABLED' => $isAssistantEnabled diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index e4b353dd0d..ed5af1d38a 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -40,6 +40,7 @@ use Utopia\Storage\Validator\FileExt; use Utopia\Storage\Validator\FileSize; use Utopia\Storage\Validator\Upload; use Utopia\Swoole\Request; +use Utopia\System\System; use Utopia\Validator\ArrayList; use Utopia\Validator\Assoc; use Utopia\Validator\Boolean; @@ -55,8 +56,8 @@ $redeployVcs = function (Request $request, Document $function, Document $project $deploymentId = ID::unique(); $entrypoint = $function->getAttribute('entrypoint', ''); $providerInstallationId = $installation->getAttribute('providerInstallationId', ''); - $privateKey = App::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); - $githubAppId = App::getEnv('_APP_VCS_GITHUB_APP_ID'); + $privateKey = System::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); + $githubAppId = System::getEnv('_APP_VCS_GITHUB_APP_ID'); $github->initializeVariables($providerInstallationId, $privateKey, $githubAppId); $owner = $github->getOwnerName($providerInstallationId); $providerRepositoryId = $function->getAttribute('providerRepositoryId', ''); @@ -144,7 +145,7 @@ App::post('/v1/functions') ->param('execute', [], new Roles(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' roles are allowed, each 64 characters long.', true) ->param('events', [], new ArrayList(new FunctionEvent(), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Events list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' events are allowed.', true) ->param('schedule', '', new Cron(), 'Schedule CRON syntax.', true) - ->param('timeout', 15, new Range(1, (int) App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900)), 'Function maximum execution time in seconds.', true) + ->param('timeout', 15, new Range(1, (int) System::getEnv('_APP_FUNCTIONS_TIMEOUT', 900)), 'Function maximum execution time in seconds.', true) ->param('enabled', true, new Boolean(), 'Is function enabled? When set to \'disabled\', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled.', true) ->param('logging', true, new Boolean(), 'Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.', true) ->param('entrypoint', '', new Text(1028, 0), 'Entrypoint File. This path is relative to the "providerRootDirectory".', true) @@ -170,7 +171,7 @@ App::post('/v1/functions') ->action(function (string $functionId, string $name, string $runtime, array $execute, array $events, string $schedule, int $timeout, bool $enabled, bool $logging, string $entrypoint, string $commands, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateBranch, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github) use ($redeployVcs) { $functionId = ($functionId == 'unique()') ? ID::unique() : $functionId; - $allowList = \array_filter(\explode(',', App::getEnv('_APP_FUNCTIONS_RUNTIMES', ''))); + $allowList = \array_filter(\explode(',', System::getEnv('_APP_FUNCTIONS_RUNTIMES', ''))); if (!empty($allowList) && !\in_array($runtime, $allowList)) { throw new Exception(Exception::FUNCTION_RUNTIME_UNSUPPORTED, 'Runtime "' . $runtime . '" is not supported'); @@ -231,7 +232,7 @@ App::post('/v1/functions') $schedule = Authorization::skip( fn () => $dbForConsole->createDocument('schedules', new Document([ - 'region' => App::getEnv('_APP_REGION', 'default'), // Todo replace with projects region + 'region' => System::getEnv('_APP_REGION', 'default'), // Todo replace with projects region 'resourceType' => 'function', 'resourceId' => $function->getId(), 'resourceInternalId' => $function->getInternalId(), @@ -280,7 +281,7 @@ App::post('/v1/functions') $redeployVcs($request, $function, $project, $installation, $dbForProject, $queueForBuilds, $template, $github); } - $functionsDomain = App::getEnv('_APP_DOMAIN_FUNCTIONS', ''); + $functionsDomain = System::getEnv('_APP_DOMAIN_FUNCTIONS', ''); if (!empty($functionsDomain)) { $ruleId = ID::unique(); $routeSubdomain = ID::unique(); @@ -422,7 +423,7 @@ App::get('/v1/functions/runtimes') ->action(function (Response $response) { $runtimes = Config::getParam('runtimes'); - $allowList = \array_filter(\explode(',', App::getEnv('_APP_FUNCTIONS_RUNTIMES', ''))); + $allowList = \array_filter(\explode(',', System::getEnv('_APP_FUNCTIONS_RUNTIMES', ''))); $allowed = []; foreach ($runtimes as $key => $runtime) { @@ -675,7 +676,7 @@ App::put('/v1/functions/:functionId') ->param('execute', [], new Roles(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' roles are allowed, each 64 characters long.', true) ->param('events', [], new ArrayList(new FunctionEvent(), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Events list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' events are allowed.', true) ->param('schedule', '', new Cron(), 'Schedule CRON syntax.', true) - ->param('timeout', 15, new Range(1, (int) App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900)), 'Maximum execution time in seconds.', true) + ->param('timeout', 15, new Range(1, (int) System::getEnv('_APP_FUNCTIONS_TIMEOUT', 900)), 'Maximum execution time in seconds.', true) ->param('enabled', true, new Boolean(), 'Is function enabled? When set to \'disabled\', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled.', true) ->param('logging', true, new Boolean(), 'Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.', true) ->param('entrypoint', '', new Text(1028, 0), 'Entrypoint File. This path is relative to the "providerRootDirectory".', true) @@ -1091,7 +1092,7 @@ App::post('/v1/functions/:functionId/deployments') } $fileExt = new FileExt([FileExt::TYPE_GZIP]); - $fileSizeValidator = new FileSize(App::getEnv('_APP_FUNCTIONS_SIZE_LIMIT', '30000000')); + $fileSizeValidator = new FileSize(System::getEnv('_APP_FUNCTIONS_SIZE_LIMIT', '30000000')); $upload = new Upload(); // Make sure we handle a single file and multiple files the same way @@ -1580,7 +1581,7 @@ App::post('/v1/functions/:functionId/executions') } if (!$current->isEmpty()) { - $jwtObj = new JWT(App::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', 900, 10); // Instantiate with key, algo, maxAge and leeway. + $jwtObj = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', 900, 10); // Instantiate with key, algo, maxAge and leeway. $jwt = $jwtObj->encode([ 'userId' => $user->getId(), 'sessionId' => $current->getId(), @@ -1703,7 +1704,7 @@ App::post('/v1/functions/:functionId/executions') ]); /** Execute function */ - $executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST')); + $executor = new Executor(System::getEnv('_APP_EXECUTOR_HOST')); try { $version = $function->getAttribute('version', 'v2'); $command = $runtime['startCommand']; diff --git a/app/controllers/api/graphql.php b/app/controllers/api/graphql.php index f4cfba9ea2..f79f433b5c 100644 --- a/app/controllers/api/graphql.php +++ b/app/controllers/api/graphql.php @@ -17,6 +17,7 @@ use Swoole\Coroutine\WaitGroup; use Utopia\App; use Utopia\Database\Document; use Utopia\Database\Validator\Authorization; +use Utopia\System\System; use Utopia\Validator\JSON; use Utopia\Validator\Text; @@ -177,9 +178,9 @@ function execute( Adapter $promiseAdapter, array $query ): array { - $maxBatchSize = App::getEnv('_APP_GRAPHQL_MAX_BATCH_SIZE', 10); - $maxComplexity = App::getEnv('_APP_GRAPHQL_MAX_COMPLEXITY', 250); - $maxDepth = App::getEnv('_APP_GRAPHQL_MAX_DEPTH', 3); + $maxBatchSize = System::getEnv('_APP_GRAPHQL_MAX_BATCH_SIZE', 10); + $maxComplexity = System::getEnv('_APP_GRAPHQL_MAX_COMPLEXITY', 250); + $maxDepth = System::getEnv('_APP_GRAPHQL_MAX_DEPTH', 3); if (!empty($query) && !isset($query[0])) { $query = [$query]; @@ -199,7 +200,7 @@ function execute( $flags = DebugFlag::INCLUDE_DEBUG_MESSAGE | DebugFlag::INCLUDE_TRACE; $validations = GraphQL::getStandardValidationRules(); - if (App::getEnv('_APP_OPTIONS_ABUSE', 'enabled') !== 'disabled') { + if (System::getEnv('_APP_OPTIONS_ABUSE', 'enabled') !== 'disabled') { $validations[] = new DisableIntrospection(); $validations[] = new QueryComplexity($maxComplexity); $validations[] = new QueryDepth($maxDepth); diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index e7a4f4a0b1..c215a78a8b 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -15,6 +15,7 @@ use Utopia\Registry\Registry; use Utopia\Storage\Device; use Utopia\Storage\Device\Local; use Utopia\Storage\Storage; +use Utopia\System\System; use Utopia\Validator\Domain; use Utopia\Validator\Integer; use Utopia\Validator\Multiple; @@ -816,13 +817,13 @@ App::get('/v1/health/anti-virus') 'version' => '' ]; - if (App::getEnv('_APP_STORAGE_ANTIVIRUS') === 'disabled') { // Check if scans are enabled + if (System::getEnv('_APP_STORAGE_ANTIVIRUS') === 'disabled') { // Check if scans are enabled $output['status'] = 'disabled'; $output['version'] = ''; } else { $antivirus = new Network( - App::getEnv('_APP_STORAGE_ANTIVIRUS_HOST', 'clamav'), - (int) App::getEnv('_APP_STORAGE_ANTIVIRUS_PORT', 3310) + System::getEnv('_APP_STORAGE_ANTIVIRUS_HOST', 'clamav'), + (int) System::getEnv('_APP_STORAGE_ANTIVIRUS_PORT', 3310) ); try { diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 8951839039..0a4f10c994 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -37,6 +37,7 @@ use Utopia\Database\Validator\Query\Offset; use Utopia\Database\Validator\Roles; use Utopia\Database\Validator\UID; use Utopia\Locale\Locale; +use Utopia\System\System; use Utopia\Validator\ArrayList; use Utopia\Validator\Boolean; use Utopia\Validator\Integer; @@ -2126,8 +2127,6 @@ App::get('/v1/messaging/topics/:topicId') throw new Exception(Exception::TOPIC_NOT_FOUND); } - $topic = $dbForProject->getDocument('topics', $topicId); - $response ->dynamic($topic, Response::MODEL_TOPIC); }); @@ -2695,7 +2694,7 @@ App::post('/v1/messaging/messages/email') break; case MessageStatus::SCHEDULED: $schedule = $dbForConsole->createDocument('schedules', new Document([ - 'region' => App::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default'), 'resourceType' => 'message', 'resourceId' => $message->getId(), 'resourceInternalId' => $message->getInternalId(), @@ -2811,7 +2810,7 @@ App::post('/v1/messaging/messages/sms') break; case MessageStatus::SCHEDULED: $schedule = $dbForConsole->createDocument('schedules', new Document([ - 'region' => App::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default'), 'resourceType' => 'message', 'resourceId' => $message->getId(), 'resourceInternalId' => $message->getInternalId(), @@ -2933,8 +2932,8 @@ App::post('/v1/messaging/messages/push') throw new Exception(Exception::STORAGE_FILE_TYPE_UNSUPPORTED); } - $host = App::getEnv('_APP_DOMAIN', 'localhost'); - $protocol = App::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https'; + $host = System::getEnv('_APP_DOMAIN', 'localhost'); + $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https'; $scheduleTime = $currentScheduledAt ?? $scheduledAt; if (!\is_null($scheduleTime)) { @@ -2943,7 +2942,7 @@ App::post('/v1/messaging/messages/push') $expiry = (new \DateTime())->add(new \DateInterval('P15D'))->format('U'); } - $encoder = new JWT(App::getEnv('_APP_OPENSSL_KEY_V1')); + $encoder = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1')); $jwt = $encoder->encode([ 'iat' => \time(), @@ -2989,7 +2988,7 @@ App::post('/v1/messaging/messages/push') break; case MessageStatus::SCHEDULED: $schedule = $dbForConsole->createDocument('schedules', new Document([ - 'region' => App::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default'), 'resourceType' => 'message', 'resourceId' => $message->getId(), 'resourceInternalId' => $message->getInternalId(), @@ -3332,7 +3331,7 @@ App::patch('/v1/messaging/messages/email/:messageId') if (\is_null($currentScheduledAt) && !\is_null($scheduledAt)) { $schedule = $dbForConsole->createDocument('schedules', new Document([ - 'region' => App::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default'), 'resourceType' => 'message', 'resourceId' => $message->getId(), 'resourceInternalId' => $message->getInternalId(), @@ -3503,7 +3502,7 @@ App::patch('/v1/messaging/messages/sms/:messageId') if (\is_null($currentScheduledAt) && !\is_null($scheduledAt)) { $schedule = $dbForConsole->createDocument('schedules', new Document([ - 'region' => App::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default'), 'resourceType' => 'message', 'resourceId' => $message->getId(), 'resourceInternalId' => $message->getInternalId(), @@ -3667,7 +3666,7 @@ App::patch('/v1/messaging/messages/push/:messageId') if (\is_null($currentScheduledAt) && !\is_null($scheduledAt)) { $schedule = $dbForConsole->createDocument('schedules', new Document([ - 'region' => App::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default'), 'resourceType' => 'message', 'resourceId' => $message->getId(), 'resourceInternalId' => $message->getInternalId(), @@ -3770,8 +3769,8 @@ App::patch('/v1/messaging/messages/push/:messageId') throw new Exception(Exception::STORAGE_FILE_TYPE_UNSUPPORTED); } - $host = App::getEnv('_APP_DOMAIN', 'localhost'); - $protocol = App::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https'; + $host = System::getEnv('_APP_DOMAIN', 'localhost'); + $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https'; $scheduleTime = $currentScheduledAt ?? $scheduledAt; if (!\is_null($scheduleTime)) { @@ -3780,7 +3779,7 @@ App::patch('/v1/messaging/messages/push/:messageId') $expiry = (new \DateTime())->add(new \DateInterval('P15D'))->format('U'); } - $encoder = new JWT(App::getEnv('_APP_OPENSSL_KEY_V1')); + $encoder = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1')); $jwt = $encoder->encode([ 'iat' => \time(), diff --git a/app/controllers/api/migrations.php b/app/controllers/api/migrations.php index 0831a473cb..3899b26ad4 100644 --- a/app/controllers/api/migrations.php +++ b/app/controllers/api/migrations.php @@ -21,6 +21,7 @@ use Utopia\Migration\Sources\Appwrite; use Utopia\Migration\Sources\Firebase; use Utopia\Migration\Sources\NHost; use Utopia\Migration\Sources\Supabase; +use Utopia\System\System; use Utopia\Validator\ArrayList; use Utopia\Validator\Host; use Utopia\Validator\Integer; @@ -109,8 +110,8 @@ App::post('/v1/migrations/firebase/oauth') ->inject('request') ->action(function (array $resources, string $projectId, Response $response, Database $dbForProject, Database $dbForConsole, Document $project, Document $user, Event $queueForEvents, Migration $queueForMigrations, Request $request) { $firebase = new OAuth2Firebase( - App::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_ID', ''), - App::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_SECRET', ''), + System::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_ID', ''), + System::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_SECRET', ''), $request->getProtocol() . '://' . $request->getHostname() . '/v1/migrations/firebase/redirect' ); @@ -553,8 +554,8 @@ App::get('/v1/migrations/firebase/report/oauth') ->inject('dbForConsole') ->action(function (array $resources, string $projectId, Response $response, Request $request, Document $user, Database $dbForConsole) { $firebase = new OAuth2Firebase( - App::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_ID', ''), - App::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_SECRET', ''), + System::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_ID', ''), + System::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_SECRET', ''), $request->getProtocol() . '://' . $request->getHostname() . '/v1/migrations/firebase/redirect' ); @@ -575,7 +576,7 @@ App::get('/v1/migrations/firebase/report/oauth') throw new Exception(Exception::USER_IDENTITY_NOT_FOUND); } - if (App::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_ID', '') === '' || App::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_SECRET', '') === '') { + if (System::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_ID', '') === '' || System::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_SECRET', '') === '') { throw new Exception(Exception::USER_IDENTITY_NOT_FOUND); } @@ -655,8 +656,8 @@ App::get('/v1/migrations/firebase/connect') $dbForConsole->updateDocument('users', $user->getId(), $user); $oauth2 = new OAuth2Firebase( - App::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_ID', ''), - App::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_SECRET', ''), + System::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_ID', ''), + System::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_SECRET', ''), $request->getProtocol() . '://' . $request->getHostname() . '/v1/migrations/firebase/redirect' ); $url = $oauth2->getLoginURL(); @@ -710,8 +711,8 @@ App::get('/v1/migrations/firebase/redirect') // OAuth Authroization if (!empty($code)) { $oauth2 = new OAuth2Firebase( - App::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_ID', ''), - App::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_SECRET', ''), + System::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_ID', ''), + System::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_SECRET', ''), $request->getProtocol() . '://' . $request->getHostname() . '/v1/migrations/firebase/redirect' ); @@ -797,8 +798,8 @@ App::get('/v1/migrations/firebase/projects') ->inject('request') ->action(function (Document $user, Response $response, Document $project, Database $dbForConsole, Request $request) { $firebase = new OAuth2Firebase( - App::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_ID', ''), - App::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_SECRET', ''), + System::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_ID', ''), + System::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_SECRET', ''), $request->getProtocol() . '://' . $request->getHostname() . '/v1/migrations/firebase/redirect' ); @@ -819,7 +820,7 @@ App::get('/v1/migrations/firebase/projects') throw new Exception(Exception::USER_IDENTITY_NOT_FOUND); } - if (App::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_ID', '') === '' || App::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_SECRET', '') === '') { + if (System::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_ID', '') === '' || System::getEnv('_APP_MIGRATIONS_FIREBASE_CLIENT_SECRET', '') === '') { throw new Exception(Exception::USER_IDENTITY_NOT_FOUND); } diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index c6d9dfa6eb..cb75b76da5 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -30,6 +30,7 @@ use Utopia\Database\Validator\UID; use Utopia\Domains\Validator\PublicDomain; use Utopia\Locale\Locale; use Utopia\Pools\Group; +use Utopia\System\System; use Utopia\Validator\ArrayList; use Utopia\Validator\Boolean; use Utopia\Validator\Hostname; @@ -62,7 +63,7 @@ App::post('/v1/projects') ->param('projectId', '', new ProjectId(), 'Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can\'t start with a special char. Max length is 36 chars.') ->param('name', null, new Text(128), 'Project name. Max length: 128 chars.') ->param('teamId', '', new UID(), 'Team unique ID.') - ->param('region', App::getEnv('_APP_REGION', 'default'), new Whitelist(array_keys(array_filter(Config::getParam('regions'), fn ($config) => !$config['disabled']))), 'Project Region.', true) + ->param('region', System::getEnv('_APP_REGION', 'default'), new Whitelist(array_keys(array_filter(Config::getParam('regions'), fn ($config) => !$config['disabled']))), 'Project Region.', true) ->param('description', '', new Text(256), 'Project description. Max length: 256 chars.', true) ->param('logo', '', new Text(1024), 'Project logo.', true) ->param('url', '', new URL(), 'Project URL.', true) @@ -84,7 +85,7 @@ App::post('/v1/projects') throw new Exception(Exception::TEAM_NOT_FOUND); } - $allowList = \array_filter(\explode(',', App::getEnv('_APP_PROJECT_REGIONS', ''))); + $allowList = \array_filter(\explode(',', System::getEnv('_APP_PROJECT_REGIONS', ''))); if (!empty($allowList) && !\in_array($region, $allowList)) { throw new Exception(Exception::PROJECT_REGION_UNSUPPORTED, 'Region "' . $region . '" is not supported'); @@ -127,7 +128,7 @@ App::post('/v1/projects') } } - $databaseOverride = App::getEnv('_APP_DATABASE_OVERRIDE', null); + $databaseOverride = System::getEnv('_APP_DATABASE_OVERRIDE', null); $index = array_search($databaseOverride, $databases); if ($index !== false) { $database = $databases[$index]; @@ -1613,8 +1614,8 @@ App::post('/v1/projects/:projectId/smtp/tests') ->label('sdk.response.model', Response::MODEL_NONE) ->param('projectId', '', new UID(), 'Project unique ID.') ->param('emails', [], new ArrayList(new Email(), 10), 'Array of emails to send test email to. Maximum of 10 emails are allowed.') - ->param('senderName', App::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server'), new Text(255, 0), 'Name of the email sender') - ->param('senderEmail', App::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM), new Email(), 'Email of the sender') + ->param('senderName', System::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server'), new Text(255, 0), 'Name of the email sender') + ->param('senderEmail', System::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM), new Email(), 'Email of the sender') ->param('replyTo', '', new Email(), 'Reply to email', true) ->param('host', '', new HostName(), 'SMTP server host name') ->param('port', 587, new Integer(), 'SMTP server port', true) diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index b8f889c958..1dfbc0ba0f 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -16,6 +16,7 @@ use Utopia\Database\Query; use Utopia\Database\Validator\UID; use Utopia\Domains\Domain; use Utopia\Logger\Log; +use Utopia\System\System; use Utopia\Validator\Domain as ValidatorDomain; use Utopia\Validator\Text; use Utopia\Validator\WhiteList; @@ -44,7 +45,7 @@ App::post('/v1/proxy/rules') ->inject('dbForConsole') ->inject('dbForProject') ->action(function (string $domain, string $resourceType, string $resourceId, Response $response, Document $project, Certificate $queueForCertificates, Event $queueForEvents, Database $dbForConsole, Database $dbForProject) { - $mainDomain = App::getEnv('_APP_DOMAIN', ''); + $mainDomain = System::getEnv('_APP_DOMAIN', ''); if ($domain === $mainDomain) { throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'You cannot assign your main domain to specific resource. Please use subdomain or a different domain.'); } @@ -108,13 +109,13 @@ App::post('/v1/proxy/rules') ]); $status = 'created'; - $functionsDomain = App::getEnv('_APP_DOMAIN_FUNCTIONS'); + $functionsDomain = System::getEnv('_APP_DOMAIN_FUNCTIONS'); if (!empty($functionsDomain) && \str_ends_with($domain->get(), $functionsDomain)) { $status = 'verified'; } if ($status === 'created') { - $target = new Domain(App::getEnv('_APP_DOMAIN_TARGET', '')); + $target = new Domain(System::getEnv('_APP_DOMAIN_TARGET', '')); $validator = new CNAME($target->get()); // Verify Domain with DNS records if ($validator->isValid($domain->get())) { @@ -296,7 +297,7 @@ App::patch('/v1/proxy/rules/:ruleId/verification') throw new Exception(Exception::RULE_NOT_FOUND); } - $target = new Domain(App::getEnv('_APP_DOMAIN_TARGET', '')); + $target = new Domain(System::getEnv('_APP_DOMAIN_TARGET', '')); if (!$target->isKnown() || $target->isTest()) { throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Domain target must be configured as environment variable.'); diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index f3d7f318ef..97a0eb488a 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -39,6 +39,7 @@ use Utopia\Storage\Validator\FileExt; use Utopia\Storage\Validator\FileSize; use Utopia\Storage\Validator\Upload; use Utopia\Swoole\Request; +use Utopia\System\System; use Utopia\Validator\ArrayList; use Utopia\Validator\Boolean; use Utopia\Validator\HexColor; @@ -65,7 +66,7 @@ App::post('/v1/storage/buckets') ->param('permissions', null, new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) ->param('fileSecurity', false, new Boolean(true), 'Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) ->param('enabled', true, new Boolean(true), 'Is bucket enabled? When set to \'disabled\', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled.', true) - ->param('maximumFileSize', (int) App::getEnv('_APP_STORAGE_LIMIT', 0), new Range(1, (int) App::getEnv('_APP_STORAGE_LIMIT', 0)), 'Maximum file size allowed in bytes. Maximum allowed value is ' . Storage::human(App::getEnv('_APP_STORAGE_LIMIT', 0), 0) . '.', true) + ->param('maximumFileSize', (int) System::getEnv('_APP_STORAGE_LIMIT', 0), new Range(1, (int) System::getEnv('_APP_STORAGE_LIMIT', 0)), 'Maximum file size allowed in bytes. Maximum allowed value is ' . Storage::human(System::getEnv('_APP_STORAGE_LIMIT', 0), 0) . '.', true) ->param('allowedFileExtensions', [], new ArrayList(new Text(64), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Allowed file extensions. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' extensions are allowed, each 64 characters long.', true) ->param('compression', Compression::NONE, new WhiteList([Compression::NONE, Compression::GZIP, Compression::ZSTD]), 'Compression algorithm choosen for compression. Can be one of ' . Compression::NONE . ', [' . Compression::GZIP . '](https://en.wikipedia.org/wiki/Gzip), or [' . Compression::ZSTD . '](https://en.wikipedia.org/wiki/Zstd), For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' compression is skipped even if it\'s enabled', true) ->param('encryption', true, new Boolean(true), 'Is encryption enabled? For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' encryption is skipped even if it\'s enabled', true) @@ -242,7 +243,7 @@ App::put('/v1/storage/buckets/:bucketId') ->param('permissions', null, new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) ->param('fileSecurity', false, new Boolean(true), 'Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) ->param('enabled', true, new Boolean(true), 'Is bucket enabled? When set to \'disabled\', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled.', true) - ->param('maximumFileSize', null, new Range(1, (int) App::getEnv('_APP_STORAGE_LIMIT', 0)), 'Maximum file size allowed in bytes. Maximum allowed value is ' . Storage::human((int)App::getEnv('_APP_STORAGE_LIMIT', 0), 0) . '.', true) + ->param('maximumFileSize', null, new Range(1, (int) System::getEnv('_APP_STORAGE_LIMIT', 0)), 'Maximum file size allowed in bytes. Maximum allowed value is ' . Storage::human((int)System::getEnv('_APP_STORAGE_LIMIT', 0), 0) . '.', true) ->param('allowedFileExtensions', [], new ArrayList(new Text(64), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Allowed file extensions. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' extensions are allowed, each 64 characters long.', true) ->param('compression', Compression::NONE, new WhiteList([Compression::NONE, Compression::GZIP, Compression::ZSTD]), 'Compression algorithm choosen for compression. Can be one of ' . Compression::NONE . ', [' . Compression::GZIP . '](https://en.wikipedia.org/wiki/Gzip), or [' . Compression::ZSTD . '](https://en.wikipedia.org/wiki/Zstd), For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' compression is skipped even if it\'s enabled', true) ->param('encryption', true, new Boolean(true), 'Is encryption enabled? For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' encryption is skipped even if it\'s enabled', true) @@ -258,7 +259,7 @@ App::put('/v1/storage/buckets/:bucketId') } $permissions ??= $bucket->getPermissions(); - $maximumFileSize ??= $bucket->getAttribute('maximumFileSize', (int) App::getEnv('_APP_STORAGE_LIMIT', 0)); + $maximumFileSize ??= $bucket->getAttribute('maximumFileSize', (int) System::getEnv('_APP_STORAGE_LIMIT', 0)); $allowedFileExtensions ??= $bucket->getAttribute('allowedFileExtensions', []); $enabled ??= $bucket->getAttribute('enabled', true); $encryption ??= $bucket->getAttribute('encryption', true); @@ -420,7 +421,7 @@ App::post('/v1/storage/buckets/:bucketId/files') } $maximumFileSize = $bucket->getAttribute('maximumFileSize', 0); - if ($maximumFileSize > (int) App::getEnv('_APP_STORAGE_LIMIT', 0)) { + if ($maximumFileSize > (int) System::getEnv('_APP_STORAGE_LIMIT', 0)) { throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Maximum bucket file size is larger than _APP_STORAGE_LIMIT'); } @@ -522,10 +523,10 @@ App::post('/v1/storage/buckets/:bucketId/files') } if ($chunksUploaded === $chunks) { - if (App::getEnv('_APP_STORAGE_ANTIVIRUS') === 'enabled' && $bucket->getAttribute('antivirus', true) && $fileSize <= APP_LIMIT_ANTIVIRUS && $deviceForFiles->getType() === Storage::DEVICE_LOCAL) { + if (System::getEnv('_APP_STORAGE_ANTIVIRUS') === 'enabled' && $bucket->getAttribute('antivirus', true) && $fileSize <= APP_LIMIT_ANTIVIRUS && $deviceForFiles->getType() === Storage::DEVICE_LOCAL) { $antivirus = new Network( - App::getEnv('_APP_STORAGE_ANTIVIRUS_HOST', 'clamav'), - (int) App::getEnv('_APP_STORAGE_ANTIVIRUS_PORT', 3310) + System::getEnv('_APP_STORAGE_ANTIVIRUS_HOST', 'clamav'), + (int) System::getEnv('_APP_STORAGE_ANTIVIRUS_PORT', 3310) ); if (!$antivirus->fileScan($path)) { @@ -562,7 +563,7 @@ App::post('/v1/storage/buckets/:bucketId/files') if (empty($data)) { $data = $deviceForFiles->read($path); } - $key = App::getEnv('_APP_OPENSSL_KEY_V1'); + $key = System::getEnv('_APP_OPENSSL_KEY_V1'); $iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM)); $data = OpenSSL::encrypt($data, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag); } @@ -920,7 +921,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview') $algorithm = $file->getAttribute('algorithm', Compression::NONE); $cipher = $file->getAttribute('openSSLCipher'); $mime = $file->getAttribute('mimeType'); - if (!\in_array($mime, $inputs) || $file->getAttribute('sizeActual') > (int) App::getEnv('_APP_STORAGE_PREVIEW_LIMIT', 20000000)) { + if (!\in_array($mime, $inputs) || $file->getAttribute('sizeActual') > (int) System::getEnv('_APP_STORAGE_PREVIEW_LIMIT', 20000000)) { if (!\in_array($mime, $inputs)) { $path = (\array_key_exists($mime, $fileLogos)) ? $fileLogos[$mime] : $fileLogos['default']; } else { @@ -957,7 +958,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview') $source = OpenSSL::decrypt( $source, $file->getAttribute('openSSLCipher'), - App::getEnv('_APP_OPENSSL_KEY_V' . $file->getAttribute('openSSLVersion')), + System::getEnv('_APP_OPENSSL_KEY_V' . $file->getAttribute('openSSLVersion')), 0, \hex2bin($file->getAttribute('openSSLIV')), \hex2bin($file->getAttribute('openSSLTag')) @@ -1105,7 +1106,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/download') $source = OpenSSL::decrypt( $source, $file->getAttribute('openSSLCipher'), - App::getEnv('_APP_OPENSSL_KEY_V' . $file->getAttribute('openSSLVersion')), + System::getEnv('_APP_OPENSSL_KEY_V' . $file->getAttribute('openSSLVersion')), 0, \hex2bin($file->getAttribute('openSSLIV')), \hex2bin($file->getAttribute('openSSLTag')) @@ -1254,7 +1255,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/view') $source = OpenSSL::decrypt( $source, $file->getAttribute('openSSLCipher'), - App::getEnv('_APP_OPENSSL_KEY_V' . $file->getAttribute('openSSLVersion')), + System::getEnv('_APP_OPENSSL_KEY_V' . $file->getAttribute('openSSLVersion')), 0, \hex2bin($file->getAttribute('openSSLIV')), \hex2bin($file->getAttribute('openSSLTag')) @@ -1327,7 +1328,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/push') ->action(function (string $bucketId, string $fileId, string $jwt, Response $response, Request $request, Database $dbForProject, Document $project, string $mode, Device $deviceForFiles) { $bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); - $decoder = new JWT(App::getEnv('_APP_OPENSSL_KEY_V1')); + $decoder = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1')); try { $decoded = $decoder->decode($jwt); @@ -1408,7 +1409,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/push') $source = OpenSSL::decrypt( $source, $file->getAttribute('openSSLCipher'), - App::getEnv('_APP_OPENSSL_KEY_V' . $file->getAttribute('openSSLVersion')), + System::getEnv('_APP_OPENSSL_KEY_V' . $file->getAttribute('openSSLVersion')), 0, \hex2bin($file->getAttribute('openSSLIV')), \hex2bin($file->getAttribute('openSSLTag')) diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index ca26e82d38..4cb2eb331f 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -37,6 +37,7 @@ use Utopia\Database\Validator\Query\Limit; use Utopia\Database\Validator\Query\Offset; use Utopia\Database\Validator\UID; use Utopia\Locale\Locale; +use Utopia\System\System; use Utopia\Validator\ArrayList; use Utopia\Validator\Assoc; use Utopia\Validator\Host; @@ -412,7 +413,7 @@ App::post('/v1/teams/:teamId/memberships') $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); $isAppUser = Auth::isAppUser(Authorization::getRoles()); - if (!$isPrivilegedUser && !$isAppUser && empty(App::getEnv('_APP_SMTP_HOST'))) { + if (!$isPrivilegedUser && !$isAppUser && empty(System::getEnv('_APP_SMTP_HOST'))) { throw new Exception(Exception::GENERAL_SMTP_DISABLED); } @@ -575,8 +576,8 @@ App::post('/v1/teams/:teamId/memberships') $smtp = $project->getAttribute('smtp', []); $smtpEnabled = $smtp['enabled'] ?? false; - $senderEmail = App::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM); - $senderName = App::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server'); + $senderEmail = System::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM); + $senderName = System::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server'); $replyTo = ""; if ($smtpEnabled) { @@ -637,7 +638,7 @@ App::post('/v1/teams/:teamId/memberships') ->trigger() ; } elseif (!empty($phone)) { - if (empty(App::getEnv('_APP_SMS_PROVIDER'))) { + if (empty(System::getEnv('_APP_SMS_PROVIDER'))) { throw new Exception(Exception::GENERAL_PHONE_DISABLED, 'Phone provider not configured'); } diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index c041155ef7..382689a2cc 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -32,6 +32,7 @@ use Utopia\Detector\Adapter\Python; use Utopia\Detector\Adapter\Ruby; use Utopia\Detector\Adapter\Swift; use Utopia\Detector\Detector; +use Utopia\System\System; use Utopia\Validator\Boolean; use Utopia\Validator\Host; use Utopia\Validator\Text; @@ -286,7 +287,7 @@ App::get('/v1/vcs/github/authorize') 'failure' => $failure, ]); - $appName = App::getEnv('_APP_VCS_GITHUB_APP_NAME'); + $appName = System::getEnv('_APP_VCS_GITHUB_APP_NAME'); if (empty($appName)) { throw new Exception(Exception::GENERAL_SERVER_ERROR, 'GitHub App name is not configured. Please configure VCS (Version Control System) variables in .env file.'); @@ -357,7 +358,7 @@ App::get('/v1/vcs/github/callback') // OAuth Authroization if (!empty($code)) { - $oauth2 = new OAuth2Github(App::getEnv('_APP_VCS_GITHUB_CLIENT_ID', ''), App::getEnv('_APP_VCS_GITHUB_CLIENT_SECRET', ''), ""); + $oauth2 = new OAuth2Github(System::getEnv('_APP_VCS_GITHUB_CLIENT_ID', ''), System::getEnv('_APP_VCS_GITHUB_CLIENT_SECRET', ''), ""); $accessToken = $oauth2->getAccessToken($code) ?? ''; $refreshToken = $oauth2->getRefreshToken($code) ?? ''; $accessTokenExpiry = $oauth2->getAccessTokenExpiry($code) ?? ''; @@ -404,8 +405,8 @@ App::get('/v1/vcs/github/callback') // Create / Update installation if (!empty($providerInstallationId)) { - $privateKey = App::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); - $githubAppId = App::getEnv('_APP_VCS_GITHUB_APP_ID'); + $privateKey = System::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); + $githubAppId = System::getEnv('_APP_VCS_GITHUB_APP_ID'); $github->initializeVariables($providerInstallationId, $privateKey, $githubAppId); $owner = $github->getOwnerName($providerInstallationId) ?? ''; @@ -489,8 +490,8 @@ App::post('/v1/vcs/github/installations/:installationId/providerRepositories/:pr } $providerInstallationId = $installation->getAttribute('providerInstallationId'); - $privateKey = App::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); - $githubAppId = App::getEnv('_APP_VCS_GITHUB_APP_ID'); + $privateKey = System::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); + $githubAppId = System::getEnv('_APP_VCS_GITHUB_APP_ID'); $github->initializeVariables($providerInstallationId, $privateKey, $githubAppId); $owner = $github->getOwnerName($providerInstallationId); @@ -563,8 +564,8 @@ App::get('/v1/vcs/github/installations/:installationId/providerRepositories') } $providerInstallationId = $installation->getAttribute('providerInstallationId'); - $privateKey = App::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); - $githubAppId = App::getEnv('_APP_VCS_GITHUB_APP_ID'); + $privateKey = System::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); + $githubAppId = System::getEnv('_APP_VCS_GITHUB_APP_ID'); $github->initializeVariables($providerInstallationId, $privateKey, $githubAppId); $page = 1; @@ -655,7 +656,7 @@ App::post('/v1/vcs/github/installations/:installationId/providerRepositories') } if ($installation->getAttribute('personal', false) === true) { - $oauth2 = new OAuth2Github(App::getEnv('_APP_VCS_GITHUB_CLIENT_ID', ''), App::getEnv('_APP_VCS_GITHUB_CLIENT_SECRET', ''), ""); + $oauth2 = new OAuth2Github(System::getEnv('_APP_VCS_GITHUB_CLIENT_ID', ''), System::getEnv('_APP_VCS_GITHUB_CLIENT_SECRET', ''), ""); $identity = $dbForConsole->findOne('identities', [ Query::equal('provider', ['github']), @@ -697,8 +698,8 @@ App::post('/v1/vcs/github/installations/:installationId/providerRepositories') } } else { $providerInstallationId = $installation->getAttribute('providerInstallationId'); - $privateKey = App::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); - $githubAppId = App::getEnv('_APP_VCS_GITHUB_APP_ID'); + $privateKey = System::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); + $githubAppId = System::getEnv('_APP_VCS_GITHUB_APP_ID'); $github->initializeVariables($providerInstallationId, $privateKey, $githubAppId); $owner = $github->getOwnerName($providerInstallationId); @@ -754,8 +755,8 @@ App::get('/v1/vcs/github/installations/:installationId/providerRepositories/:pro } $providerInstallationId = $installation->getAttribute('providerInstallationId'); - $privateKey = App::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); - $githubAppId = App::getEnv('_APP_VCS_GITHUB_APP_ID'); + $privateKey = System::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); + $githubAppId = System::getEnv('_APP_VCS_GITHUB_APP_ID'); $github->initializeVariables($providerInstallationId, $privateKey, $githubAppId); $owner = $github->getOwnerName($providerInstallationId) ?? ''; @@ -803,8 +804,8 @@ App::get('/v1/vcs/github/installations/:installationId/providerRepositories/:pro } $providerInstallationId = $installation->getAttribute('providerInstallationId'); - $privateKey = App::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); - $githubAppId = App::getEnv('_APP_VCS_GITHUB_APP_ID'); + $privateKey = System::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); + $githubAppId = System::getEnv('_APP_VCS_GITHUB_APP_ID'); $github->initializeVariables($providerInstallationId, $privateKey, $githubAppId); $owner = $github->getOwnerName($providerInstallationId) ?? ''; @@ -841,7 +842,7 @@ App::post('/v1/vcs/github/events') function (GitHub $github, Request $request, Response $response, Database $dbForConsole, callable $getProjectDB, Build $queueForBuilds) use ($createGitDeployments) { $payload = $request->getRawPayload(); $signatureRemote = $request->getHeader('x-hub-signature-256', ''); - $signatureLocal = App::getEnv('_APP_VCS_GITHUB_WEBHOOK_SECRET', ''); + $signatureLocal = System::getEnv('_APP_VCS_GITHUB_WEBHOOK_SECRET', ''); $valid = empty($signatureRemote) ? true : $github->validateWebhookEvent($payload, $signatureRemote, $signatureLocal); @@ -850,8 +851,8 @@ App::post('/v1/vcs/github/events') } $event = $request->getHeader('x-github-event', ''); - $privateKey = App::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); - $githubAppId = App::getEnv('_APP_VCS_GITHUB_APP_ID'); + $privateKey = System::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); + $githubAppId = System::getEnv('_APP_VCS_GITHUB_APP_ID'); $parsedPayload = $github->getEvent($event, $payload); if ($event == $github::EVENT_PUSH) { @@ -1134,8 +1135,8 @@ App::patch('/v1/vcs/github/installations/:installationId/repositories/:repositor $repository = Authorization::skip(fn () => $dbForConsole->updateDocument('repositories', $repository->getId(), $repository)); - $privateKey = App::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); - $githubAppId = App::getEnv('_APP_VCS_GITHUB_APP_ID'); + $privateKey = System::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); + $githubAppId = System::getEnv('_APP_VCS_GITHUB_APP_ID'); $providerInstallationId = $installation->getAttribute('providerInstallationId'); $github->initializeVariables($providerInstallationId, $privateKey, $githubAppId); diff --git a/app/controllers/general.php b/app/controllers/general.php index 1602316dd4..20848da47e 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -30,6 +30,7 @@ use Utopia\Locale\Locale; use Utopia\Logger\Log; use Utopia\Logger\Log\User; use Utopia\Logger\Logger; +use Utopia\System\System; use Utopia\Validator\Hostname; use Utopia\Validator\Text; @@ -51,15 +52,15 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo )[0] ?? null; if ($route === null) { - if ($host === App::getEnv('_APP_DOMAIN_FUNCTIONS', '')) { + if ($host === System::getEnv('_APP_DOMAIN_FUNCTIONS', '')) { throw new AppwriteException(AppwriteException::GENERAL_ACCESS_FORBIDDEN, 'This domain cannot be used for security reasons. Please use any subdomain instead.'); } - if (\str_ends_with($host, App::getEnv('_APP_DOMAIN_FUNCTIONS', ''))) { + if (\str_ends_with($host, System::getEnv('_APP_DOMAIN_FUNCTIONS', ''))) { throw new AppwriteException(AppwriteException::GENERAL_ACCESS_FORBIDDEN, 'This domain is not connected to any Appwrite resource yet. Please configure custom domain or function domain to allow this request.'); } - if (App::getEnv('_APP_OPTIONS_ROUTER_PROTECTION', 'disabled') === 'enabled') { + if (System::getEnv('_APP_OPTIONS_ROUTER_PROTECTION', 'disabled') === 'enabled') { if ($host !== 'localhost' && $host !== APP_HOSTNAME_INTERNAL) { // localhost allowed for proxy, APP_HOSTNAME_INTERNAL allowed for migrations throw new AppwriteException(AppwriteException::GENERAL_ACCESS_FORBIDDEN, 'Router protection does not allow accessing Appwrite over this domain. Please add it as custom domain to your project or disable _APP_OPTIONS_ROUTER_PROTECTION environment variable.'); } @@ -90,7 +91,7 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo $type = $route->getAttribute('resourceType'); if ($type === 'function') { - if (App::getEnv('_APP_OPTIONS_FUNCTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS + if (System::getEnv('_APP_OPTIONS_FUNCTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS if ($request->getProtocol() !== 'https') { if ($request->getMethod() !== Request::METHOD_GET) { throw new AppwriteException(AppwriteException::GENERAL_PROTOCOL_UNSUPPORTED, 'Method unsupported over HTTP. Please use HTTPS instead.'); @@ -250,7 +251,7 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo ]); /** Execute function */ - $executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST')); + $executor = new Executor(System::getEnv('_APP_EXECUTOR_HOST')); try { $version = $function->getAttribute('version', 'v2'); $command = $runtime['startCommand']; @@ -378,7 +379,7 @@ App::init() * Appwrite Router */ $host = $request->getHostname() ?? ''; - $mainDomain = App::getEnv('_APP_DOMAIN', ''); + $mainDomain = System::getEnv('_APP_DOMAIN', ''); // Only run Router when external domain if ($host !== $mainDomain) { if (router($utopia, $dbForConsole, $getProjectDB, $swooleRequest, $request, $response, $queueForEvents, $queueForUsage, $geodb)) { @@ -396,7 +397,7 @@ App::init() return $response->setStatusCode(404)->send('Not Found'); } - $requestFormat = $request->getHeader('x-appwrite-response-format', App::getEnv('_APP_SYSTEM_RESPONSE_FORMAT', null)); + $requestFormat = $request->getHeader('x-appwrite-response-format', System::getEnv('_APP_SYSTEM_RESPONSE_FORMAT', '')); if ($requestFormat) { if (version_compare($requestFormat, '1.4.0', '<')) { $request->addFilter(new RequestV16()); @@ -419,7 +420,7 @@ App::init() } else { Authorization::disable(); - $envDomain = App::getEnv('_APP_DOMAIN', ''); + $envDomain = System::getEnv('_APP_DOMAIN', ''); $mainDomain = null; if (!empty($envDomain) && $envDomain !== 'localhost') { $mainDomain = $envDomain; @@ -496,7 +497,7 @@ App::init() $isIpAddress = filter_var($request->getHostname(), FILTER_VALIDATE_IP) !== false; $isConsoleProject = $project->getAttribute('$id', '') === 'console'; - $isConsoleRootSession = App::getEnv('_APP_CONSOLE_ROOT_SESSION', 'disabled') === 'enabled'; + $isConsoleRootSession = System::getEnv('_APP_CONSOLE_ROOT_SESSION', 'disabled') === 'enabled'; Config::setParam( 'cookieDomain', @@ -512,7 +513,7 @@ App::init() /* * Response format */ - $responseFormat = $request->getHeader('x-appwrite-response-format', App::getEnv('_APP_SYSTEM_RESPONSE_FORMAT', null)); + $responseFormat = $request->getHeader('x-appwrite-response-format', System::getEnv('_APP_SYSTEM_RESPONSE_FORMAT', '')); if ($responseFormat) { if (version_compare($responseFormat, '1.4.0', '<')) { $response->addFilter(new ResponseV16()); @@ -528,7 +529,7 @@ App::init() * As recommended at: * @see https://www.owasp.org/index.php/List_of_useful_HTTP_headers */ - if (App::getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS + if (System::getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS if ($request->getProtocol() !== 'https' && ($swooleRequest->header['host'] ?? '') !== 'localhost' && ($swooleRequest->header['host'] ?? '') !== APP_HOSTNAME_INTERNAL) { // localhost allowed for proxy, APP_HOSTNAME_INTERNAL allowed for migrations if ($request->getMethod() !== Request::METHOD_GET) { throw new AppwriteException(AppwriteException::GENERAL_PROTOCOL_UNSUPPORTED, 'Method unsupported over HTTP. Please use HTTPS instead.'); @@ -584,7 +585,7 @@ App::options() * Appwrite Router */ $host = $request->getHostname() ?? ''; - $mainDomain = App::getEnv('_APP_DOMAIN', ''); + $mainDomain = System::getEnv('_APP_DOMAIN', ''); // Only run Router when external domain if ($host !== $mainDomain) { if (router($utopia, $dbForConsole, $getProjectDB, $swooleRequest, $request, $response, $queueForEvents, $queueForUsage, $geodb)) { @@ -613,7 +614,7 @@ App::error() ->inject('logger') ->inject('log') ->action(function (Throwable $error, App $utopia, Request $request, Response $response, Document $project, ?Logger $logger, Log $log) { - $version = App::getEnv('_APP_VERSION', 'UNKNOWN'); + $version = System::getEnv('_APP_VERSION', 'UNKNOWN'); $route = $utopia->getRoute(); if ($error instanceof AppwriteException) { @@ -658,7 +659,7 @@ App::error() $action = $route->getLabel("sdk.namespace", "UNKNOWN_NAMESPACE") . '.' . $route->getLabel("sdk.method", "UNKNOWN_METHOD"); $log->setAction($action); - $isProduction = App::getEnv('_APP_ENV', 'development') === 'production'; + $isProduction = System::getEnv('_APP_ENV', 'development') === 'production'; $log->setEnvironment($isProduction ? Log::ENVIRONMENT_PRODUCTION : Log::ENVIRONMENT_STAGING); $responseCode = $logger->addLog($log); diff --git a/app/controllers/mock.php b/app/controllers/mock.php index f933c62e6e..6679fa14f5 100644 --- a/app/controllers/mock.php +++ b/app/controllers/mock.php @@ -12,6 +12,7 @@ use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; use Utopia\Database\Validator\UID; +use Utopia\System\System; use Utopia\Validator\Host; use Utopia\Validator\Text; use Utopia\Validator\WhiteList; @@ -136,7 +137,7 @@ App::patch('/v1/mock/functions-v2') ->inject('response') ->inject('dbForProject') ->action(function (string $functionId, Response $response, Database $dbForProject) { - $isDevelopment = App::getEnv('_APP_ENV', 'development') === 'development'; + $isDevelopment = System::getEnv('_APP_ENV', 'development') === 'development'; if (!$isDevelopment) { throw new Exception(Exception::GENERAL_NOT_IMPLEMENTED); @@ -165,7 +166,7 @@ App::get('/v1/mock/github/callback') ->inject('response') ->inject('dbForConsole') ->action(function (string $providerInstallationId, string $projectId, GitHub $github, Document $project, Response $response, Database $dbForConsole) { - $isDevelopment = App::getEnv('_APP_ENV', 'development') === 'development'; + $isDevelopment = System::getEnv('_APP_ENV', 'development') === 'development'; if (!$isDevelopment) { throw new Exception(Exception::GENERAL_NOT_IMPLEMENTED); @@ -179,8 +180,8 @@ App::get('/v1/mock/github/callback') } if (!empty($providerInstallationId)) { - $privateKey = App::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); - $githubAppId = App::getEnv('_APP_VCS_GITHUB_APP_ID'); + $privateKey = System::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); + $githubAppId = System::getEnv('_APP_VCS_GITHUB_APP_ID'); $github->initializeVariables($providerInstallationId, $privateKey, $githubAppId); $owner = $github->getOwnerName($providerInstallationId) ?? ''; diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index ad9ed97b63..7c2f08c70e 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -26,6 +26,7 @@ use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Helpers\Role; use Utopia\Database\Validator\Authorization; +use Utopia\System\System; use Utopia\Validator\WhiteList; $parseLabel = function (string $label, array $responsePayload, array $requestParams, Document $user) { @@ -374,7 +375,7 @@ App::init() ; } - $enabled = App::getEnv('_APP_OPTIONS_ABUSE', 'enabled') !== 'disabled'; + $enabled = System::getEnv('_APP_OPTIONS_ABUSE', 'enabled') !== 'disabled'; if ( $enabled // Abuse is enabled @@ -739,7 +740,7 @@ App::shutdown() App::init() ->groups(['usage']) ->action(function () { - if (App::getEnv('_APP_USAGE_STATS', 'enabled') !== 'enabled') { + if (System::getEnv('_APP_USAGE_STATS', 'enabled') !== 'enabled') { throw new Exception(Exception::GENERAL_USAGE_DISABLED); } }); diff --git a/app/controllers/shared/api/auth.php b/app/controllers/shared/api/auth.php index 7f304454be..e50887882a 100644 --- a/app/controllers/shared/api/auth.php +++ b/app/controllers/shared/api/auth.php @@ -8,6 +8,7 @@ use Utopia\App; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Validator\Authorization; +use Utopia\System\System; App::init() ->groups(['mfaProtected']) @@ -35,7 +36,7 @@ App::init() ->inject('project') ->inject('geodb') ->action(function (App $utopia, Request $request, Document $project, Reader $geodb) { - $denylist = App::getEnv('_APP_CONSOLE_COUNTRIES_DENYLIST', ''); + $denylist = System::getEnv('_APP_CONSOLE_COUNTRIES_DENYLIST', ''); if (!empty($denylist && $project->getId() === 'console')) { $countries = explode(',', $denylist); $record = $geodb->get($request->getIP()) ?? []; diff --git a/app/http.php b/app/http.php index ddf25dd744..c1b491056a 100644 --- a/app/http.php +++ b/app/http.php @@ -24,15 +24,16 @@ use Utopia\Logger\Log; use Utopia\Logger\Log\User; use Utopia\Pools\Group; use Utopia\Swoole\Files; +use Utopia\System\System; $http = new Server( host: "0.0.0.0", - port: App::getEnv('PORT', 80), + port: System::getEnv('PORT', 80), mode: SWOOLE_PROCESS, ); $payloadSize = 6 * (1024 * 1024); // 6MB -$workerNumber = swoole_cpu_num() * intval(App::getEnv('_APP_WORKER_PER_CORE', 6)); +$workerNumber = swoole_cpu_num() * intval(System::getEnv('_APP_WORKER_PER_CORE', 6)); $http ->set([ @@ -156,7 +157,7 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg '$id' => ID::custom('default'), '$collection' => ID::custom('buckets'), 'name' => 'Default', - 'maximumFileSize' => (int) App::getEnv('_APP_STORAGE_LIMIT', 0), // 10MB + 'maximumFileSize' => (int) System::getEnv('_APP_STORAGE_LIMIT', 0), // 10MB 'allowedFileExtensions' => [], 'enabled' => true, 'compression' => 'gzip', @@ -255,7 +256,7 @@ $http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swo $app->run($request, $response); } catch (\Throwable $th) { - $version = App::getEnv('_APP_VERSION', 'UNKNOWN'); + $version = System::getEnv('_APP_VERSION', 'UNKNOWN'); $logger = $app->getResource("logger"); if ($logger) { @@ -297,7 +298,7 @@ $http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swo $action = $route->getLabel("sdk.namespace", "UNKNOWN_NAMESPACE") . '.' . $route->getLabel("sdk.method", "UNKNOWN_METHOD"); $log->setAction($action); - $isProduction = App::getEnv('_APP_ENV', 'development') === 'production'; + $isProduction = System::getEnv('_APP_ENV', 'development') === 'production'; $log->setEnvironment($isProduction ? Log::ENVIRONMENT_PRODUCTION : Log::ENVIRONMENT_STAGING); $responseCode = $logger->addLog($log); diff --git a/app/init.php b/app/init.php index 4b70b2601b..5877327ab6 100644 --- a/app/init.php +++ b/app/init.php @@ -77,6 +77,7 @@ use Utopia\Storage\Device\Local; use Utopia\Storage\Device\S3; use Utopia\Storage\Device\Wasabi; use Utopia\Storage\Storage; +use Utopia\System\System; use Utopia\Validator\Hostname; use Utopia\Validator\IP; use Utopia\Validator\Range; @@ -244,7 +245,7 @@ const METRIC_NETWORK_OUTBOUND = 'network.outbound'; $register = new Registry(); -App::setMode(App::getEnv('_APP_ENV', App::MODE_TYPE_PRODUCTION)); +App::setMode(System::getEnv('_APP_ENV', App::MODE_TYPE_PRODUCTION)); if (!App::isProduction()) { // Allow specific domains to skip public domain validation in dev environment @@ -517,7 +518,7 @@ Database::addFilter( Database::addFilter( 'encrypt', function (mixed $value) { - $key = App::getEnv('_APP_OPENSSL_KEY_V1'); + $key = System::getEnv('_APP_OPENSSL_KEY_V1'); $iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM)); $tag = null; @@ -534,7 +535,7 @@ Database::addFilter( return; } $value = json_decode($value, true); - $key = App::getEnv('_APP_OPENSSL_KEY_V' . $value['version']); + $key = System::getEnv('_APP_OPENSSL_KEY_V' . $value['version']); return OpenSSL::decrypt($value['data'], $value['method'], $key, 0, hex2bin($value['iv']), hex2bin($value['tag'])); } @@ -720,8 +721,8 @@ Structure::addFormat(APP_DATABASE_ATTRIBUTE_FLOAT_RANGE, function ($attribute) { */ $register->set('logger', function () { // Register error logger - $providerName = App::getEnv('_APP_LOGGING_PROVIDER', ''); - $providerConfig = App::getEnv('_APP_LOGGING_CONFIG', ''); + $providerName = System::getEnv('_APP_LOGGING_PROVIDER', ''); + $providerConfig = System::getEnv('_APP_LOGGING_CONFIG', ''); if (empty($providerName) || empty($providerConfig)) { return; @@ -740,60 +741,60 @@ $register->set('pools', function () { $fallbackForDB = 'db_main=' . AppwriteURL::unparse([ 'scheme' => 'mariadb', - 'host' => App::getEnv('_APP_DB_HOST', 'mariadb'), - 'port' => App::getEnv('_APP_DB_PORT', '3306'), - 'user' => App::getEnv('_APP_DB_USER', ''), - 'pass' => App::getEnv('_APP_DB_PASS', ''), - 'path' => App::getEnv('_APP_DB_SCHEMA', ''), + 'host' => System::getEnv('_APP_DB_HOST', 'mariadb'), + 'port' => System::getEnv('_APP_DB_PORT', '3306'), + 'user' => System::getEnv('_APP_DB_USER', ''), + 'pass' => System::getEnv('_APP_DB_PASS', ''), + 'path' => System::getEnv('_APP_DB_SCHEMA', ''), ]); $fallbackForRedis = 'redis_main=' . AppwriteURL::unparse([ 'scheme' => 'redis', - 'host' => App::getEnv('_APP_REDIS_HOST', 'redis'), - 'port' => App::getEnv('_APP_REDIS_PORT', '6379'), - 'user' => App::getEnv('_APP_REDIS_USER', ''), - 'pass' => App::getEnv('_APP_REDIS_PASS', ''), + 'host' => System::getEnv('_APP_REDIS_HOST', 'redis'), + 'port' => System::getEnv('_APP_REDIS_PORT', '6379'), + 'user' => System::getEnv('_APP_REDIS_USER', ''), + 'pass' => System::getEnv('_APP_REDIS_PASS', ''), ]); $connections = [ 'console' => [ 'type' => 'database', - 'dsns' => App::getEnv('_APP_CONNECTIONS_DB_CONSOLE', $fallbackForDB), + 'dsns' => System::getEnv('_APP_CONNECTIONS_DB_CONSOLE', $fallbackForDB), 'multiple' => false, 'schemes' => ['mariadb', 'mysql'], ], 'database' => [ 'type' => 'database', - 'dsns' => App::getEnv('_APP_CONNECTIONS_DB_PROJECT', $fallbackForDB), + 'dsns' => System::getEnv('_APP_CONNECTIONS_DB_PROJECT', $fallbackForDB), 'multiple' => true, 'schemes' => ['mariadb', 'mysql'], ], 'queue' => [ 'type' => 'queue', - 'dsns' => App::getEnv('_APP_CONNECTIONS_QUEUE', $fallbackForRedis), + 'dsns' => System::getEnv('_APP_CONNECTIONS_QUEUE', $fallbackForRedis), 'multiple' => false, 'schemes' => ['redis'], ], 'pubsub' => [ 'type' => 'pubsub', - 'dsns' => App::getEnv('_APP_CONNECTIONS_PUBSUB', $fallbackForRedis), + 'dsns' => System::getEnv('_APP_CONNECTIONS_PUBSUB', $fallbackForRedis), 'multiple' => false, 'schemes' => ['redis'], ], 'cache' => [ 'type' => 'cache', - 'dsns' => App::getEnv('_APP_CONNECTIONS_CACHE', $fallbackForRedis), + 'dsns' => System::getEnv('_APP_CONNECTIONS_CACHE', $fallbackForRedis), 'multiple' => true, 'schemes' => ['redis'], ], ]; - $maxConnections = App::getEnv('_APP_CONNECTIONS_MAX', 151); - $instanceConnections = $maxConnections / App::getEnv('_APP_POOL_CLIENTS', 14); + $maxConnections = System::getEnv('_APP_CONNECTIONS_MAX', 151); + $instanceConnections = $maxConnections / System::getEnv('_APP_POOL_CLIENTS', 14); - $multiprocessing = App::getEnv('_APP_SERVER_MULTIPROCESS', 'disabled') === 'enabled'; + $multiprocessing = System::getEnv('_APP_SERVER_MULTIPROCESS', 'disabled') === 'enabled'; if ($multiprocessing) { - $workerCount = swoole_cpu_num() * intval(App::getEnv('_APP_WORKER_PER_CORE', 6)); + $workerCount = swoole_cpu_num() * intval(System::getEnv('_APP_WORKER_PER_CORE', 6)); } else { $workerCount = 1; } @@ -919,11 +920,11 @@ $register->set('pools', function () { $register->set('db', function () { // This is usually for our workers or CLI commands scope - $dbHost = App::getEnv('_APP_DB_HOST', ''); - $dbPort = App::getEnv('_APP_DB_PORT', ''); - $dbUser = App::getEnv('_APP_DB_USER', ''); - $dbPass = App::getEnv('_APP_DB_PASS', ''); - $dbScheme = App::getEnv('_APP_DB_SCHEMA', ''); + $dbHost = System::getEnv('_APP_DB_HOST', ''); + $dbPort = System::getEnv('_APP_DB_PORT', ''); + $dbUser = System::getEnv('_APP_DB_USER', ''); + $dbPass = System::getEnv('_APP_DB_PASS', ''); + $dbScheme = System::getEnv('_APP_DB_SCHEMA', ''); return new PDO( "mysql:host={$dbHost};port={$dbPort};dbname={$dbScheme};charset=utf8mb4", @@ -938,21 +939,21 @@ $register->set('smtp', function () { $mail->isSMTP(); - $username = App::getEnv('_APP_SMTP_USERNAME'); - $password = App::getEnv('_APP_SMTP_PASSWORD'); + $username = System::getEnv('_APP_SMTP_USERNAME'); + $password = System::getEnv('_APP_SMTP_PASSWORD'); $mail->XMailer = 'Appwrite Mailer'; - $mail->Host = App::getEnv('_APP_SMTP_HOST', 'smtp'); - $mail->Port = App::getEnv('_APP_SMTP_PORT', 25); + $mail->Host = System::getEnv('_APP_SMTP_HOST', 'smtp'); + $mail->Port = System::getEnv('_APP_SMTP_PORT', 25); $mail->SMTPAuth = !empty($username) && !empty($password); $mail->Username = $username; $mail->Password = $password; - $mail->SMTPSecure = App::getEnv('_APP_SMTP_SECURE', ''); + $mail->SMTPSecure = System::getEnv('_APP_SMTP_SECURE', ''); $mail->SMTPAutoTLS = false; $mail->CharSet = 'UTF-8'; - $from = \urldecode(App::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server')); - $email = App::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM); + $from = \urldecode(System::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server')); + $email = System::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM); $mail->setFrom($email, $from); $mail->addReplyTo($email, $from); @@ -1003,8 +1004,8 @@ foreach ($locales as $locale) { 'method' => 'GET', 'user_agent' => \sprintf( APP_USERAGENT, - App::getEnv('_APP_VERSION', 'UNKNOWN'), - App::getEnv('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY) + System::getEnv('_APP_VERSION', 'UNKNOWN'), + System::getEnv('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY) ), 'timeout' => 2, ], @@ -1021,7 +1022,7 @@ App::setResource('hooks', function ($register) { }, ['register']); App::setResource('register', fn () => $register); -App::setResource('locale', fn () => new Locale(App::getEnv('_APP_LOCALE', 'en'))); +App::setResource('locale', fn () => new Locale(System::getEnv('_APP_LOCALE', 'en'))); App::setResource('localeCodes', function () { return array_map(fn ($locale) => $locale['code'], Config::getParam('locale-codes', [])); @@ -1072,7 +1073,7 @@ App::setResource('clients', function ($request, $console, $project) { 'hostname' => $request->getHostname(), ], Document::SET_TYPE_APPEND); - $hostnames = explode(',', App::getEnv('_APP_CONSOLE_HOSTNAMES', '')); + $hostnames = explode(',', System::getEnv('_APP_CONSOLE_HOSTNAMES', '')); $validator = new Hostname(); foreach ($hostnames as $hostname) { $hostname = trim($hostname); @@ -1196,7 +1197,7 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons $authJWT = $request->getHeader('x-appwrite-jwt', ''); if (!empty($authJWT) && !$project->isEmpty()) { // JWT authentication - $jwt = new JWT(App::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', 900, 10); // Instantiate with key, algo, maxAge and leeway. + $jwt = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', 900, 10); // Instantiate with key, algo, maxAge and leeway. try { $payload = $jwt->decode($authJWT); @@ -1286,16 +1287,16 @@ App::setResource('console', function () { 'legalAddress' => '', 'legalTaxId' => '', 'auths' => [ - 'invites' => App::getEnv('_APP_CONSOLE_INVITES', 'enabled') === 'enabled', - 'limit' => (App::getEnv('_APP_CONSOLE_WHITELIST_ROOT', 'enabled') === 'enabled') ? 1 : 0, // limit signup to 1 user + 'invites' => System::getEnv('_APP_CONSOLE_INVITES', 'enabled') === 'enabled', + 'limit' => (System::getEnv('_APP_CONSOLE_WHITELIST_ROOT', 'enabled') === 'enabled') ? 1 : 0, // limit signup to 1 user 'duration' => Auth::TOKEN_EXPIRATION_LOGIN_LONG, // 1 Year in seconds ], - 'authWhitelistEmails' => (!empty(App::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null))) ? \explode(',', App::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null)) : [], - 'authWhitelistIPs' => (!empty(App::getEnv('_APP_CONSOLE_WHITELIST_IPS', null))) ? \explode(',', App::getEnv('_APP_CONSOLE_WHITELIST_IPS', null)) : [], + 'authWhitelistEmails' => (!empty(System::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null))) ? \explode(',', System::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null)) : [], + 'authWhitelistIPs' => (!empty(System::getEnv('_APP_CONSOLE_WHITELIST_IPS', null))) ? \explode(',', System::getEnv('_APP_CONSOLE_WHITELIST_IPS', null)) : [], 'oAuthProviders' => [ 'githubEnabled' => true, - 'githubSecret' => App::getEnv('_APP_CONSOLE_GITHUB_SECRET', ''), - 'githubAppid' => App::getEnv('_APP_CONSOLE_GITHUB_APP_ID', '') + 'githubSecret' => System::getEnv('_APP_CONSOLE_GITHUB_SECRET', ''), + 'githubAppid' => System::getEnv('_APP_CONSOLE_GITHUB_APP_ID', '') ], ]); }, []); @@ -1415,7 +1416,7 @@ App::setResource('deviceForBuilds', function ($project) { function getDevice($root): Device { - $connection = App::getEnv('_APP_CONNECTIONS_STORAGE', ''); + $connection = System::getEnv('_APP_CONNECTIONS_STORAGE', ''); if (!empty($connection)) { $acl = 'private'; @@ -1452,43 +1453,43 @@ function getDevice($root): Device return new Local($root); } } else { - switch (strtolower(App::getEnv('_APP_STORAGE_DEVICE', Storage::DEVICE_LOCAL) ?? '')) { + switch (strtolower(System::getEnv('_APP_STORAGE_DEVICE', Storage::DEVICE_LOCAL) ?? '')) { case Storage::DEVICE_LOCAL: default: return new Local($root); case Storage::DEVICE_S3: - $s3AccessKey = App::getEnv('_APP_STORAGE_S3_ACCESS_KEY', ''); - $s3SecretKey = App::getEnv('_APP_STORAGE_S3_SECRET', ''); - $s3Region = App::getEnv('_APP_STORAGE_S3_REGION', ''); - $s3Bucket = App::getEnv('_APP_STORAGE_S3_BUCKET', ''); + $s3AccessKey = System::getEnv('_APP_STORAGE_S3_ACCESS_KEY', ''); + $s3SecretKey = System::getEnv('_APP_STORAGE_S3_SECRET', ''); + $s3Region = System::getEnv('_APP_STORAGE_S3_REGION', ''); + $s3Bucket = System::getEnv('_APP_STORAGE_S3_BUCKET', ''); $s3Acl = 'private'; return new S3($root, $s3AccessKey, $s3SecretKey, $s3Bucket, $s3Region, $s3Acl); case Storage::DEVICE_DO_SPACES: - $doSpacesAccessKey = App::getEnv('_APP_STORAGE_DO_SPACES_ACCESS_KEY', ''); - $doSpacesSecretKey = App::getEnv('_APP_STORAGE_DO_SPACES_SECRET', ''); - $doSpacesRegion = App::getEnv('_APP_STORAGE_DO_SPACES_REGION', ''); - $doSpacesBucket = App::getEnv('_APP_STORAGE_DO_SPACES_BUCKET', ''); + $doSpacesAccessKey = System::getEnv('_APP_STORAGE_DO_SPACES_ACCESS_KEY', ''); + $doSpacesSecretKey = System::getEnv('_APP_STORAGE_DO_SPACES_SECRET', ''); + $doSpacesRegion = System::getEnv('_APP_STORAGE_DO_SPACES_REGION', ''); + $doSpacesBucket = System::getEnv('_APP_STORAGE_DO_SPACES_BUCKET', ''); $doSpacesAcl = 'private'; return new DOSpaces($root, $doSpacesAccessKey, $doSpacesSecretKey, $doSpacesBucket, $doSpacesRegion, $doSpacesAcl); case Storage::DEVICE_BACKBLAZE: - $backblazeAccessKey = App::getEnv('_APP_STORAGE_BACKBLAZE_ACCESS_KEY', ''); - $backblazeSecretKey = App::getEnv('_APP_STORAGE_BACKBLAZE_SECRET', ''); - $backblazeRegion = App::getEnv('_APP_STORAGE_BACKBLAZE_REGION', ''); - $backblazeBucket = App::getEnv('_APP_STORAGE_BACKBLAZE_BUCKET', ''); + $backblazeAccessKey = System::getEnv('_APP_STORAGE_BACKBLAZE_ACCESS_KEY', ''); + $backblazeSecretKey = System::getEnv('_APP_STORAGE_BACKBLAZE_SECRET', ''); + $backblazeRegion = System::getEnv('_APP_STORAGE_BACKBLAZE_REGION', ''); + $backblazeBucket = System::getEnv('_APP_STORAGE_BACKBLAZE_BUCKET', ''); $backblazeAcl = 'private'; return new Backblaze($root, $backblazeAccessKey, $backblazeSecretKey, $backblazeBucket, $backblazeRegion, $backblazeAcl); case Storage::DEVICE_LINODE: - $linodeAccessKey = App::getEnv('_APP_STORAGE_LINODE_ACCESS_KEY', ''); - $linodeSecretKey = App::getEnv('_APP_STORAGE_LINODE_SECRET', ''); - $linodeRegion = App::getEnv('_APP_STORAGE_LINODE_REGION', ''); - $linodeBucket = App::getEnv('_APP_STORAGE_LINODE_BUCKET', ''); + $linodeAccessKey = System::getEnv('_APP_STORAGE_LINODE_ACCESS_KEY', ''); + $linodeSecretKey = System::getEnv('_APP_STORAGE_LINODE_SECRET', ''); + $linodeRegion = System::getEnv('_APP_STORAGE_LINODE_REGION', ''); + $linodeBucket = System::getEnv('_APP_STORAGE_LINODE_BUCKET', ''); $linodeAcl = 'private'; return new Linode($root, $linodeAccessKey, $linodeSecretKey, $linodeBucket, $linodeRegion, $linodeAcl); case Storage::DEVICE_WASABI: - $wasabiAccessKey = App::getEnv('_APP_STORAGE_WASABI_ACCESS_KEY', ''); - $wasabiSecretKey = App::getEnv('_APP_STORAGE_WASABI_SECRET', ''); - $wasabiRegion = App::getEnv('_APP_STORAGE_WASABI_REGION', ''); - $wasabiBucket = App::getEnv('_APP_STORAGE_WASABI_BUCKET', ''); + $wasabiAccessKey = System::getEnv('_APP_STORAGE_WASABI_ACCESS_KEY', ''); + $wasabiSecretKey = System::getEnv('_APP_STORAGE_WASABI_SECRET', ''); + $wasabiRegion = System::getEnv('_APP_STORAGE_WASABI_REGION', ''); + $wasabiBucket = System::getEnv('_APP_STORAGE_WASABI_BUCKET', ''); $wasabiAcl = 'private'; return new Wasabi($root, $wasabiAccessKey, $wasabiSecretKey, $wasabiBucket, $wasabiRegion, $wasabiAcl); } diff --git a/app/realtime.php b/app/realtime.php index e0ee7bc59a..faebb1d198 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -27,6 +27,7 @@ use Utopia\Database\Helpers\Role; use Utopia\Database\Query; use Utopia\Database\Validator\Authorization; use Utopia\Logger\Log; +use Utopia\System\System; use Utopia\WebSocket\Adapter; use Utopia\WebSocket\Server; @@ -122,9 +123,9 @@ $stats->create(); $containerId = uniqid(); $statsDocument = null; -$workerNumber = swoole_cpu_num() * intval(App::getEnv('_APP_WORKER_PER_CORE', 6)); +$workerNumber = swoole_cpu_num() * intval(System::getEnv('_APP_WORKER_PER_CORE', 6)); -$adapter = new Adapter\Swoole(port: App::getEnv('PORT', 80)); +$adapter = new Adapter\Swoole(port: System::getEnv('PORT', 80)); $adapter ->setPackageMaxLength(64000) // Default maximum Package Size (64kb) ->setWorkerNumber($workerNumber); @@ -135,7 +136,7 @@ $logError = function (Throwable $error, string $action) use ($register) { $logger = $register->get('logger'); if ($logger && !$error instanceof Exception) { - $version = App::getEnv('_APP_VERSION', 'UNKNOWN'); + $version = System::getEnv('_APP_VERSION', 'UNKNOWN'); $log = new Log(); $log->setNamespace("realtime"); @@ -154,7 +155,7 @@ $logError = function (Throwable $error, string $action) use ($register) { $log->setAction($action); - $isProduction = App::getEnv('_APP_ENV', 'development') === 'production'; + $isProduction = System::getEnv('_APP_ENV', 'development') === 'production'; $log->setEnvironment($isProduction ? Log::ENVIRONMENT_PRODUCTION : Log::ENVIRONMENT_STAGING); $responseCode = $logger->addLog($log); @@ -435,7 +436,7 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server, $abuse = new Abuse($timeLimit); - if (App::getEnv('_APP_OPTIONS_ABUSE', 'enabled') === 'enabled' && $abuse->check()) { + if (System::getEnv('_APP_OPTIONS_ABUSE', 'enabled') === 'enabled' && $abuse->check()) { throw new Exception(Exception::REALTIME_TOO_MANY_MESSAGES, 'Too many requests'); } @@ -530,7 +531,7 @@ $server->onMessage(function (int $connection, string $message) use ($server, $re $abuse = new Abuse($timeLimit); - if ($abuse->check() && App::getEnv('_APP_OPTIONS_ABUSE', 'enabled') === 'enabled') { + if ($abuse->check() && System::getEnv('_APP_OPTIONS_ABUSE', 'enabled') === 'enabled') { throw new Exception(Exception::REALTIME_TOO_MANY_MESSAGES, 'Too many messages.'); } diff --git a/app/worker.php b/app/worker.php index 98a1e40a88..ae9732fb1b 100644 --- a/app/worker.php +++ b/app/worker.php @@ -17,7 +17,6 @@ use Appwrite\Event\Usage; use Appwrite\Event\UsageDump; use Appwrite\Platform\Appwrite; use Swoole\Runtime; -use Utopia\App; use Utopia\Cache\Adapter\Sharding; use Utopia\Cache\Cache; use Utopia\CLI\Console; @@ -35,6 +34,7 @@ use Utopia\Queue\Message; use Utopia\Queue\Server; use Utopia\Registry\Registry; use Utopia\Storage\Device\Local; +use Utopia\System\System; Authorization::disable(); Runtime::enableCoroutine(SWOOLE_HOOK_ALL); @@ -113,15 +113,15 @@ Server::setResource('getProjectDB', function (Group $pools, Database $dbForConso }, ['pools', 'dbForConsole', 'cache']); Server::setResource('abuseRetention', function () { - return DateTime::addSeconds(new \DateTime(), -1 * App::getEnv('_APP_MAINTENANCE_RETENTION_ABUSE', 86400)); + return DateTime::addSeconds(new \DateTime(), -1 * System::getEnv('_APP_MAINTENANCE_RETENTION_ABUSE', 86400)); }); Server::setResource('auditRetention', function () { - return DateTime::addSeconds(new \DateTime(), -1 * App::getEnv('_APP_MAINTENANCE_RETENTION_AUDIT', 1209600)); + return DateTime::addSeconds(new \DateTime(), -1 * System::getEnv('_APP_MAINTENANCE_RETENTION_AUDIT', 1209600)); }); Server::setResource('executionRetention', function () { - return DateTime::addSeconds(new \DateTime(), -1 * App::getEnv('_APP_MAINTENANCE_RETENTION_EXECUTION', 1209600)); + return DateTime::addSeconds(new \DateTime(), -1 * System::getEnv('_APP_MAINTENANCE_RETENTION_EXECUTION', 1209600)); }); Server::setResource('cache', function (Registry $register) { @@ -244,9 +244,9 @@ if (!empty($workerIndex)) { } if (\str_starts_with($workerName, 'databases')) { - $queueName = App::getEnv('_APP_QUEUE_NAME', 'database_db_main'); + $queueName = System::getEnv('_APP_QUEUE_NAME', 'database_db_main'); } else { - $queueName = App::getEnv('_APP_QUEUE_NAME', 'v1-' . strtolower($workerName)); + $queueName = System::getEnv('_APP_QUEUE_NAME', 'v1-' . strtolower($workerName)); } try { @@ -257,7 +257,7 @@ try { * - _APP_QUEUE_NAME The name of the queue to read for database events */ $platform->init(Service::TYPE_WORKER, [ - 'workersNum' => App::getEnv('_APP_WORKERS_NUM', 1), + 'workersNum' => System::getEnv('_APP_WORKERS_NUM', 1), 'connection' => $pools->get('queue')->pop()->getResource(), 'workerName' => strtolower($workerName) ?? null, 'queueName' => $queueName @@ -284,7 +284,7 @@ $worker ->inject('project') ->action(function (Throwable $error, ?Logger $logger, Log $log, Group $pools, Document $project) use ($queueName) { $pools->reclaim(); - $version = App::getEnv('_APP_VERSION', 'UNKNOWN'); + $version = System::getEnv('_APP_VERSION', 'UNKNOWN'); if ($error instanceof PDOException) { throw $error; @@ -306,7 +306,7 @@ $worker $log->addExtra('detailedTrace', $error->getTrace()); $log->addExtra('roles', Authorization::getRoles()); - $isProduction = App::getEnv('_APP_ENV', 'development') === 'production'; + $isProduction = System::getEnv('_APP_ENV', 'development') === 'production'; $log->setEnvironment($isProduction ? Log::ENVIRONMENT_PRODUCTION : Log::ENVIRONMENT_STAGING); $responseCode = $logger->addLog($log); diff --git a/composer.json b/composer.json index d2984b5802..cfdd7f323b 100644 --- a/composer.json +++ b/composer.json @@ -66,6 +66,7 @@ "utopia-php/registry": "0.5.*", "utopia-php/storage": "0.18.*", "utopia-php/swoole": "0.8.*", + "utopia-php/system": "0.8.*", "utopia-php/vcs": "0.6.*", "utopia-php/websocket": "0.1.*", "matomo/device-detector": "6.1.*", diff --git a/composer.lock b/composer.lock index 506d6d9a67..88ccf84ded 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "92244aad23e8d26c034633397692c1fc", + "content-hash": "78b9cd75952805a2347578f4fcb96add", "packages": [ { "name": "adhocore/jwt", @@ -156,21 +156,21 @@ }, { "name": "appwrite/php-runtimes", - "version": "0.13.3", + "version": "0.13.5", "source": { "type": "git", "url": "https://github.com/appwrite/runtimes.git", - "reference": "5d93fc578a9a543bcdc9b2c0562d80a51d56c73d" + "reference": "ba24c3a163f1a1da6cd355db92def508d05e59f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/runtimes/zipball/5d93fc578a9a543bcdc9b2c0562d80a51d56c73d", - "reference": "5d93fc578a9a543bcdc9b2c0562d80a51d56c73d", + "url": "https://api.github.com/repos/appwrite/runtimes/zipball/ba24c3a163f1a1da6cd355db92def508d05e59f7", + "reference": "ba24c3a163f1a1da6cd355db92def508d05e59f7", "shasum": "" }, "require": { "php": ">=8.0", - "utopia-php/system": "0.7.*" + "utopia-php/system": "0.8.*" }, "require-dev": { "phpunit/phpunit": "^9.3", @@ -204,9 +204,9 @@ ], "support": { "issues": "https://github.com/appwrite/runtimes/issues", - "source": "https://github.com/appwrite/runtimes/tree/0.13.3" + "source": "https://github.com/appwrite/runtimes/tree/0.13.5" }, - "time": "2024-03-01T14:47:47+00:00" + "time": "2024-04-01T10:35:02+00:00" }, { "name": "beberlei/assert", @@ -2443,16 +2443,16 @@ }, { "name": "utopia-php/system", - "version": "0.7.2", + "version": "0.8.0", "source": { "type": "git", "url": "https://github.com/utopia-php/system.git", - "reference": "4593d4d334b0c15879c4744a826e0362924c5d66" + "reference": "a2cbfb3c69b9ecb8b6f06c5774f3cf279ea7665e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/system/zipball/4593d4d334b0c15879c4744a826e0362924c5d66", - "reference": "4593d4d334b0c15879c4744a826e0362924c5d66", + "url": "https://api.github.com/repos/utopia-php/system/zipball/a2cbfb3c69b9ecb8b6f06c5774f3cf279ea7665e", + "reference": "a2cbfb3c69b9ecb8b6f06c5774f3cf279ea7665e", "shasum": "" }, "require": { @@ -2493,9 +2493,9 @@ ], "support": { "issues": "https://github.com/utopia-php/system/issues", - "source": "https://github.com/utopia-php/system/tree/0.7.2" + "source": "https://github.com/utopia-php/system/tree/0.8.0" }, - "time": "2023-10-20T01:39:17+00:00" + "time": "2024-04-01T10:22:28+00:00" }, { "name": "utopia-php/vcs", @@ -2731,16 +2731,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.37.8", + "version": "0.37.9", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "29844ac860237018a5d6bce17f8b591c996081ef" + "reference": "ad80d80e18f0cda981e1bddbf0841a805632caa0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/29844ac860237018a5d6bce17f8b591c996081ef", - "reference": "29844ac860237018a5d6bce17f8b591c996081ef", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/ad80d80e18f0cda981e1bddbf0841a805632caa0", + "reference": "ad80d80e18f0cda981e1bddbf0841a805632caa0", "shasum": "" }, "require": { @@ -2776,9 +2776,9 @@ "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "support": { "issues": "https://github.com/appwrite/sdk-generator/issues", - "source": "https://github.com/appwrite/sdk-generator/tree/0.37.8" + "source": "https://github.com/appwrite/sdk-generator/tree/0.37.9" }, - "time": "2024-03-12T14:13:43+00:00" + "time": "2024-03-24T05:40:55+00:00" }, { "name": "doctrine/deprecations", @@ -2899,16 +2899,16 @@ }, { "name": "laravel/pint", - "version": "v1.14.0", + "version": "v1.15.0", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "6b127276e3f263f7bb17d5077e9e0269e61b2a0e" + "reference": "c52de679b3ac01207016c179d7ce173e4be128c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/6b127276e3f263f7bb17d5077e9e0269e61b2a0e", - "reference": "6b127276e3f263f7bb17d5077e9e0269e61b2a0e", + "url": "https://api.github.com/repos/laravel/pint/zipball/c52de679b3ac01207016c179d7ce173e4be128c4", + "reference": "c52de679b3ac01207016c179d7ce173e4be128c4", "shasum": "" }, "require": { @@ -2961,7 +2961,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2024-02-20T17:38:05+00:00" + "time": "2024-03-26T16:40:24+00:00" }, { "name": "matthiasmullie/minify", diff --git a/src/Appwrite/Auth/OAuth2/Autodesk.php b/src/Appwrite/Auth/OAuth2/Autodesk.php index 0b268ead3b..9d99791962 100644 --- a/src/Appwrite/Auth/OAuth2/Autodesk.php +++ b/src/Appwrite/Auth/OAuth2/Autodesk.php @@ -88,7 +88,7 @@ class Autodesk extends OAuth2 'client_id' => $this->appID, 'client_secret' => $this->appSecret, 'grant_type' => 'refresh_token', - 'code' => $code, + 'code' => $refreshToken, 'redirect_uri' => $this->callback, ]) ); diff --git a/src/Appwrite/GraphQL/Resolvers.php b/src/Appwrite/GraphQL/Resolvers.php index a1f6af0f3f..8bc72af2f8 100644 --- a/src/Appwrite/GraphQL/Resolvers.php +++ b/src/Appwrite/GraphQL/Resolvers.php @@ -9,6 +9,7 @@ use Appwrite\Utopia\Response; use Utopia\App; use Utopia\Exception; use Utopia\Route; +use Utopia\System\System; class Resolvers { @@ -302,7 +303,7 @@ class Resolvers private static function escapePayload(array $payload, int $depth) { - if ($depth > App::getEnv('_APP_GRAPHQL_MAX_DEPTH', 3)) { + if ($depth > System::getEnv('_APP_GRAPHQL_MAX_DEPTH', 3)) { return; } diff --git a/src/Appwrite/Messaging/Adapter/Realtime.php b/src/Appwrite/Messaging/Adapter/Realtime.php index 792adfa5a4..55d8db2924 100644 --- a/src/Appwrite/Messaging/Adapter/Realtime.php +++ b/src/Appwrite/Messaging/Adapter/Realtime.php @@ -3,11 +3,11 @@ namespace Appwrite\Messaging\Adapter; use Appwrite\Messaging\Adapter; -use Utopia\App; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Role; +use Utopia\System\System; class Realtime extends Adapter { @@ -140,7 +140,7 @@ class Realtime extends Adapter $userId = array_key_exists('userId', $options) ? $options['userId'] : null; $redis = new \Redis(); //TODO: make this part of the constructor - $redis->connect(App::getEnv('_APP_REDIS_HOST', ''), App::getEnv('_APP_REDIS_PORT', '')); + $redis->connect(System::getEnv('_APP_REDIS_HOST', ''), System::getEnv('_APP_REDIS_PORT', '')); $redis->publish('realtime', json_encode([ 'project' => $projectId, 'roles' => $roles, diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index 76cbbebe03..dff3683dbe 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -4,7 +4,6 @@ namespace Appwrite\Migration; use Exception; use Swoole\Runtime; -use Utopia\App; use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\Database\Database; @@ -12,6 +11,7 @@ use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Query; use Utopia\Database\Validator\Authorization; +use Utopia\System\System; Runtime::enableCoroutine(SWOOLE_HOOK_ALL); @@ -252,7 +252,7 @@ abstract class Migration default => 'projects', }; - if (!$this->projectDB->exists(App::getEnv('_APP_DB_SCHEMA', 'appwrite'), $name)) { + if (!$this->projectDB->exists(System::getEnv('_APP_DB_SCHEMA', 'appwrite'), $name)) { $attributes = []; $indexes = []; $collection = $this->collections[$collectionType][$id]; diff --git a/src/Appwrite/Migration/Version/V15.php b/src/Appwrite/Migration/Version/V15.php index e2de0422de..ca20b6d7b3 100644 --- a/src/Appwrite/Migration/Version/V15.php +++ b/src/Appwrite/Migration/Version/V15.php @@ -4,7 +4,6 @@ namespace Appwrite\Migration\Version; use Appwrite\Migration\Migration; use Appwrite\OpenSSL\OpenSSL; -use Utopia\App; use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\Database\Database; @@ -12,6 +11,7 @@ use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; +use Utopia\System\System; class V15 extends Migration { @@ -1484,7 +1484,7 @@ class V15 extends Migration */ protected function encryptFilter(string $value): string { - $key = App::getEnv('_APP_OPENSSL_KEY_V1'); + $key = System::getEnv('_APP_OPENSSL_KEY_V1'); $iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM)); $tag = null; diff --git a/src/Appwrite/Migration/Version/V19.php b/src/Appwrite/Migration/Version/V19.php index 7934c1aaa6..bb887e40f7 100644 --- a/src/Appwrite/Migration/Version/V19.php +++ b/src/Appwrite/Migration/Version/V19.php @@ -3,7 +3,6 @@ namespace Appwrite\Migration\Version; use Appwrite\Migration\Migration; -use Utopia\App; use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\Database\Database; @@ -11,6 +10,7 @@ use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception; use Utopia\Database\Query; +use Utopia\System\System; class V19 extends Migration { @@ -731,7 +731,7 @@ class V19 extends Migration if (empty($document->getAttribute('scheduleId', null))) { $schedule = $this->consoleDB->createDocument('schedules', new Document([ - 'region' => App::getEnv('_APP_REGION', 'default'), // Todo replace with projects region + 'region' => System::getEnv('_APP_REGION', 'default'), // Todo replace with projects region 'resourceType' => 'function', 'resourceId' => $document->getId(), 'resourceInternalId' => $document->getInternalId(), diff --git a/src/Appwrite/Platform/Tasks/CalcTierStats.php b/src/Appwrite/Platform/Tasks/CalcTierStats.php index fc01881523..2d7dd3403f 100644 --- a/src/Appwrite/Platform/Tasks/CalcTierStats.php +++ b/src/Appwrite/Platform/Tasks/CalcTierStats.php @@ -4,7 +4,6 @@ namespace Appwrite\Platform\Tasks; use League\Csv\Writer; use PHPMailer\PHPMailer\PHPMailer; -use Utopia\App; use Utopia\Cache\Cache; use Utopia\CLI\Console; use Utopia\Database\Database; @@ -14,6 +13,7 @@ use Utopia\Database\Validator\Authorization; use Utopia\Platform\Action; use Utopia\Pools\Group; use Utopia\Registry\Registry; +use Utopia\System\System; use Utopia\Validator\Text; class CalcTierStats extends Action @@ -184,8 +184,8 @@ class CalcTierStats extends Action try { /** Addresses */ - $mail->setFrom(App::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM), 'Appwrite Cloud Hamster'); - $recipients = explode(',', App::getEnv('_APP_USERS_STATS_RECIPIENTS', '')); + $mail->setFrom(System::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM), 'Appwrite Cloud Hamster'); + $recipients = explode(',', System::getEnv('_APP_USERS_STATS_RECIPIENTS', '')); foreach ($recipients as $recipient) { $mail->addAddress($recipient); } diff --git a/src/Appwrite/Platform/Tasks/Doctor.php b/src/Appwrite/Platform/Tasks/Doctor.php index 2886dcd4dd..a79763cf42 100644 --- a/src/Appwrite/Platform/Tasks/Doctor.php +++ b/src/Appwrite/Platform/Tasks/Doctor.php @@ -12,6 +12,7 @@ use Utopia\Platform\Action; use Utopia\Registry\Registry; use Utopia\Storage\Device\Local; use Utopia\Storage\Storage; +use Utopia\System\System; class Doctor extends Action { @@ -35,11 +36,11 @@ class Doctor extends Action / \ ) __/ ) __/\ /\ / ) / )( )( ) _) _ )(( O ) \_/\_/(__) (__) (_/\_)(__\_)(__) (__) (____)(_)(__)\__/ "); - Console::log("\n" . '👩‍⚕️ Running ' . APP_NAME . ' Doctor for version ' . App::getEnv('_APP_VERSION', 'UNKNOWN') . ' ...' . "\n"); + Console::log("\n" . '👩‍⚕️ Running ' . APP_NAME . ' Doctor for version ' . System::getEnv('_APP_VERSION', 'UNKNOWN') . ' ...' . "\n"); Console::log('[Settings]'); - $domain = new Domain(App::getEnv('_APP_DOMAIN')); + $domain = new Domain(System::getEnv('_APP_DOMAIN')); if (!$domain->isKnown() || $domain->isTest()) { Console::log('🔴 Hostname has no public suffix (' . $domain->get() . ')'); @@ -47,7 +48,7 @@ class Doctor extends Action Console::log('🟢 Hostname has a public suffix (' . $domain->get() . ')'); } - $domain = new Domain(App::getEnv('_APP_DOMAIN_TARGET')); + $domain = new Domain(System::getEnv('_APP_DOMAIN_TARGET')); if (!$domain->isKnown() || $domain->isTest()) { Console::log('🔴 CNAME target has no public suffix (' . $domain->get() . ')'); @@ -55,27 +56,27 @@ class Doctor extends Action Console::log('🟢 CNAME target has a public suffix (' . $domain->get() . ')'); } - if (App::getEnv('_APP_OPENSSL_KEY_V1') === 'your-secret-key' || empty(App::getEnv('_APP_OPENSSL_KEY_V1'))) { + if (System::getEnv('_APP_OPENSSL_KEY_V1') === 'your-secret-key' || empty(System::getEnv('_APP_OPENSSL_KEY_V1'))) { Console::log('🔴 Not using a unique secret key for encryption'); } else { Console::log('🟢 Using a unique secret key for encryption'); } - if (App::getEnv('_APP_ENV', 'development') !== 'production') { + if (System::getEnv('_APP_ENV', 'development') !== 'production') { Console::log('🔴 App environment is set for development'); } else { Console::log('🟢 App environment is set for production'); } - if ('enabled' !== App::getEnv('_APP_OPTIONS_ABUSE', 'disabled')) { + if ('enabled' !== System::getEnv('_APP_OPTIONS_ABUSE', 'disabled')) { Console::log('🔴 Abuse protection is disabled'); } else { Console::log('🟢 Abuse protection is enabled'); } - $authWhitelistRoot = App::getEnv('_APP_CONSOLE_WHITELIST_ROOT', null); - $authWhitelistEmails = App::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null); - $authWhitelistIPs = App::getEnv('_APP_CONSOLE_WHITELIST_IPS', null); + $authWhitelistRoot = System::getEnv('_APP_CONSOLE_WHITELIST_ROOT', null); + $authWhitelistEmails = System::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null); + $authWhitelistIPs = System::getEnv('_APP_CONSOLE_WHITELIST_IPS', null); if ( empty($authWhitelistRoot) @@ -87,20 +88,20 @@ class Doctor extends Action Console::log('🟢 Console access limits are enabled'); } - if ('enabled' !== App::getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled')) { + if ('enabled' !== System::getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled')) { Console::log('🔴 HTTPS force option is disabled'); } else { Console::log('🟢 HTTPS force option is enabled'); } - if ('enabled' !== App::getEnv('_APP_OPTIONS_FUNCTIONS_FORCE_HTTPS', 'disabled')) { + if ('enabled' !== System::getEnv('_APP_OPTIONS_FUNCTIONS_FORCE_HTTPS', 'disabled')) { Console::log('🔴 HTTPS force option is disabled for function domains'); } else { Console::log('🟢 HTTPS force option is enabled for function domains'); } - $providerName = App::getEnv('_APP_LOGGING_PROVIDER', ''); - $providerConfig = App::getEnv('_APP_LOGGING_CONFIG', ''); + $providerName = System::getEnv('_APP_LOGGING_PROVIDER', ''); + $providerConfig = System::getEnv('_APP_LOGGING_CONFIG', ''); if (empty($providerName) || empty($providerConfig) || !Logger::hasProvider($providerName)) { Console::log('🔴 Logging adapter is disabled'); @@ -162,11 +163,11 @@ class Doctor extends Action } } - if (App::getEnv('_APP_STORAGE_ANTIVIRUS') === 'enabled') { // Check if scans are enabled + if (System::getEnv('_APP_STORAGE_ANTIVIRUS') === 'enabled') { // Check if scans are enabled try { $antivirus = new Network( - App::getEnv('_APP_STORAGE_ANTIVIRUS_HOST', 'clamav'), - (int) App::getEnv('_APP_STORAGE_ANTIVIRUS_PORT', 3310) + System::getEnv('_APP_STORAGE_ANTIVIRUS_HOST', 'clamav'), + (int) System::getEnv('_APP_STORAGE_ANTIVIRUS_PORT', 3310) ); if ((@$antivirus->ping())) { @@ -251,10 +252,10 @@ class Doctor extends Action try { if (App::isProduction()) { Console::log(''); - $version = \json_decode(@\file_get_contents(App::getEnv('_APP_HOME', 'http://localhost') . '/version'), true); + $version = \json_decode(@\file_get_contents(System::getEnv('_APP_HOME', 'http://localhost') . '/version'), true); if ($version && isset($version['version'])) { - if (\version_compare($version['version'], App::getEnv('_APP_VERSION', 'UNKNOWN')) === 0) { + if (\version_compare($version['version'], System::getEnv('_APP_VERSION', 'UNKNOWN')) === 0) { Console::info('You are running the latest version of ' . APP_NAME . '! 🥳'); } else { Console::info('A new version (' . $version['version'] . ') is available! 🥳' . "\n"); diff --git a/src/Appwrite/Platform/Tasks/GetMigrationStats.php b/src/Appwrite/Platform/Tasks/GetMigrationStats.php index dd43f75447..30a9ebb8e9 100644 --- a/src/Appwrite/Platform/Tasks/GetMigrationStats.php +++ b/src/Appwrite/Platform/Tasks/GetMigrationStats.php @@ -13,6 +13,7 @@ use Utopia\Database\Query; use Utopia\Platform\Action; use Utopia\Pools\Group; use Utopia\Registry\Registry; +use Utopia\System\System; class GetMigrationStats extends Action { @@ -164,8 +165,8 @@ class GetMigrationStats extends Action try { /** Addresses */ - $mail->setFrom(App::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM), 'Appwrite Cloud Hamster'); - $recipients = explode(',', App::getEnv('_APP_USERS_STATS_RECIPIENTS', '')); + $mail->setFrom(System::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM), 'Appwrite Cloud Hamster'); + $recipients = explode(',', System::getEnv('_APP_USERS_STATS_RECIPIENTS', '')); foreach ($recipients as $recipient) { $mail->addAddress($recipient); diff --git a/src/Appwrite/Platform/Tasks/Hamster.php b/src/Appwrite/Platform/Tasks/Hamster.php index 7f8ef4041d..2cfef1a2c9 100644 --- a/src/Appwrite/Platform/Tasks/Hamster.php +++ b/src/Appwrite/Platform/Tasks/Hamster.php @@ -3,12 +3,12 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Event\Hamster as EventHamster; -use Utopia\App; use Utopia\CLI\Console; use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Query; use Utopia\Platform\Action; +use Utopia\System\System; class Hamster extends Action { @@ -33,9 +33,9 @@ class Hamster extends Action Console::title('Cloud Hamster V1'); Console::success(APP_NAME . ' cloud hamster process has started'); - $sleep = (int) App::getEnv('_APP_HAMSTER_INTERVAL', '30'); // 30 seconds (by default) + $sleep = (int) System::getEnv('_APP_HAMSTER_INTERVAL', '30'); // 30 seconds (by default) - $jobInitTime = App::getEnv('_APP_HAMSTER_TIME', '22:00'); // (hour:minutes) + $jobInitTime = System::getEnv('_APP_HAMSTER_TIME', '22:00'); // (hour:minutes) $now = new \DateTime(); $now->setTimezone(new \DateTimeZone(date_default_timezone_get())); diff --git a/src/Appwrite/Platform/Tasks/Maintenance.php b/src/Appwrite/Platform/Tasks/Maintenance.php index 55bcd488a0..cfbc4b200a 100644 --- a/src/Appwrite/Platform/Tasks/Maintenance.php +++ b/src/Appwrite/Platform/Tasks/Maintenance.php @@ -4,13 +4,13 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Event\Certificate; use Appwrite\Event\Delete; -use Utopia\App; use Utopia\CLI\Console; use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Query; use Utopia\Platform\Action; +use Utopia\System\System; class Maintenance extends Action { @@ -35,11 +35,11 @@ class Maintenance extends Action Console::success(APP_NAME . ' maintenance process v1 has started'); // # of days in seconds (1 day = 86400s) - $interval = (int) App::getEnv('_APP_MAINTENANCE_INTERVAL', '86400'); - $delay = (int) App::getEnv('_APP_MAINTENANCE_DELAY', '0'); - $usageStatsRetentionHourly = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_USAGE_HOURLY', '8640000'); //100 days - $cacheRetention = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_CACHE', '2592000'); // 30 days - $schedulesDeletionRetention = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_SCHEDULES', '86400'); // 1 Day + $interval = (int) System::getEnv('_APP_MAINTENANCE_INTERVAL', '86400'); + $delay = (int) System::getEnv('_APP_MAINTENANCE_DELAY', '0'); + $usageStatsRetentionHourly = (int) System::getEnv('_APP_MAINTENANCE_RETENTION_USAGE_HOURLY', '8640000'); //100 days + $cacheRetention = (int) System::getEnv('_APP_MAINTENANCE_RETENTION_CACHE', '2592000'); // 30 days + $schedulesDeletionRetention = (int) System::getEnv('_APP_MAINTENANCE_RETENTION_SCHEDULES', '86400'); // 1 Day Console::loop(function () use ($interval, $cacheRetention, $schedulesDeletionRetention, $usageStatsRetentionHourly, $dbForConsole, $queueForDeletes, $queueForCertificates) { $time = DateTime::now(); diff --git a/src/Appwrite/Platform/Tasks/SSL.php b/src/Appwrite/Platform/Tasks/SSL.php index 251d3a046b..5af0cb6cd8 100644 --- a/src/Appwrite/Platform/Tasks/SSL.php +++ b/src/Appwrite/Platform/Tasks/SSL.php @@ -3,10 +3,10 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Event\Certificate; -use Utopia\App; use Utopia\CLI\Console; use Utopia\Database\Document; use Utopia\Platform\Action; +use Utopia\System\System; use Utopia\Validator\Boolean; use Utopia\Validator\Hostname; @@ -21,7 +21,7 @@ class SSL extends Action { $this ->desc('Validate server certificates') - ->param('domain', App::getEnv('_APP_DOMAIN', ''), new Hostname(), 'Domain to generate certificate for. If empty, main domain will be used.', true) + ->param('domain', System::getEnv('_APP_DOMAIN', ''), new Hostname(), 'Domain to generate certificate for. If empty, main domain will be used.', true) ->param('skip-check', true, new Boolean(true), 'If DNS and renew check should be skipped. Defaults to true, and when true, all jobs will result in certificate generation attempt.', true) ->inject('queueForCertificates') ->callback(fn (string $domain, bool|string $skipCheck, Certificate $queueForCertificates) => $this->action($domain, $skipCheck, $queueForCertificates)); diff --git a/src/Appwrite/Platform/Tasks/ScheduleBase.php b/src/Appwrite/Platform/Tasks/ScheduleBase.php index 81110f5216..a50fbb2403 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleBase.php +++ b/src/Appwrite/Platform/Tasks/ScheduleBase.php @@ -3,7 +3,6 @@ namespace Appwrite\Platform\Tasks; use Swoole\Timer; -use Utopia\App; use Utopia\CLI\Console; use Utopia\Database\Database; use Utopia\Database\DateTime; @@ -12,6 +11,7 @@ use Utopia\Database\Exception; use Utopia\Database\Query; use Utopia\Platform\Action; use Utopia\Pools\Group; +use Utopia\System\System; use function Swoole\Coroutine\run; @@ -99,7 +99,7 @@ abstract class ScheduleBase extends Action } $results = $dbForConsole->find('schedules', \array_merge($paginationQueries, [ - Query::equal('region', [App::getEnv('_APP_REGION', 'default')]), + Query::equal('region', [System::getEnv('_APP_REGION', 'default')]), Query::equal('resourceType', [static::getSupportedResource()]), Query::equal('active', [true]), ])); @@ -153,7 +153,7 @@ abstract class ScheduleBase extends Action } $results = $dbForConsole->find('schedules', \array_merge($paginationQueries, [ - Query::equal('region', [App::getEnv('_APP_REGION', 'default')]), + Query::equal('region', [System::getEnv('_APP_REGION', 'default')]), Query::equal('resourceType', [static::getSupportedResource()]), Query::greaterThanEqual('resourceUpdatedAt', $lastSyncUpdate), ])); diff --git a/src/Appwrite/Platform/Tasks/Specs.php b/src/Appwrite/Platform/Tasks/Specs.php index 46c83fe2b1..114e12ac85 100644 --- a/src/Appwrite/Platform/Tasks/Specs.php +++ b/src/Appwrite/Platform/Tasks/Specs.php @@ -18,6 +18,7 @@ use Utopia\Database\Database; use Utopia\Platform\Action; use Utopia\Registry\Registry; use Utopia\Request; +use Utopia\System\System; use Utopia\Validator\Text; use Utopia\Validator\WhiteList; @@ -257,8 +258,8 @@ class Specs extends Action }; $specs = new Specification($formatInstance); - $endpoint = App::getEnv('_APP_HOME', '[HOSTNAME]'); - $email = App::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM); + $endpoint = System::getEnv('_APP_HOME', '[HOSTNAME]'); + $email = System::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM); $formatInstance ->setParam('name', APP_NAME) diff --git a/src/Appwrite/Platform/Tasks/Vars.php b/src/Appwrite/Platform/Tasks/Vars.php index 696073e568..499f8b15ec 100644 --- a/src/Appwrite/Platform/Tasks/Vars.php +++ b/src/Appwrite/Platform/Tasks/Vars.php @@ -2,10 +2,10 @@ namespace Appwrite\Platform\Tasks; -use Utopia\App; use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\Platform\Action; +use Utopia\System\System; class Vars extends Action { @@ -33,7 +33,7 @@ class Vars extends Action } foreach ($vars as $key => $value) { - Console::log('- ' . $value['name'] . '=' . App::getEnv($value['name'], '')); + Console::log('- ' . $value['name'] . '=' . System::getEnv($value['name'], '')); } } } diff --git a/src/Appwrite/Platform/Tasks/Version.php b/src/Appwrite/Platform/Tasks/Version.php index 4a9cbf9dcf..25e2d13c65 100644 --- a/src/Appwrite/Platform/Tasks/Version.php +++ b/src/Appwrite/Platform/Tasks/Version.php @@ -2,9 +2,9 @@ namespace Appwrite\Platform\Tasks; -use Utopia\App; use Utopia\CLI\Console; use Utopia\Platform\Action; +use Utopia\System\System; class Version extends Action { @@ -18,7 +18,7 @@ class Version extends Action $this ->desc('Get the server version') ->callback(function () { - Console::log(App::getEnv('_APP_VERSION', 'UNKNOWN')); + Console::log(System::getEnv('_APP_VERSION', 'UNKNOWN')); }); } } diff --git a/src/Appwrite/Platform/Workers/Builds.php b/src/Appwrite/Platform/Workers/Builds.php index 8a25980bc1..ff1c439aa2 100644 --- a/src/Appwrite/Platform/Workers/Builds.php +++ b/src/Appwrite/Platform/Workers/Builds.php @@ -10,7 +10,6 @@ use Appwrite\Utopia\Response\Model\Deployment; use Appwrite\Vcs\Comment; use Executor\Executor; use Swoole\Coroutine as Co; -use Utopia\App; use Utopia\Cache\Cache; use Utopia\CLI\Console; use Utopia\Config\Config; @@ -27,6 +26,7 @@ use Utopia\Platform\Action; use Utopia\Queue\Message; use Utopia\Storage\Device; use Utopia\Storage\Device\Local; +use Utopia\System\System; use Utopia\VCS\Adapter\Git\GitHub; class Builds extends Action @@ -117,7 +117,7 @@ class Builds extends Action */ protected function buildDeployment(Device $deviceForFunctions, Func $queueForFunctions, Event $queueForEvents, Usage $queueForUsage, Database $dbForConsole, Database $dbForProject, GitHub $github, Document $project, Document $function, Document $deployment, Document $template, Log $log): void { - $executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST')); + $executor = new Executor(System::getEnv('_APP_EXECUTOR_HOST')); $functionId = $function->getId(); $log->addTag('functionId', $function->getId()); @@ -195,8 +195,8 @@ class Builds extends Action if ($isVcsEnabled) { $installation = $dbForConsole->getDocument('installations', $installationId); $providerInstallationId = $installation->getAttribute('providerInstallationId'); - $privateKey = App::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); - $githubAppId = App::getEnv('_APP_VCS_GITHUB_APP_ID'); + $privateKey = System::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); + $githubAppId = System::getEnv('_APP_VCS_GITHUB_APP_ID'); $github->initializeVariables($providerInstallationId, $privateKey, $githubAppId); } @@ -304,7 +304,7 @@ class Builds extends Action } $directorySize = $localDevice->getDirectorySize($tmpDirectory); - $functionsSizeLimit = (int) App::getEnv('_APP_FUNCTIONS_SIZE_LIMIT', '30000000'); + $functionsSizeLimit = (int) System::getEnv('_APP_FUNCTIONS_SIZE_LIMIT', '30000000'); if ($directorySize > $functionsSizeLimit) { throw new \Exception('Repository directory size should be less than ' . number_format($functionsSizeLimit / 1048576, 2) . ' MBs.'); } @@ -593,8 +593,8 @@ class Builds extends Action $name = "{$functionName} ({$projectName})"; - $protocol = App::getEnv('_APP_OPTIONS_FORCE_HTTPS') == 'disabled' ? 'http' : 'https'; - $hostname = App::getEnv('_APP_DOMAIN'); + $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') == 'disabled' ? 'http' : 'https'; + $hostname = System::getEnv('_APP_DOMAIN'); $functionId = $function->getId(); $projectId = $project->getId(); $providerTargetUrl = $protocol . '://' . $hostname . "/console/project-$projectId/functions/function-$functionId"; diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 7cc32ca1c9..1fbbd3b2ec 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -26,6 +26,7 @@ use Utopia\Locale\Locale; use Utopia\Logger\Log; use Utopia\Platform\Action; use Utopia\Queue\Message; +use Utopia\System\System; class Certificates extends Action { @@ -134,7 +135,7 @@ class Certificates extends Action try { // Email for alerts is required by LetsEncrypt - $email = App::getEnv('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS'); + $email = System::getEnv('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS'); if (empty($email)) { throw new Exception('You must set a valid security email address (_APP_SYSTEM_SECURITY_EMAIL_ADDRESS) to issue an SSL certificate.'); } @@ -235,7 +236,7 @@ class Certificates extends Action */ private function getMainDomain(): ?string { - $envDomain = App::getEnv('_APP_DOMAIN', ''); + $envDomain = System::getEnv('_APP_DOMAIN', ''); if (!empty($envDomain) && $envDomain !== 'localhost') { return $envDomain; } @@ -267,7 +268,7 @@ class Certificates extends Action if (!$isMainDomain) { // TODO: Would be awesome to also support A/AAAA records here. Maybe dry run? // Validate if domain target is properly configured - $target = new Domain(App::getEnv('_APP_DOMAIN_TARGET', '')); + $target = new Domain(System::getEnv('_APP_DOMAIN_TARGET', '')); if (!$target->isKnown() || $target->isTest()) { throw new Exception('Unreachable CNAME target (' . $target->get() . '), please use a domain with a public suffix.'); @@ -436,7 +437,7 @@ class Certificates extends Action // Log error into console Console::warning('Cannot renew domain (' . $domain . ') on attempt no. ' . $attempt . ' certificate: ' . $errorMessage); - $locale = new Locale(App::getEnv('_APP_LOCALE', 'en')); + $locale = new Locale(System::getEnv('_APP_LOCALE', 'en')); // Send mail to administratore mail $template = Template::fromFile(__DIR__ . '/../../../../app/config/locale/templates/email-certificate-failed.tpl'); @@ -473,7 +474,7 @@ class Certificates extends Action ->setBody($body) ->setName('Appwrite Administrator') ->setVariables($emailVariables) - ->setRecipient(App::getEnv('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS')) + ->setRecipient(System::getEnv('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS')) ->trigger(); } diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index fdf494afec..189ef6496b 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -8,7 +8,6 @@ use Executor\Executor; use Throwable; use Utopia\Abuse\Abuse; use Utopia\Abuse\Adapters\TimeLimit; -use Utopia\App; use Utopia\Audit\Audit; use Utopia\Cache\Adapter\Filesystem; use Utopia\Cache\Cache; @@ -26,6 +25,7 @@ use Utopia\Logger\Log; use Utopia\Platform\Action; use Utopia\Queue\Message; use Utopia\Storage\Device; +use Utopia\System\System; class Deletes extends Action { @@ -180,7 +180,7 @@ class Deletes extends Action $this->listByGroup( 'schedules', [ - Query::equal('region', [App::getEnv('_APP_REGION', 'default')]), + Query::equal('region', [System::getEnv('_APP_REGION', 'default')]), Query::lessThanEqual('resourceUpdatedAt', $datetime), Query::equal('active', [false]), ], @@ -1083,7 +1083,7 @@ class Deletes extends Action */ private function deleteRuntimes(callable $getProjectDB, ?Document $function, Document $project): void { - $executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST')); + $executor = new Executor(System::getEnv('_APP_EXECUTOR_HOST')); $deleteByFunction = function (Document $function) use ($getProjectDB, $project, $executor) { $this->listByGroup( diff --git a/src/Appwrite/Platform/Workers/Functions.php b/src/Appwrite/Platform/Workers/Functions.php index 05695d9e26..e527456c7e 100644 --- a/src/Appwrite/Platform/Workers/Functions.php +++ b/src/Appwrite/Platform/Workers/Functions.php @@ -9,7 +9,6 @@ use Appwrite\Messaging\Adapter\Realtime; use Appwrite\Utopia\Response\Model\Execution; use Exception; use Executor\Executor; -use Utopia\App; use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\Database\Database; @@ -24,6 +23,7 @@ use Utopia\Database\Query; use Utopia\Logger\Log; use Utopia\Platform\Action; use Utopia\Queue\Message; +use Utopia\System\System; class Functions extends Action { @@ -383,7 +383,7 @@ class Functions extends Action try { $version = $function->getAttribute('version', 'v2'); $command = $runtime['startCommand']; - $executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST')); + $executor = new Executor(System::getEnv('_APP_EXECUTOR_HOST')); $command = $version === 'v2' ? '' : 'cp /tmp/code.tar.gz /mnt/code/code.tar.gz && nohup helpers/start.sh "' . $command . '"'; $executionResponse = $executor->createExecution( projectId: $project->getId(), diff --git a/src/Appwrite/Platform/Workers/Hamster.php b/src/Appwrite/Platform/Workers/Hamster.php index b72b7f7030..2c34f6f3dc 100644 --- a/src/Appwrite/Platform/Workers/Hamster.php +++ b/src/Appwrite/Platform/Workers/Hamster.php @@ -6,7 +6,6 @@ use Appwrite\Event\Hamster as EventHamster; use Appwrite\Network\Validator\Origin; use Utopia\Analytics\Adapter\Mixpanel; use Utopia\Analytics\Event as AnalyticsEvent; -use Utopia\App; use Utopia\Cache\Cache; use Utopia\CLI\Console; use Utopia\Config\Config; @@ -17,6 +16,7 @@ use Utopia\Database\Validator\Authorization; use Utopia\Platform\Action; use Utopia\Pools\Group; use Utopia\Queue\Message; +use Utopia\System\System; class Hamster extends Action { @@ -67,7 +67,7 @@ class Hamster extends Action */ public function action(Message $message, Group $pools, Cache $cache, Database $dbForConsole): void { - $token = App::getEnv('_APP_MIXPANEL_TOKEN', ''); + $token = System::getEnv('_APP_MIXPANEL_TOKEN', ''); if (empty($token)) { throw new \Exception('Missing MixPanel Token'); } diff --git a/src/Appwrite/Platform/Workers/Mails.php b/src/Appwrite/Platform/Workers/Mails.php index 57d1baa978..e48f96ea90 100644 --- a/src/Appwrite/Platform/Workers/Mails.php +++ b/src/Appwrite/Platform/Workers/Mails.php @@ -6,11 +6,11 @@ use Appwrite\Template\Template; use Exception; use PHPMailer\PHPMailer\PHPMailer; use Swoole\Runtime; -use Utopia\App; use Utopia\Logger\Log; use Utopia\Platform\Action; use Utopia\Queue\Message; use Utopia\Registry\Registry; +use Utopia\System\System; class Mails extends Action { @@ -59,14 +59,14 @@ class Mails extends Action $smtp = $payload['smtp']; - if (empty($smtp) && empty(App::getEnv('_APP_SMTP_HOST'))) { + if (empty($smtp) && empty(System::getEnv('_APP_SMTP_HOST'))) { throw new Exception('Skipped mail processing. No SMTP configuration has been set.'); } $log->addTag('type', empty($smtp) ? 'cloud' : 'smtp'); - $protocol = App::getEnv('_APP_OPTIONS_FORCE_HTTPS') == 'disabled' ? 'http' : 'https'; - $hostname = App::getEnv('_APP_DOMAIN'); + $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') == 'disabled' ? 'http' : 'https'; + $hostname = System::getEnv('_APP_DOMAIN'); $recipient = $payload['recipient']; $subject = $payload['subject']; @@ -121,8 +121,8 @@ class Mails extends Action $mail->AltBody = \strip_tags($mail->AltBody); $mail->AltBody = \trim($mail->AltBody); - $replyTo = App::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM); - $replyToName = \urldecode(App::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server')); + $replyTo = System::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM); + $replyToName = \urldecode(System::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server')); if (!empty($smtp)) { $replyTo = !empty($smtp['replyTo']) ? $smtp['replyTo'] : $smtp['senderEmail']; diff --git a/src/Appwrite/Platform/Workers/Messaging.php b/src/Appwrite/Platform/Workers/Messaging.php index 0f1503b3e5..c4bc38dae4 100644 --- a/src/Appwrite/Platform/Workers/Messaging.php +++ b/src/Appwrite/Platform/Workers/Messaging.php @@ -4,7 +4,6 @@ namespace Appwrite\Platform\Workers; use Appwrite\Event\Usage; use Appwrite\Messaging\Status as MessageStatus; -use Utopia\App; use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\Database\Database; @@ -36,6 +35,7 @@ use Utopia\Platform\Action; use Utopia\Queue\Message; use Utopia\Storage\Device; use Utopia\Storage\Storage; +use Utopia\System\System; use function Swoole\Coroutine\batch; @@ -361,7 +361,7 @@ class Messaging extends Action private function sendInternalSMSMessage(Document $message, Document $project, array $recipients, Usage $queueForUsage, Log $log): void { - if (empty(App::getEnv('_APP_SMS_PROVIDER')) || empty(App::getEnv('_APP_SMS_FROM'))) { + if (empty(System::getEnv('_APP_SMS_PROVIDER')) || empty(System::getEnv('_APP_SMS_FROM'))) { throw new \Exception('Skipped SMS processing. Missing "_APP_SMS_PROVIDER" or "_APP_SMS_FROM" environment variables.'); } @@ -371,7 +371,7 @@ class Messaging extends Action Console::log('Project: ' . $project->getId()); - $denyList = App::getEnv('_APP_SMS_PROJECTS_DENY_LIST', ''); + $denyList = System::getEnv('_APP_SMS_PROJECTS_DENY_LIST', ''); $denyList = explode(',', $denyList); if (\in_array($project->getId(), $denyList)) { @@ -379,14 +379,14 @@ class Messaging extends Action return; } - $smsDSN = new DSN(App::getEnv('_APP_SMS_PROVIDER')); + $smsDSN = new DSN(System::getEnv('_APP_SMS_PROVIDER')); $host = $smsDSN->getHost(); $password = $smsDSN->getPassword(); $user = $smsDSN->getUser(); $log->addTag('type', $host); - $from = App::getEnv('_APP_SMS_FROM'); + $from = System::getEnv('_APP_SMS_FROM'); $provider = new Document([ '$id' => ID::unique(), diff --git a/src/Appwrite/Platform/Workers/Usage.php b/src/Appwrite/Platform/Workers/Usage.php index 3227153e08..48724c0d0d 100644 --- a/src/Appwrite/Platform/Workers/Usage.php +++ b/src/Appwrite/Platform/Workers/Usage.php @@ -4,12 +4,12 @@ namespace Appwrite\Platform\Workers; use Appwrite\Event\UsageDump; use Exception; -use Utopia\App; use Utopia\CLI\Console; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Platform\Action; use Utopia\Queue\Message; +use Utopia\System\System; class Usage extends Action { @@ -58,7 +58,7 @@ class Usage extends Action } //Todo Figure out way to preserve keys when the container is being recreated @shimonewman - $aggregationInterval = (int) App::getEnv('_APP_USAGE_AGGREGATION_INTERVAL', '20'); + $aggregationInterval = (int) System::getEnv('_APP_USAGE_AGGREGATION_INTERVAL', '20'); $project = new Document($payload['project'] ?? []); $projectId = $project->getInternalId(); foreach ($payload['reduce'] ?? [] as $document) { diff --git a/src/Appwrite/Platform/Workers/UsageDump.php b/src/Appwrite/Platform/Workers/UsageDump.php index e1e62feb9f..b7097dbb04 100644 --- a/src/Appwrite/Platform/Workers/UsageDump.php +++ b/src/Appwrite/Platform/Workers/UsageDump.php @@ -3,13 +3,13 @@ namespace Appwrite\Platform\Workers; use Appwrite\Extend\Exception; -use Utopia\App; use Utopia\CLI\Console; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception\Duplicate; use Utopia\Platform\Action; use Utopia\Queue\Message; +use Utopia\System\System; class UsageDump extends Action { @@ -81,7 +81,7 @@ class UsageDump extends Action 'time' => $time, 'metric' => $key, 'value' => $value, - 'region' => App::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default'), ])); } catch (Duplicate $th) { if ($value < 0) { diff --git a/src/Appwrite/Platform/Workers/Webhooks.php b/src/Appwrite/Platform/Workers/Webhooks.php index da5a82999f..d60946f709 100644 --- a/src/Appwrite/Platform/Workers/Webhooks.php +++ b/src/Appwrite/Platform/Workers/Webhooks.php @@ -5,13 +5,13 @@ namespace Appwrite\Platform\Workers; use Appwrite\Event\Mail; use Appwrite\Template\Template; use Exception; -use Utopia\App; use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Query; use Utopia\Logger\Log; use Utopia\Platform\Action; use Utopia\Queue\Message; +use Utopia\System\System; class Webhooks extends Action { @@ -103,8 +103,8 @@ class Webhooks extends Action \curl_setopt($ch, CURLOPT_MAXFILESIZE, self::MAX_FILE_SIZE); \curl_setopt($ch, CURLOPT_USERAGENT, \sprintf( APP_USERAGENT, - App::getEnv('_APP_VERSION', 'UNKNOWN'), - App::getEnv('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY) + System::getEnv('_APP_VERSION', 'UNKNOWN'), + System::getEnv('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY) )); \curl_setopt( $ch, @@ -156,7 +156,7 @@ class Webhooks extends Action $webhook->setAttribute('logs', $logs); - if ($attempts >= \intval(App::getEnv('_APP_WEBHOOK_MAX_FAILED_ATTEMPTS', '10'))) { + if ($attempts >= \intval(System::getEnv('_APP_WEBHOOK_MAX_FAILED_ATTEMPTS', '10'))) { $webhook->setAttribute('enabled', false); $this->sendEmailAlert($attempts, $statusCode, $webhook, $project, $dbForConsole, $queueForMails); } diff --git a/src/Appwrite/Vcs/Comment.php b/src/Appwrite/Vcs/Comment.php index 35f76b6fd0..8bea1ae8d5 100644 --- a/src/Appwrite/Vcs/Comment.php +++ b/src/Appwrite/Vcs/Comment.php @@ -2,8 +2,10 @@ namespace Appwrite\Vcs; -use Utopia\App; use Utopia\Database\Document; +use Utopia\System\System; + +// TODO this class should be moved to a more appropriate place in the architecture class Comment { @@ -73,8 +75,8 @@ class Comment $text .= "| Function | ID | Status | Action |\n"; $text .= "| :- | :- | :- | :- |\n"; - $protocol = App::getEnv('_APP_OPTIONS_FORCE_HTTPS') == 'disabled' ? 'http' : 'https'; - $hostname = App::getEnv('_APP_DOMAIN'); + $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') == 'disabled' ? 'http' : 'https'; + $hostname = System::getEnv('_APP_DOMAIN'); foreach ($project['functions'] as $functionId => $function) { $generateImage = function (string $status) use ($protocol, $hostname) { diff --git a/src/Executor/Executor.php b/src/Executor/Executor.php index 8e73747047..76c66de231 100644 --- a/src/Executor/Executor.php +++ b/src/Executor/Executor.php @@ -3,7 +3,7 @@ namespace Executor; use Exception; -use Utopia\App; +use Utopia\System\System; class Executor { @@ -34,11 +34,11 @@ class Executor } $this->endpoint = $endpoint; - $this->cpus = \intval(App::getEnv('_APP_FUNCTIONS_CPUS', '1')); - $this->memory = \intval(App::getEnv('_APP_FUNCTIONS_MEMORY', '512')); + $this->cpus = \intval(System::getEnv('_APP_FUNCTIONS_CPUS', '1')); + $this->memory = \intval(System::getEnv('_APP_FUNCTIONS_MEMORY', '512')); $this->headers = [ 'content-type' => 'application/json', - 'authorization' => 'Bearer ' . App::getEnv('_APP_EXECUTOR_SECRET', ''), + 'authorization' => 'Bearer ' . System::getEnv('_APP_EXECUTOR_SECRET', ''), 'x-opr-addressing-method' => 'anycast-efficient' ]; } @@ -72,7 +72,7 @@ class Executor ) { $runtimeId = "$projectId-$deploymentId-build"; $route = "/runtimes"; - $timeout = (int) App::getEnv('_APP_FUNCTIONS_BUILD_TIMEOUT', 900); + $timeout = (int) System::getEnv('_APP_FUNCTIONS_BUILD_TIMEOUT', 900); $params = [ 'runtimeId' => $runtimeId, 'source' => $source, @@ -111,7 +111,7 @@ class Executor string $projectId, callable $callback ) { - $timeout = (int) App::getEnv('_APP_FUNCTIONS_BUILD_TIMEOUT', 900); + $timeout = (int) System::getEnv('_APP_FUNCTIONS_BUILD_TIMEOUT', 900); $runtimeId = "$projectId-$deploymentId-build"; $route = "/runtimes/{$runtimeId}/logs"; @@ -180,7 +180,7 @@ class Executor int $requestTimeout = null ) { if (empty($headers['host'])) { - $headers['host'] = App::getEnv('_APP_DOMAIN', ''); + $headers['host'] = System::getEnv('_APP_DOMAIN', ''); } $runtimeId = "$projectId-$deploymentId"; diff --git a/tests/e2e/General/AbuseTest.php b/tests/e2e/General/AbuseTest.php index f5a2829974..898fbd4aff 100644 --- a/tests/e2e/General/AbuseTest.php +++ b/tests/e2e/General/AbuseTest.php @@ -7,10 +7,10 @@ use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideNone; -use Utopia\App; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; +use Utopia\System\System; class AbuseTest extends Scope { @@ -21,7 +21,7 @@ class AbuseTest extends Scope { parent::setUp(); - if (App::getEnv('_APP_OPTIONS_ABUSE') === 'disabled') { + if (System::getEnv('_APP_OPTIONS_ABUSE') === 'disabled') { $this->markTestSkipped('Abuse is not enabled.'); } } diff --git a/tests/e2e/Services/GraphQL/AbuseTest.php b/tests/e2e/Services/GraphQL/AbuseTest.php index 48ee64d141..d4e87cf029 100644 --- a/tests/e2e/Services/GraphQL/AbuseTest.php +++ b/tests/e2e/Services/GraphQL/AbuseTest.php @@ -6,10 +6,10 @@ use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideServer; -use Utopia\App; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; +use Utopia\System\System; class AbuseTest extends Scope { @@ -21,7 +21,7 @@ class AbuseTest extends Scope { parent::setUp(); - if (App::getEnv('_APP_OPTIONS_ABUSE') === 'disabled') { + if (System::getEnv('_APP_OPTIONS_ABUSE') === 'disabled') { $this->markTestSkipped('Abuse is not enabled.'); } } @@ -90,7 +90,7 @@ class AbuseTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $graphQLPayload); - $max = App::getEnv('_APP_GRAPHQL_MAX_QUERY_COMPLEXITY', 250); + $max = System::getEnv('_APP_GRAPHQL_MAX_QUERY_COMPLEXITY', 250); $this->assertEquals('Max query complexity should be ' . $max . ' but got 259.', $response['body']['errors'][0]['message']); } @@ -98,7 +98,7 @@ class AbuseTest extends Scope public function testTooManyQueriesBlocked() { $projectId = $this->getProject()['$id']; - $maxQueries = App::getEnv('_APP_GRAPHQL_MAX_QUERIES', 10); + $maxQueries = System::getEnv('_APP_GRAPHQL_MAX_QUERIES', 10); $query = []; for ($i = 0; $i <= $maxQueries + 1; $i++) { diff --git a/tests/e2e/Services/GraphQL/MessagingTest.php b/tests/e2e/Services/GraphQL/MessagingTest.php index f5e92b9113..bbf82abd91 100644 --- a/tests/e2e/Services/GraphQL/MessagingTest.php +++ b/tests/e2e/Services/GraphQL/MessagingTest.php @@ -6,9 +6,9 @@ use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideServer; -use Utopia\App; use Utopia\Database\Helpers\ID; use Utopia\DSN\DSN; +use Utopia\System\System; class MessagingTest extends Scope { @@ -547,11 +547,11 @@ class MessagingTest extends Scope public function testSendEmail() { - if (empty(App::getEnv('_APP_MESSAGE_EMAIL_TEST_DSN'))) { + if (empty(System::getEnv('_APP_MESSAGE_EMAIL_TEST_DSN'))) { $this->markTestSkipped('Email DSN not provided'); } - $emailDSN = new DSN(App::getEnv('_APP_MESSAGE_EMAIL_TEST_DSN')); + $emailDSN = new DSN(System::getEnv('_APP_MESSAGE_EMAIL_TEST_DSN')); $to = $emailDSN->getParam('to'); $fromName = $emailDSN->getParam('fromName'); $fromEmail = $emailDSN->getParam('fromEmail'); @@ -757,11 +757,11 @@ class MessagingTest extends Scope public function testSendSMS() { - if (empty(App::getEnv('_APP_MESSAGE_SMS_TEST_DSN'))) { + if (empty(System::getEnv('_APP_MESSAGE_SMS_TEST_DSN'))) { $this->markTestSkipped('SMS DSN not provided'); } - $smsDSN = new DSN(App::getEnv('_APP_MESSAGE_SMS_TEST_DSN')); + $smsDSN = new DSN(System::getEnv('_APP_MESSAGE_SMS_TEST_DSN')); $to = $smsDSN->getParam('to'); $from = $smsDSN->getParam('from'); $authKey = $smsDSN->getPassword(); @@ -960,11 +960,11 @@ class MessagingTest extends Scope public function testSendPushNotification() { - if (empty(App::getEnv('_APP_MESSAGE_PUSH_TEST_DSN'))) { + if (empty(System::getEnv('_APP_MESSAGE_PUSH_TEST_DSN'))) { $this->markTestSkipped('Push DSN empty'); } - $pushDSN = new DSN(App::getEnv('_APP_MESSAGE_PUSH_TEST_DSN')); + $pushDSN = new DSN(System::getEnv('_APP_MESSAGE_PUSH_TEST_DSN')); $to = $pushDSN->getParam('to'); $serviceAccountJSON = $pushDSN->getParam('serviceAccountJSON'); diff --git a/tests/e2e/Services/Messaging/MessagingBase.php b/tests/e2e/Services/Messaging/MessagingBase.php index 5d43d982e7..b3e4000b55 100644 --- a/tests/e2e/Services/Messaging/MessagingBase.php +++ b/tests/e2e/Services/Messaging/MessagingBase.php @@ -5,7 +5,6 @@ namespace Tests\E2E\Services\Messaging; use Appwrite\Messaging\Status as MessageStatus; use CURLFile; use Tests\E2E\Client; -use Utopia\App; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; @@ -13,6 +12,7 @@ use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; use Utopia\Database\Query; use Utopia\DSN\DSN; +use Utopia\System\System; trait MessagingBase { @@ -1210,11 +1210,11 @@ trait MessagingBase public function testSendEmail() { - if (empty(App::getEnv('_APP_MESSAGE_EMAIL_TEST_DSN'))) { + if (empty(System::getEnv('_APP_MESSAGE_EMAIL_TEST_DSN'))) { $this->markTestSkipped('Email DSN not provided'); } - $emailDSN = new DSN(App::getEnv('_APP_MESSAGE_EMAIL_TEST_DSN')); + $emailDSN = new DSN(System::getEnv('_APP_MESSAGE_EMAIL_TEST_DSN')); $to = $emailDSN->getParam('to'); $fromName = $emailDSN->getParam('fromName'); $fromEmail = $emailDSN->getParam('fromEmail'); @@ -1370,11 +1370,11 @@ trait MessagingBase public function testSendSMS() { - if (empty(App::getEnv('_APP_MESSAGE_SMS_TEST_DSN'))) { + if (empty(System::getEnv('_APP_MESSAGE_SMS_TEST_DSN'))) { $this->markTestSkipped('SMS DSN not provided'); } - $smsDSN = new DSN(App::getEnv('_APP_MESSAGE_SMS_TEST_DSN')); + $smsDSN = new DSN(System::getEnv('_APP_MESSAGE_SMS_TEST_DSN')); $to = $smsDSN->getParam('to'); $from = $smsDSN->getParam('from'); $senderId = $smsDSN->getUser(); @@ -1534,11 +1534,11 @@ trait MessagingBase public function testSendPushNotification() { - if (empty(App::getEnv('_APP_MESSAGE_PUSH_TEST_DSN'))) { + if (empty(System::getEnv('_APP_MESSAGE_PUSH_TEST_DSN'))) { $this->markTestSkipped('Push DSN empty'); } - $dsn = new DSN(App::getEnv('_APP_MESSAGE_PUSH_TEST_DSN')); + $dsn = new DSN(System::getEnv('_APP_MESSAGE_PUSH_TEST_DSN')); $to = $dsn->getParam('to'); $serviceAccountJSON = $dsn->getParam('serviceAccountJSON'); diff --git a/tests/e2e/Services/VCS/VCSBase.php b/tests/e2e/Services/VCS/VCSBase.php index 7531ea3bc8..a65ebcd1d3 100644 --- a/tests/e2e/Services/VCS/VCSBase.php +++ b/tests/e2e/Services/VCS/VCSBase.php @@ -2,7 +2,7 @@ namespace Tests\E2E\Services\VCS; -use Utopia\App; +use Utopia\System\System; trait VCSBase { @@ -10,7 +10,7 @@ trait VCSBase { parent::setUp(); - if (App::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY') === 'disabled') { + if (System::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY') === 'disabled') { $this->markTestSkipped('VCS is not enabled.'); } } diff --git a/tests/e2e/Services/VCS/VCSConsoleClientTest.php b/tests/e2e/Services/VCS/VCSConsoleClientTest.php index 5e04c81a86..f109e250bf 100644 --- a/tests/e2e/Services/VCS/VCSConsoleClientTest.php +++ b/tests/e2e/Services/VCS/VCSConsoleClientTest.php @@ -6,11 +6,11 @@ use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideConsole; -use Utopia\App; use Utopia\Cache\Adapter\None; use Utopia\Cache\Cache; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Role; +use Utopia\System\System; use Utopia\VCS\Adapter\Git\GitHub; class VCSConsoleClientTest extends Scope @@ -278,8 +278,8 @@ class VCSConsoleClientTest extends Scope */ $github = new GitHub(new Cache(new None())); - $privateKey = App::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); - $githubAppId = App::getEnv('_APP_VCS_GITHUB_APP_ID'); + $privateKey = System::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); + $githubAppId = System::getEnv('_APP_VCS_GITHUB_APP_ID'); $github->initializeVariables($this->providerInstallationId, $privateKey, $githubAppId); $repository = $this->client->call(Client::METHOD_POST, '/vcs/github/installations/' . $installationId . '/providerRepositories', array_merge([ diff --git a/tests/unit/Event/EventTest.php b/tests/unit/Event/EventTest.php index a430a7fdc6..0bdc00da62 100644 --- a/tests/unit/Event/EventTest.php +++ b/tests/unit/Event/EventTest.php @@ -6,10 +6,10 @@ use Appwrite\Event\Event; use Appwrite\URL\URL; use InvalidArgumentException; use PHPUnit\Framework\TestCase; -use Utopia\App; use Utopia\DSN\DSN; use Utopia\Queue; use Utopia\Queue\Client; +use Utopia\System\System; require_once __DIR__ . '/../../../app/init.php'; @@ -22,13 +22,13 @@ class EventTest extends TestCase { $fallbackForRedis = URL::unparse([ 'scheme' => 'redis', - 'host' => App::getEnv('_APP_REDIS_HOST', 'redis'), - 'port' => App::getEnv('_APP_REDIS_PORT', '6379'), - 'user' => App::getEnv('_APP_REDIS_USER', ''), - 'pass' => App::getEnv('_APP_REDIS_PASS', ''), + 'host' => System::getEnv('_APP_REDIS_HOST', 'redis'), + 'port' => System::getEnv('_APP_REDIS_PORT', '6379'), + 'user' => System::getEnv('_APP_REDIS_USER', ''), + 'pass' => System::getEnv('_APP_REDIS_PASS', ''), ]); - $dsn = App::getEnv('_APP_CONNECTIONS_QUEUE', $fallbackForRedis); + $dsn = System::getEnv('_APP_CONNECTIONS_QUEUE', $fallbackForRedis); $dsn = explode('=', $dsn); $dsn = $dsn[0] ?? ''; $dsn = new DSN($dsn); diff --git a/tests/unit/Usage/StatsTest.php b/tests/unit/Usage/StatsTest.php index c564b31c92..534d5beda0 100644 --- a/tests/unit/Usage/StatsTest.php +++ b/tests/unit/Usage/StatsTest.php @@ -4,11 +4,11 @@ namespace Tests\Unit\Usage; use Appwrite\URL\URL as AppwriteURL; use PHPUnit\Framework\TestCase; -use Utopia\App; use Utopia\DSN\DSN; use Utopia\Queue; use Utopia\Queue\Client; use Utopia\Queue\Connection; +use Utopia\System\System; class StatsTest extends TestCase { @@ -19,12 +19,12 @@ class StatsTest extends TestCase public function setUp(): void { - $env = App::getEnv('_APP_CONNECTIONS_QUEUE', AppwriteURL::unparse([ + $env = System::getEnv('_APP_CONNECTIONS_QUEUE', AppwriteURL::unparse([ 'scheme' => 'redis', - 'host' => App::getEnv('_APP_REDIS_HOST', 'redis'), - 'port' => App::getEnv('_APP_REDIS_PORT', '6379'), - 'user' => App::getEnv('_APP_REDIS_USER', ''), - 'pass' => App::getEnv('_APP_REDIS_PASS', ''), + 'host' => System::getEnv('_APP_REDIS_HOST', 'redis'), + 'port' => System::getEnv('_APP_REDIS_PORT', '6379'), + 'user' => System::getEnv('_APP_REDIS_USER', ''), + 'pass' => System::getEnv('_APP_REDIS_PASS', ''), ])); $dsn = explode('=', $env);