From c8c73eaa468d00af64f8c2083ac0ebf593abe2bb Mon Sep 17 00:00:00 2001 From: Jannik Streek Date: Thu, 11 Apr 2024 12:13:15 +0200 Subject: [PATCH] anonymize author names when no pads present --- .env.default | 2 +- docker-compose.yml | 4 ++-- src/node/db/AuthorManager.ts | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.env.default b/.env.default index b78b5599aa1..74ac097ee72 100644 --- a/.env.default +++ b/.env.default @@ -11,7 +11,7 @@ DOCKER_COMPOSE_APP_DEV_PORT_TARGET=9001 # The env var DEFAULT_PAD_TEXT seems to be mandatory in the latest version of etherpad. DOCKER_COMPOSE_APP_DEV_ENV_DEFAULT_PAD_TEXT="Welcome to etherpad" -DOCKER_COMPOSE_APP_DEV_ADMIN_PASSWORD= +DOCKER_COMPOSE_APP_DEV_ENV_ADMIN_PASSWORD= DOCKER_COMPOSE_POSTGRES_DEV_ENV_POSTGRES_DATABASE=db DOCKER_COMPOSE_POSTGRES_DEV_ENV_POSTGRES_PASSWORD=etherpad-lite-password diff --git a/docker-compose.yml b/docker-compose.yml index a83449e8a46..3c4042cad06 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -36,7 +36,7 @@ services: environment: # change from development to production if needed NODE_ENV: development - ADMIN_PASSWORD: ${DOCKER_COMPOSE_APP_DEV_ADMIN_PASSWORD} + ADMIN_PASSWORD: ${DOCKER_COMPOSE_APP_DEV_ENV_ADMIN_PASSWORD} DB_CHARSET: ${DOCKER_COMPOSE_APP_DEV_ENV_DB_CHARSET:-utf8mb4} DB_HOST: postgres DB_NAME: ${DOCKER_COMPOSE_POSTGRES_DEV_ENV_POSTGRES_DATABASE:?} @@ -67,7 +67,7 @@ services: # Exposing the port is not needed unless you want to access this database instance from the host. # Be careful when other postgres docker container are running on the same port # ports: - # - "5432:5432" + # - "5432:5432" volumes: - postgres_data:/var/lib/postgresql/data/pgdata diff --git a/src/node/db/AuthorManager.ts b/src/node/db/AuthorManager.ts index 2f4e7d751af..d8ff44d410f 100644 --- a/src/node/db/AuthorManager.ts +++ b/src/node/db/AuthorManager.ts @@ -312,4 +312,10 @@ exports.removePad = async (authorID: string, padID: string) => { delete author.padIDs[padID]; await db.set(`globalAuthor:${authorID}`, author); } + + const author_reloaded = await db.get(`globalAuthor:${authorID}`); + if (author_reloaded.padIDs == null || Object.keys(author_reloaded.padIDs).length === 0) { + author_reloaded.name = "Guest" + await db.set(`globalAuthor:${authorID}`, author_reloaded); + } };