From 0db1a5cf0ec3b50e0a79360e27b620011ad52a63 Mon Sep 17 00:00:00 2001 From: Maksim Eltyshev Date: Tue, 10 Feb 2026 22:53:22 +0100 Subject: [PATCH] chore: Support multiple term types --- .github/workflows/build-and-test.yml | 2 +- docker-compose-dev.yml | 9 +++---- docker-compose.yml | 9 +++---- server/.env.sample | 9 +++---- server/api/hooks/terms/index.js | 5 +++- server/config/custom.js | 16 ++++++++----- server/terms/{ => cloud}/de-DE.md | 0 server/terms/{ => cloud}/en-US.md | 0 server/terms/self-hosted/de-DE.md | 36 ++++++++++++++++++++++++++++ server/terms/self-hosted/en-US.md | 36 ++++++++++++++++++++++++++++ 10 files changed, 96 insertions(+), 26 deletions(-) rename server/terms/{ => cloud}/de-DE.md (100%) rename server/terms/{ => cloud}/en-US.md (100%) create mode 100644 server/terms/self-hosted/de-DE.md create mode 100644 server/terms/self-hosted/en-US.md diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 68352539..a0536cb1 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -69,7 +69,7 @@ jobs: - name: Seed database with terms signature run: | - TERMS_SIGNATURE=$(sha256sum terms/en-US.md | awk '{print $1}') + TERMS_SIGNATURE=$(sha256sum terms/self-hosted/en-US.md | awk '{print $1}') PGPASSWORD=$POSTGRES_PASSWORD psql -h localhost -U $POSTGRES_USERNAME -d $POSTGRES_DATABASE -c "UPDATE user_account SET terms_signature = '$TERMS_SIGNATURE';" working-directory: ./server diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index 4bac776c..38bae88a 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -22,6 +22,9 @@ services: # - MAX_UPLOAD_FILE_SIZE= # - TOKEN_EXPIRES_IN=365 # In days + # - STORAGE_LIMIT= + # - ACTIVE_USERS_LIMIT= + # related: https://github.com/knex/knex/issues/2354 # As knex does not pass query parameters from the connection string, # we have to use environment variables in order to pass the desired values, e.g. @@ -40,12 +43,6 @@ services: # - DEFAULT_ADMIN_NAME=Demo Demo # - DEFAULT_ADMIN_USERNAME=demo - # - INTERNAL_ACCESS_TOKEN= - # - STORAGE_LIMIT= - # - ACTIVE_USERS_LIMIT= - # - CUSTOMER_PANEL_URL= - # - DEMO_MODE=true - # Set to true to show more detailed authentication error messages. # It should not be enabled without a rate limiter for security reasons. # - SHOW_DETAILED_AUTH_ERRORS=false diff --git a/docker-compose.yml b/docker-compose.yml index e58db239..3b449a43 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -31,6 +31,9 @@ services: # - MAX_UPLOAD_FILE_SIZE= # - TOKEN_EXPIRES_IN=365 # In days + # - STORAGE_LIMIT= + # - ACTIVE_USERS_LIMIT= + # related: https://github.com/knex/knex/issues/2354 # As knex does not pass query parameters from the connection string, # we have to use environment variables in order to pass the desired values, e.g. @@ -51,12 +54,6 @@ services: # - DEFAULT_ADMIN_NAME=Demo Demo # - DEFAULT_ADMIN_USERNAME=demo - # - INTERNAL_ACCESS_TOKEN= - # - STORAGE_LIMIT= - # - ACTIVE_USERS_LIMIT= - # - CUSTOMER_PANEL_URL= - # - DEMO_MODE=true - # Set to true to show more detailed authentication error messages. # It should not be enabled without a rate limiter for security reasons. # - SHOW_DETAILED_AUTH_ERRORS=false diff --git a/server/.env.sample b/server/.env.sample index 7f592343..afb50da0 100644 --- a/server/.env.sample +++ b/server/.env.sample @@ -13,6 +13,9 @@ SECRET_KEY=notsecretkey # MAX_UPLOAD_FILE_SIZE= # TOKEN_EXPIRES_IN=365 # In days +# STORAGE_LIMIT= +# ACTIVE_USERS_LIMIT= + # related: https://github.com/knex/knex/issues/2354 # As knex does not pass query parameters from the connection string, # we have to use environment variables in order to pass the desired values, e.g. @@ -31,12 +34,6 @@ SECRET_KEY=notsecretkey # DEFAULT_ADMIN_NAME=Demo Demo # DEFAULT_ADMIN_USERNAME=demo -# INTERNAL_ACCESS_TOKEN= -# STORAGE_LIMIT= -# ACTIVE_USERS_LIMIT= -# CUSTOMER_PANEL_URL= -# DEMO_MODE=true - # Set to true to show more detailed authentication error messages. # It should not be enabled without a rate limiter for security reasons. # SHOW_DETAILED_AUTH_ERRORS=false diff --git a/server/api/hooks/terms/index.js b/server/api/hooks/terms/index.js index ea448c0b..d163934d 100644 --- a/server/api/hooks/terms/index.js +++ b/server/api/hooks/terms/index.js @@ -18,7 +18,10 @@ const LANGUAGES = ['de-DE', 'en-US']; const DEFAULT_LANGUAGE = 'en-US'; const getContent = (language = DEFAULT_LANGUAGE) => - fsPromises.readFile(`${sails.config.appPath}/terms/${language}.md`, 'utf8'); + fsPromises.readFile( + `${sails.config.appPath}/terms/${sails.config.custom.termsType}/${language}.md`, + 'utf8', + ); const hashContent = (content) => crypto.createHash('sha256').update(content).digest('hex'); diff --git a/server/config/custom.js b/server/config/custom.js index 70aa38ae..1fe53151 100644 --- a/server/config/custom.js +++ b/server/config/custom.js @@ -47,6 +47,9 @@ module.exports.custom = { maxUploadFileSize: envToBytes(process.env.MAX_UPLOAD_FILE_SIZE), tokenExpiresIn: (parseInt(process.env.TOKEN_EXPIRES_IN, 10) || 365) * 24 * 60 * 60, + storageLimit: envToBytes(process.env.STORAGE_LIMIT), + activeUsersLimit: envToNumber(process.env.ACTIVE_USERS_LIMIT), + // Location to receive uploaded files in. Default (non-string value) is a Sails-specific location. uploadsTempPath: null, uploadsBasePath: path.join(sails.config.appPath, 'data'), @@ -59,12 +62,6 @@ module.exports.custom = { defaultAdminEmail: process.env.DEFAULT_ADMIN_EMAIL && process.env.DEFAULT_ADMIN_EMAIL.toLowerCase(), - internalAccessToken: process.env.INTERNAL_ACCESS_TOKEN, - storageLimit: envToBytes(process.env.STORAGE_LIMIT), - activeUsersLimit: envToNumber(process.env.ACTIVE_USERS_LIMIT), - customerPanelUrl: process.env.CUSTOMER_PANEL_URL, - demoMode: process.env.DEMO_MODE === 'true', - showDetailedAuthErrors: process.env.SHOW_DETAILED_AUTH_ERRORS === 'true', outgoingProxy: process.env.OUTGOING_PROXY, @@ -112,4 +109,11 @@ module.exports.custom = { smtpFrom: process.env.SMTP_FROM, gravatarBaseUrl: process.env.GRAVATAR_BASE_URL, + + /* Internal */ + + internalAccessToken: process.env.INTERNAL_ACCESS_TOKEN, + termsType: process.env.TERMS_TYPE || 'self-hosted', + customerPanelUrl: process.env.CUSTOMER_PANEL_URL, + demoMode: process.env.DEMO_MODE === 'true', }; diff --git a/server/terms/de-DE.md b/server/terms/cloud/de-DE.md similarity index 100% rename from server/terms/de-DE.md rename to server/terms/cloud/de-DE.md diff --git a/server/terms/en-US.md b/server/terms/cloud/en-US.md similarity index 100% rename from server/terms/en-US.md rename to server/terms/cloud/en-US.md diff --git a/server/terms/self-hosted/de-DE.md b/server/terms/self-hosted/de-DE.md new file mode 100644 index 00000000..a61f4206 --- /dev/null +++ b/server/terms/self-hosted/de-DE.md @@ -0,0 +1,36 @@ +# Beispiel-Nutzungsbedingungen +_Nicht rechtsverbindlich. Dies ist ein Platzhaltertext nur zu Testzwecken._ + +_Letzte Aktualisierung: 14. August 2025_ + +Willkommen bei ExampleCorp! Diese Beispiel-Nutzungsbedingungen ("Bedingungen") dienen ausschließlich der Demonstration und dem Testen in Ihrer Anwendung. Sie sind **rechtlich nicht gültig**. + +--- + +## 1. Einführung +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer eu mauris at est lacinia gravida. Nulla facilisi. + +## 2. Teilnahmeberechtigung +Benutzer müssen mindestens 18 Jahre alt sein, um diesen Dienst zu nutzen. Sed vulputate sapien eu varius efficitur. + +## 3. Pflichten der Benutzer +Durch die Nutzung der Plattform stimmen Sie zu: +- Genaue Informationen bereitzustellen. +- Keine illegalen Aktivitäten durchzuführen. +- Andere Benutzer zu respektieren. + +## 4. Verbotene Aktivitäten +Nicht erlaubt: +1. Andere belästigen. +2. Schadcode hochladen. +3. Sicherheitsmaßnahmen umgehen. + +## 5. Änderungen +Diese Beispiel-Bedingungen können jederzeit zu Testzwecken geändert werden. + +## 6. Kontakt +Bei Fragen zu diesen Beispiel-Bedingungen wenden Sie sich bitte an `placeholder@example.com`. + +--- + +**Ende des Beispiels** diff --git a/server/terms/self-hosted/en-US.md b/server/terms/self-hosted/en-US.md new file mode 100644 index 00000000..d61af4c1 --- /dev/null +++ b/server/terms/self-hosted/en-US.md @@ -0,0 +1,36 @@ +# Example Terms of Service +_Not legally binding. This is placeholder text for testing purposes only._ + +_Last updated: August 14, 2025_ + +Welcome to ExampleCorp! These Example Terms of Service ("Terms") are provided solely for demonstration and testing purposes in your application. They are **not legally valid**. + +--- + +## 1. Introduction +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer eu mauris at est lacinia gravida. Nulla facilisi. + +## 2. Eligibility +Users must be at least 18 years old to use this service. Sed vulputate sapien eu varius efficitur. + +## 3. User Responsibilities +By using the platform, you agree to: +- Provide accurate information. +- Avoid illegal activities. +- Respect other users. + +## 4. Prohibited Activities +Do not: +1. Harass others. +2. Upload harmful code. +3. Attempt to bypass security. + +## 5. Modifications +These example Terms may change at any time for testing purposes. + +## 6. Contact +For questions about these example Terms, please contact `placeholder@example.com`. + +--- + +**End of Example**