added rooms under thread_info
This commit is contained in:
@@ -513,6 +513,7 @@ class Client(object):
|
|||||||
|
|
||||||
return [graphql_to_page(node) for node in j[name]['pages']['nodes']]
|
return [graphql_to_page(node) for node in j[name]['pages']['nodes']]
|
||||||
|
|
||||||
|
# TODO intergrate Rooms
|
||||||
def searchForGroups(self, name, limit=1):
|
def searchForGroups(self, name, limit=1):
|
||||||
"""
|
"""
|
||||||
Find and get group thread by its name
|
Find and get group thread by its name
|
||||||
@@ -787,19 +788,29 @@ class Client(object):
|
|||||||
raise FBchatException('A participant had an unknown type {}: {}'.format(p['type'], p))
|
raise FBchatException('A participant had an unknown type {}: {}'.format(p['type'], p))
|
||||||
|
|
||||||
entries = []
|
entries = []
|
||||||
for k in j['payload']['threads']:
|
if 'threads' in j['payload']:
|
||||||
if k['thread_type'] == 1:
|
for k in j['payload']['threads']:
|
||||||
if k['other_user_fbid'] not in participants:
|
if k['thread_type'] == 1:
|
||||||
raise FBchatException('The thread {} was not in participants: {}'.format(k, j['payload']))
|
if k['other_user_fbid'] not in participants:
|
||||||
participants[k['other_user_fbid']].message_count = k['message_count']
|
raise FBchatException('The thread {} was not in participants: {}'.format(k, j['payload']))
|
||||||
entries.append(participants[k['other_user_fbid']])
|
participants[k['other_user_fbid']].message_count = k['message_count']
|
||||||
elif k['thread_type'] == 2:
|
entries.append(participants[k['other_user_fbid']])
|
||||||
entries.append(Group(k['thread_fbid'], participants=set([p.strip('fbid:') for p in k['participants']]), photo=k['image_src'], name=k['name'], message_count=k['message_count']))
|
elif k['thread_type'] == 2:
|
||||||
# TODO
|
entries.append(Group(k['thread_fbid'], participants=set([p.strip('fbid:') for p in k['participants']]), photo=k['image_src'], name=k['name'], message_count=k['message_count']))
|
||||||
elif k['thread_type'] == 4:
|
elif k['thread_type'] == 3:
|
||||||
entries.append(Group(k['thread_fbid'], participants=set([p.strip('fbid:') for p in k['participants']]), photo=k['image_src'], name=k['name'], message_count=k['message_count']))
|
entries.append(Room(
|
||||||
else:
|
k['thread_fbid'],
|
||||||
raise FBchatException('A thread had an unknown thread type: {}'.format(k))
|
participants = set(p.strip('fbid:') for p in k['participants']),
|
||||||
|
photo = k['image_src'],
|
||||||
|
name = k['name'],
|
||||||
|
message_count = k['message_count'],
|
||||||
|
admins = set(p.lstrip('fbid:') for p in k['admin_ids']),
|
||||||
|
approval_mode = k['approval_mode'],
|
||||||
|
approval_requests = set(p.lstrip('fbid:') for p in k['approval_queue_ids']),
|
||||||
|
join_link = k['joinable_mode']['link'],
|
||||||
|
))
|
||||||
|
else:
|
||||||
|
raise FBchatException('A thread had an unknown thread type: {}'.format(k))
|
||||||
|
|
||||||
return entries
|
return entries
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user