Added anonymizeChannelName configuration option.

cshd
funkyhippo 2020-09-21 13:44:07 -07:00 committed by Miikka
parent 88c2fc2e83
commit 3af5a67c1b
3 changed files with 16 additions and 1 deletions

View File

@ -313,6 +313,10 @@ URL to use for attachment and log links. Defaults to `http://IP:PORT`.
**Default:** `off`
If enabled, mod replies will use their nicknames (on the inbox server) instead of their usernames
#### anonymizeChannelName
**Default:** `off`
If enabled, channel names will be the user's name and discriminator salted with the current time, then hashed to protect the user's privacy
## Advanced options
#### extraIntents

View File

@ -124,6 +124,10 @@
"$ref": "#/definitions/customBoolean",
"default": false
},
"anonymizeChannelName": {
"$ref": "#/definitions/customBoolean",
"default": false
},
"ignoreAccidentalThreads": {
"$ref": "#/definitions/customBoolean",
"default": false

View File

@ -4,6 +4,7 @@ const transliterate = require("transliteration");
const moment = require("moment");
const uuid = require("uuid");
const humanizeDuration = require("humanize-duration");
const crypto = require("crypto");
const bot = require("../bot");
const knex = require("../knex");
@ -135,7 +136,13 @@ async function createNewThreadForUser(user, opts = {}) {
if (cleanName === "") cleanName = "unknown";
cleanName = cleanName.slice(0, 95); // Make sure the discrim fits
const channelName = `${cleanName}-${user.discriminator}`;
let temporalName = `${cleanName}-${user.discriminator}`;
if (config.anonymizeChannelName) {
temporalName = crypto.createHash("md5").update(temporalName + new Date()).digest("hex").slice(0, 12);
}
const channelName = temporalName;
console.log(`[NOTE] Creating new thread channel ${channelName}`);