mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
Mutes: Add locks to prevent multiple simultaneous attempts to mute a user
This commit is contained in:
parent
00aeab6cdd
commit
b4e034e3d8
1 changed files with 5 additions and 0 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue