fbchat-dev / fbchat

Facebook Chat (Messenger) for Python
https://fbchat.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.19k stars 412 forks source link

KeyError in fetchThreadList() #335

Closed 2FWAH closed 6 years ago

2FWAH commented 6 years ago

Description of the problem

Fetching threads using fetchThreadList() failed with KeyError.

Method works if no group threads are in ThreadLocation (given as parameter, default to INBOX) but fails if there is at least one group thread (may be related if the user is admin or not of the thread conversation).

Code to reproduce

Try to fetch threads using fetchThreadList().

Traceback

>>> client.fetchThreadList()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/fb/fbchat/fbchat/client.py", line 895, in fetchThreadList
    return [graphql_to_thread(node) for node in j['viewer']['message_threads']['nodes']]
  File "/home/fb/fbchat/fbchat/client.py", line 895, in <listcomp>
    return [graphql_to_thread(node) for node in j['viewer']['message_threads']['nodes']]
  File "/home/fb/fbchat/fbchat/graphql.py", line 246, in graphql_to_thread
    return graphql_to_group(thread)
  File "/home/fb/fbchat/fbchat/graphql.py", line 306, in graphql_to_group
    approval_requests = set(node["requester"]['id'] for node in group['group_approval_queue']['nodes']),
KeyError: 'group_approval_queue'

Environment information

Looks related to the recent support for rooms.

kapi2289 commented 6 years ago

Ohh, that's my fault, I'll fix this!

madsmtm commented 6 years ago

Closed by #340, I'll release a new version later today ;)