mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
Enforce unified lock names by using functions to generate lock keys (#165)
This commit is contained in:
parent
fcbb25b7ff
commit
c5d68650a3
18 changed files with 70 additions and 28 deletions
|
@ -9,6 +9,7 @@ import { getMissingPermissions } from "../../../utils/getMissingPermissions";
|
|||
import { canAssignRole } from "../../../utils/canAssignRole";
|
||||
import { missingPermissionError } from "../../../utils/missingPermissionError";
|
||||
import { ignoreRoleChange } from "../functions/ignoredRoleChanges";
|
||||
import { memberRolesLock } from "../../../utils/lockNameHelpers";
|
||||
|
||||
const p = Constants.Permissions;
|
||||
|
||||
|
@ -64,7 +65,7 @@ export const AddRolesAction = automodAction({
|
|||
return;
|
||||
}
|
||||
|
||||
const memberRolesLock = await pluginData.locks.acquire(`member-roles-${member.id}`);
|
||||
const memberRoleLock = await pluginData.locks.acquire(memberRolesLock(member));
|
||||
|
||||
const rolesArr = Array.from(memberRoles.values());
|
||||
await member.edit({
|
||||
|
@ -72,7 +73,7 @@ export const AddRolesAction = automodAction({
|
|||
});
|
||||
member.roles = rolesArr; // Make sure we know of the new roles internally as well
|
||||
|
||||
memberRolesLock.unlock();
|
||||
memberRoleLock.unlock();
|
||||
}),
|
||||
);
|
||||
},
|
||||
|
|
|
@ -10,6 +10,7 @@ import { missingPermissionError } from "../../../utils/missingPermissionError";
|
|||
import { canAssignRole } from "../../../utils/canAssignRole";
|
||||
import { Constants } from "eris";
|
||||
import { ignoreRoleChange } from "../functions/ignoredRoleChanges";
|
||||
import { memberRolesLock } from "../../../utils/lockNameHelpers";
|
||||
|
||||
const p = Constants.Permissions;
|
||||
|
||||
|
@ -66,7 +67,7 @@ export const RemoveRolesAction = automodAction({
|
|||
return;
|
||||
}
|
||||
|
||||
const memberRolesLock = await pluginData.locks.acquire(`member-roles-${member.id}`);
|
||||
const memberRoleLock = await pluginData.locks.acquire(memberRolesLock(member));
|
||||
|
||||
const rolesArr = Array.from(memberRoles.values());
|
||||
await member.edit({
|
||||
|
@ -74,7 +75,7 @@ export const RemoveRolesAction = automodAction({
|
|||
});
|
||||
member.roles = rolesArr; // Make sure we know of the new roles internally as well
|
||||
|
||||
memberRolesLock.unlock();
|
||||
memberRoleLock.unlock();
|
||||
}),
|
||||
);
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue