A Node.js script to automatically redact (delete) old messages from Matrix rooms and purge them from the server database.
- Redacts messages older than a specified number of days
- Supports both regular and encrypted rooms
- Handles rate limiting gracefully with exponential backoff
- Dry-run mode by default for safety
- Purges old messages from server database after redaction
- Debug mode for troubleshooting
- Clone this repository
- Install dependencies:
npm install
Create a .env file with the following variables:
HOMESERVER_URL=https://your-matrix-server.com
ADMIN_TOKEN=your_admin_access_token
ROOM_ID=!your-room-id:server.com
REDACT_DAYS=7
PURGE_DAYS=30
LIMIT=100
RATE_LIMIT_DELAY=500HOMESERVER_URL: Your Matrix homeserver URLADMIN_TOKEN: Admin access token (or user token for someone in the room)ROOM_ID: The room ID to clean up (format:!localpart:domain.tld)REDACT_DAYS: Days after which messages should be redacted (default: 7)PURGE_DAYS: Days after which messages should be purged from database (default: 30)LIMIT: Number of messages to fetch per API call (default: 100)RATE_LIMIT_DELAY: Delay between requests in milliseconds (default: 500)
node wiper.jsShows what would be deleted without actually doing it.
node wiper.js --commitnode wiper.js --days 30 --commitnode wiper.js --debug --commit- Fetch Messages: Retrieves messages from the specified room using the Matrix Client API
- Filter by Age: Identifies messages older than the specified number of days
- Redact Messages: Sends redaction events to mark messages as deleted
- Purge History: Uses Synapse admin API to permanently remove old messages from database
The script handles Matrix server rate limits automatically. To reduce rate limiting:
- Increase
RATE_LIMIT_DELAYin your.envfile - Configure your Synapse server for higher admin redaction limits in
homeserver.yaml:
rc_admin_redaction:
per_second: 10000
burst_count: 100000- Node.js
- Access to a Matrix homeserver with admin privileges
- Admin access token or user token for someone in the target room
- Dry-run mode by default (requires
--committo actually delete) - Validates environment variables and configuration
- Validates room ID format
- Checks admin token format
- Handles network errors with retry logic
- Regular messages (
m.room.message) - Encrypted messages (
m.room.encrypted)
Developed by Alan P. Laudicina from Opreto
Contributions are welcome! Open a PR.
MIT License