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

searchForUsers('<name>') not working as Expected #365

Closed
kaushalvivek opened this issue Dec 7, 2018 · 7 comments
Closed

searchForUsers('<name>') not working as Expected #365

kaushalvivek opened this issue Dec 7, 2018 · 7 comments

Comments

@kaushalvivek
Copy link
Contributor

Description of the problem

searchForUsers() should return a list of objects that match the name entered as the query, but it's returning only one response (presumably, the first response.)

Code to reproduce

users = client.searchForUsers('Jane')
for user in users:
    print("User's ID: {}".format(user.uid))

This should print the user ID of all chats with 'Jane' in their name, but it would return just one option.

Environment information

  • Python 3.7.0
  • fbchat 1.4.1
@kapi2289
Copy link
Contributor

kapi2289 commented Dec 7, 2018

Maybe you have only one Jane on your Facebook friends list?

@kaushalvivek
Copy link
Contributor Author

kaushalvivek commented Dec 7, 2018

Oh, no, I checked with multiple search terms.
Terms that should definitely have returned multiple results.
Even single alphabets are returning one object.
Queries like:

users = client.searchForUsers('A')

@kaushalvivek
Copy link
Contributor Author

https://github.com/carpedm20/fbchat/blob/89a277c3541e5b5a5a1b4c1dd6aaf9025ce43707/fbchat/client.py#L505

Found the issue, the limit is set as 1 here. I suppose that was done for a reason?
5 or 10 would be a better limit logically, I'd say.

kaushalvivek added a commit to kaushalvivek/fbchat that referenced this issue Dec 7, 2018
@madsmtm
Copy link
Member

madsmtm commented Dec 7, 2018

I looked at the history, but I couldn't find an explicit reason for setting the limit so low, maybe it was just to be pragmatic, and encourage people to set their own limits?

@kaushalvivek
Copy link
Contributor Author

It does compromise on usability in its present implementation though, maybe a limit of 3 or 5 would be a better balance between usability and a pragmatic approach?

@madsmtm
Copy link
Member

madsmtm commented Dec 9, 2018

Well, you've set it at 10 in #366, which is definitively a better choice for searchForThreads, and I don't think the limits should differ between the searchForX methods.

I'd still think that the overly pragmatic choice is better. I'd rather add explicit documentation about this fact, than set an arbitary limit. You can see an example of this in the asks documentation

But then again, searchForMessageIDs, searchForMessages and search limits of 5, and fetchThreadMessages and fetchThreadList have limits of 20, so maybe it's not a big deal.

I guess I'll approve this change, and merge the PR when it's updated 👍

@kaushalvivek
Copy link
Contributor Author

Hi @madsmtm , I've updated searchForX methods for Users, Pages, Groups and Threads and set the limit to 10. Checkout #366.

madsmtm added a commit that referenced this issue Dec 10, 2018
@madsmtm madsmtm closed this as completed Dec 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants