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,
|
reason: string = null,
|
||||||
muteOptions: MuteOptions = {},
|
muteOptions: MuteOptions = {},
|
||||||
): Promise<MuteResult> {
|
): Promise<MuteResult> {
|
||||||
|
const lock = await this.locks.acquire(`mute-${userId}`);
|
||||||
|
|
||||||
const muteRole = this.getConfig().mute_role;
|
const muteRole = this.getConfig().mute_role;
|
||||||
if (!muteRole) {
|
if (!muteRole) {
|
||||||
|
lock.unlock();
|
||||||
this.throwRecoverablePluginError(ERRORS.NO_MUTE_ROLE_IN_CONFIG);
|
this.throwRecoverablePluginError(ERRORS.NO_MUTE_ROLE_IN_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,6 +290,8 @@ export class MutesPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lock.unlock();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
case: theCase,
|
case: theCase,
|
||||||
notifyResult,
|
notifyResult,
|
||||||
|
|
Loading…
Add table
Reference in a new issue