Move thread parser dispatching into _client.py

I know, it's not pretty, but it doesn't belong in _graphql.py either
This commit is contained in:
Mads Marquart
2019-03-10 19:39:22 +01:00
parent e579e0c767
commit 1f961b2ca7
3 changed files with 12 additions and 17 deletions

View File

@@ -1158,9 +1158,18 @@ class Client(object):
)
)
return [
graphql_to_thread(node) for node in j["viewer"]["message_threads"]["nodes"]
]
rtn = []
for node in j["viewer"]["message_threads"]["nodes"]:
_type = node.get("thread_type")
if _type == "GROUP":
rtn.append(Group._from_graphql(node))
elif _type == "ONE_TO_ONE":
rtn.append(User._from_thread_fetch(node))
else:
raise FBchatException(
"Unknown thread type: {}, with data: {}".format(_type, node)
)
return rtn
def fetchUnread(self):
"""