chore: Support multiple term types

This commit is contained in:
Maksim Eltyshev
2026-02-10 22:53:22 +01:00
parent 1d0b3e9af8
commit 0db1a5cf0e
10 changed files with 96 additions and 26 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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');

View File

@@ -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',
};

View File

@@ -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**

View File

@@ -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**