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

Conversation

Half-Shot
Copy link
Contributor

@Half-Shot Half-Shot commented Mar 28, 2022

This was causing users to get banned erroneously

@Half-Shot Half-Shot requested a review from a team March 28, 2022 12:50
changelog.d/1551.bugfix Outdated Show resolved Hide resolved
@@ -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 (banReason) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer some test that also kills on empty string.
While the matrixBanSyncer will default empty strings to "No reason given", only the return value false states that the user isn't banned.

Suggested change
if (banReason) {
if (typeof banReason === 'string') {

@Half-Shot
Copy link
Contributor Author

(You were right about typeof, checking for false would have banned everyone)

@Half-Shot Half-Shot merged commit 5717720 into develop Mar 30, 2022
@Half-Shot Half-Shot deleted the hs/fix-overzealus-bans branch March 30, 2022 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants