quarantine_users_and_orgs.pl - Quarantine (and later restore or purge) a list of users and orgs, e.g. spam accounts
# 1. Quarantine: dry run by default, add --execute to apply
quarantine_users_and_orgs.pl --batch spam-bot --users userids.txt --orgs orgids.txt [--brevo-csv emails.csv] [--execute]
# 2a. Undo a batch
quarantine_users_and_orgs.pl --restore <batch dir> [--execute]
# 2b. Or, some time later, delete the batch for good
quarantine_users_and_orgs.pl --purge <batch dir> [--execute]
Input files contain one user id or org id per line.
Quarantine:
- users: the Keycloak account is disabled (the user cannot log in anymore), and the user .sto file is moved to the batch directory - orgs: the org .sto file is moved to the batch directory, and the org is removed from the orgs MongoDB collection
Users and orgs are skipped (unless --force is used) if they look like real users or orgs: moderators and admins, users or orgs linked to the CRM, accepted orgs, users that are members of orgs that are not in the list, orgs that have members that are not in the list, users who edited products, orgs that have products. The products checks are done in the MongoDB database of the current flavor, and orgs are removed from the orgs collection of the current flavor. As users and orgs files are shared between the public and producers platforms, run the script for users on the public platform, and for orgs on the producers platform.
The batch directory is created in the quarantine/ directory, next to the users/ directory. Every action is recorded in its manifest.tsv file, which is used by --restore and --purge.
Restore moves the files back and re-enables the Keycloak accounts.
Purge deletes the Keycloak accounts (which triggers the usual user deletion job) and the quarantined files. Until it is done, the email addresses of quarantined users cannot be used to create new accounts.