mirror of
https://github.com/janderedev/automod.git
synced 2024-12-22 10:45:27 +00:00
add disallow_opt_out configuration option
This commit is contained in:
parent
603d922a33
commit
6d5b91d07f
|
@ -30,6 +30,7 @@ function getDBUrl() {
|
|||
}
|
||||
|
||||
async function databaseMigrations() {
|
||||
// prettier-ignore
|
||||
async function setIndexes(collection: ICollection, toIndex: string[]) {
|
||||
try {
|
||||
const indexes = await collection.indexes();
|
||||
|
@ -44,21 +45,32 @@ async function databaseMigrations() {
|
|||
}
|
||||
}
|
||||
|
||||
await setIndexes(dbs.BRIDGE_CONFIG, [ 'discord', 'revolt' ]);
|
||||
await setIndexes(dbs.BRIDGE_REQUESTS, [ 'id', 'revolt' ]);
|
||||
await setIndexes(dbs.BRIDGE_CONFIG, ["discord", "revolt"]);
|
||||
await setIndexes(dbs.BRIDGE_REQUESTS, ["id", "revolt"]);
|
||||
await setIndexes(dbs.BRIDGED_MESSAGES, [
|
||||
"discord.messageId",
|
||||
"revolt.messageId",
|
||||
"revolt.nonce",
|
||||
"origin",
|
||||
]);
|
||||
await setIndexes(dbs.INFRACTIONS, [ 'createdBy', 'user', 'server' ]);
|
||||
await setIndexes(dbs.PENDING_LOGINS, [ 'code', 'user' ]);
|
||||
await setIndexes(dbs.SERVERS, [ 'id' ]);
|
||||
await setIndexes(dbs.SESSIONS, [ 'user', 'token' ]);
|
||||
await setIndexes(dbs.TEMPBANS, [ 'id', 'until' ]);
|
||||
await setIndexes(dbs.USERS, [ 'id' ]);
|
||||
await setIndexes(dbs.VOTEKICKS, [ 'id', 'server', 'target' ]);
|
||||
await setIndexes(dbs.INFRACTIONS, ["createdBy", "user", "server"]);
|
||||
await setIndexes(dbs.PENDING_LOGINS, ["code", "user"]);
|
||||
await setIndexes(dbs.SERVERS, ["id"]);
|
||||
await setIndexes(dbs.SESSIONS, ["user", "token"]);
|
||||
await setIndexes(dbs.TEMPBANS, ["id", "until"]);
|
||||
await setIndexes(dbs.USERS, ["id"]);
|
||||
await setIndexes(dbs.VOTEKICKS, ["id", "server", "target"]);
|
||||
|
||||
// Migrate `disallowIfOptedOut` to `config.disallow_opt_out` on bridge_config
|
||||
await dbs.BRIDGE_CONFIG.update(
|
||||
{
|
||||
disallowIfOptedOut: { $exists: true },
|
||||
"config.disallow_opt_out": { $exists: false },
|
||||
},
|
||||
{
|
||||
$rename: { disallowIfOptedOut: "config.disallow_opt_out" },
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export { databaseMigrations }
|
||||
|
|
|
@ -101,7 +101,11 @@ client.on('messageCreate', async message => {
|
|||
}
|
||||
}
|
||||
|
||||
if (bridgeCfg.disallowIfOptedOut && userConfig?.optOut && message.deletable) {
|
||||
if (
|
||||
bridgeCfg.config?.disallow_opt_out &&
|
||||
userConfig?.optOut &&
|
||||
message.deletable
|
||||
) {
|
||||
await message.delete();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@ export const CONFIG_KEYS = {
|
|||
description:
|
||||
"If enabled, nicknames and avatar overrides will be bridged.",
|
||||
},
|
||||
// disallow_opt_out: {
|
||||
// friendlyName: "Disallow users who opted out of message bridging",
|
||||
// description:
|
||||
// "If enabled, all messages by users who opted out of their messages being bridged (`/bridge opt_out`) will be deleted. " +
|
||||
// "You should enable this if your Revolt server is bridged to a mostly unmoderated Discord server.",
|
||||
// },
|
||||
disallow_opt_out: {
|
||||
friendlyName: "Disallow users who opted out of message bridging",
|
||||
description:
|
||||
"If enabled, all messages by users who opted out of their messages being bridged (`/bridge opt_out`) will be deleted. " +
|
||||
"You should enable this if your Revolt server is bridged to a mostly unmoderated Discord server.",
|
||||
},
|
||||
};
|
||||
|
|
|
@ -15,6 +15,9 @@ export default class {
|
|||
|
||||
config?: { [key in keyof typeof CONFIG_KEYS]: boolean | undefined };
|
||||
|
||||
// If true, messages by users who have opted out of bridging will be deleted.
|
||||
/**
|
||||
* @deprecated Use config.disallow_opt_out
|
||||
* Will be automatically removed by database migrations
|
||||
*/
|
||||
disallowIfOptedOut?: boolean;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue