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

Incorrect handler inside function "isUserOn" #37

Open
ostafen opened this issue Dec 19, 2021 · 0 comments
Open

Incorrect handler inside function "isUserOn" #37

ostafen opened this issue Dec 19, 2021 · 0 comments

Comments

@ostafen
Copy link

ostafen commented Dec 19, 2021

Hi, while working with your library, i discovered a potential bug inside function isUserOn of the Client class.

@override
  Future<bool> isUserOn(String name,
    ...
     var handler = (WhoisEvent event) {
      if (event.nickname == nickname) {
        if (!completer.isCompleted) {
          completer.complete(event.away);
        }
      }
   };
    ...

I think the handler is intercepting the wrong event, it should be IsOnEvent, in fact the call always returns false. Moreover, the check "if(event.nickname == nickname)" is incorrect, because nickname represents the current nickname of our client user, not the nickname of the user we are trying to query (whose nickname is on the "name" parameter of the function).

I fixed the handler like so:

var handler = (IsOnEvent event) {
      if (!completer.isCompleted) {
        completer.complete(event.users.contains(name));
      }
    };

Now, it works. Is my reasoning correct or there is something escaping to me? In the first case, I can pull request my fix.``

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

No branches or pull requests

1 participant