Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check the banReason before banning a user. #1551

Merged
merged 6 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/1551.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix an issue where synchronising a ban list would cause all users to get banned.
8 changes: 5 additions & 3 deletions src/irc/ClientPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export class ClientPool {
throw Error("Cannot create bridged client - user is excluded from bridging");
}
const banReason = this.ircBridge.matrixBanSyncer?.isUserBanned(matrixUser);
if (banReason) {
if (typeof banReason === "string") {
throw Error(`Cannot create bridged client - user is banned (${banReason})`);
}
}
Expand Down Expand Up @@ -558,8 +558,10 @@ export class ClientPool {
for (const [userId, client] of set.userIds.entries()) {
try {
const banReason = this.ircBridge.matrixBanSyncer?.isUserBanned(userId);
log.warn(`Killing ${userId} client connection due - user is banned (${banReason})`);
await client.kill('User was banned');
if (typeof banReason === "string") {
log.warn(`Killing ${userId} client connection due - user is banned (${banReason})`);
await client.kill('User was banned');
}
}
catch (ex) {
log.warn(`Failed to kill connection for ${userId}`);
Expand Down