Fix several role race conditions
This commit is contained in:
parent
baf13a9ffa
commit
5d579446c5
2 changed files with 7 additions and 0 deletions
|
@ -64,11 +64,15 @@ export const AddRolesAction = automodAction({
|
|||
return;
|
||||
}
|
||||
|
||||
const memberRolesLock = await pluginData.locks.acquire(`member-roles-${member.id}`);
|
||||
|
||||
const rolesArr = Array.from(memberRoles.values());
|
||||
await member.edit({
|
||||
roles: rolesArr,
|
||||
});
|
||||
member.roles = rolesArr; // Make sure we know of the new roles internally as well
|
||||
|
||||
memberRolesLock.unlock();
|
||||
}),
|
||||
);
|
||||
},
|
||||
|
|
|
@ -12,7 +12,10 @@ export const ReapplyActiveMuteOnJoinEvt = eventListener<MutesPluginType>()(
|
|||
const mute = await pluginData.state.mutes.findExistingMuteForUserId(member.id);
|
||||
if (mute) {
|
||||
const muteRole = pluginData.config.get().mute_role;
|
||||
|
||||
const memberRolesLock = await pluginData.locks.acquire(`member-roles-${member.id}`);
|
||||
await member.addRole(muteRole);
|
||||
memberRolesLock.unlock();
|
||||
|
||||
pluginData.state.serverLogs.log(LogType.MEMBER_MUTE_REJOIN, {
|
||||
member: stripObjectToScalars(member, ["user", "roles"]),
|
||||
|
|
Loading…
Add table
Reference in a new issue