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:
@@ -1158,9 +1158,18 @@ class Client(object):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return [
|
rtn = []
|
||||||
graphql_to_thread(node) for node in j["viewer"]["message_threads"]["nodes"]
|
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):
|
def fetchUnread(self):
|
||||||
"""
|
"""
|
||||||
|
@@ -82,19 +82,6 @@ def graphql_to_message(message):
|
|||||||
return rtn
|
return rtn
|
||||||
|
|
||||||
|
|
||||||
def graphql_to_thread(thread):
|
|
||||||
if thread["thread_type"] == "GROUP":
|
|
||||||
return Group._from_graphql(thread)
|
|
||||||
elif thread["thread_type"] == "ONE_TO_ONE":
|
|
||||||
return User._from_thread_fetch(thread)
|
|
||||||
else:
|
|
||||||
raise FBchatException(
|
|
||||||
"Unknown thread type: {}, with data: {}".format(
|
|
||||||
thread.get("thread_type"), thread
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def graphql_queries_to_json(*queries):
|
def graphql_queries_to_json(*queries):
|
||||||
"""
|
"""
|
||||||
Queries should be a list of GraphQL objects
|
Queries should be a list of GraphQL objects
|
||||||
|
@@ -9,7 +9,6 @@ from ._graphql import (
|
|||||||
WHITESPACE,
|
WHITESPACE,
|
||||||
ConcatJSONDecoder,
|
ConcatJSONDecoder,
|
||||||
graphql_to_message,
|
graphql_to_message,
|
||||||
graphql_to_thread,
|
|
||||||
graphql_queries_to_json,
|
graphql_queries_to_json,
|
||||||
graphql_response_to_json,
|
graphql_response_to_json,
|
||||||
GraphQL,
|
GraphQL,
|
||||||
|
Reference in New Issue
Block a user