Skip to content

Commit

Permalink
Punishments: Fix Punishments.roomUnblacklistAll (#2829)
Browse files Browse the repository at this point in the history
- should use Punishments.saveRoomPunishments() instead of the global version at the end of the Punishments.roomUnblacklistAll
- add an extra ignoreWrite argument to be passed to ``roomUnblacklist`` => ``roomUnpunish``.  That way, it doesn't try to write to the tsv file for each loop of the forEach called in roomUnblacklistAll
  • Loading branch information
Charlie Kobayashi authored and Zarel committed Oct 10, 2016
1 parent f81a4d2 commit 3aa3936
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions punishments.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ Punishments.roomPunishName = function (room, userid, punishment) {
* @param {string} id
* @param {string} punishType
*/
Punishments.roomUnpunish = function (room, id, punishType) {
Punishments.roomUnpunish = function (room, id, punishType, ignoreWrite) {
id = toId(id);
let punishment = Punishments.roomUserids.nestedGet(room, id);
if (punishment) {
Expand Down Expand Up @@ -505,7 +505,7 @@ Punishments.roomUnpunish = function (room, id, punishType) {
}
});
}
if (success) {
if (success && !ignoreWrite) {
Punishments.saveRoomPunishments();
}
return success;
Expand Down Expand Up @@ -720,13 +720,13 @@ Punishments.roomUnban = function (room, userid) {
return Punishments.roomUnpunish(room, userid, 'ROOMBAN');
};

Punishments.roomUnblacklist = function (room, userid) {
Punishments.roomUnblacklist = function (room, userid, ignoreWrite) {
const user = Users(userid);
if (user) {
let punishment = Punishments.isRoomBanned(user, room.id);
if (punishment) userid = punishment[1];
}
return Punishments.roomUnpunish(room, userid, 'BLACKLIST');
return Punishments.roomUnpunish(room, userid, 'BLACKLIST', ignoreWrite);
};

Punishments.roomUnblacklistAll = function (room) {
Expand All @@ -737,12 +737,12 @@ Punishments.roomUnblacklistAll = function (room) {

roombans.forEach((punishment, userid) => {
if (punishment[0] === 'BLACKLIST') {
Punishments.roomUnblacklist(room, userid);
Punishments.roomUnblacklist(room, userid, true);
unblacklisted.push(userid);
}
});
if (unblacklisted.length === 0) return false;
Punishments.savePunishments();
Punishments.saveRoomPunishments();
return unblacklisted;
};

Expand Down

0 comments on commit 3aa3936

Please sign in to comment.