3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-18 15:45:03 +00:00

Mutes: Add locks to prevent multiple simultaneous attempts to mute a user

This commit is contained in:
Dragory 2020-06-14 23:59:51 +03:00
parent d8d5665e93
commit a0af3f0764

View file

@ -150,8 +150,11 @@ export class MutesPlugin extends ZeppelinPlugin<TConfigSchema> {
reason: string = null,
muteOptions: MuteOptions = {},
): Promise<MuteResult> {
const lock = await this.locks.acquire(`mute-${userId}`);
const muteRole = this.getConfig().mute_role;
if (!muteRole) {
lock.unlock();
this.throwRecoverablePluginError(ERRORS.NO_MUTE_ROLE_IN_CONFIG);
}
@ -287,6 +290,8 @@ export class MutesPlugin extends ZeppelinPlugin<TConfigSchema> {
});
}
lock.unlock();
return {
case: theCase,
notifyResult,