Skip to content

Commit

Permalink
anonymize author names when no pads present
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikStreek committed Apr 11, 2024
1 parent fc84b17 commit c8c73ea
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .env.default
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}
Expand Down Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions src/node/db/AuthorManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

0 comments on commit c8c73ea

Please sign in to comment.