Changed return type for ONE_TO_ONE to User

This commit is contained in:
Marco Gavelli
2018-02-18 22:49:47 +01:00
parent c12dcd9263
commit 8268445f0b

View File

@@ -176,17 +176,26 @@ def graphql_to_thread(thread):
if thread['thread_type'] == 'GROUP': if thread['thread_type'] == 'GROUP':
return graphql_to_group(thread) return graphql_to_group(thread)
elif thread['thread_type'] == 'ONE_TO_ONE': elif thread['thread_type'] == 'ONE_TO_ONE':
if thread.get('image') is None: if thread.get('big_image_src') is None:
thread['image'] = {} thread['big_image_src'] = {}
c_info = get_customization_info(thread) c_info = get_customization_info(thread)
return Group( participants = [node['messaging_actor'] for node in thread['all_participants']['nodes']]
thread['thread_key']['other_user_id'], user = next(p for p in participants if p['id'] == thread['thread_key']['other_user_id'])
participants=set([node['messaging_actor']['id'] for node in thread['all_participants']['nodes']]),
nicknames=c_info.get('nicknames'), return User(
user['id'],
url=user.get('url'),
name=user.get('name'),
first_name=user.get('short_name'),
last_name=user.get('name').split(user.get('short_name'),1)[1].strip(),
is_friend=user.get('is_viewer_friend'),
gender=GENDERS.get(user.get('gender')),
affinity=user.get('affinity'),
nickname=c_info.get('nickname'),
color=c_info.get('color'), color=c_info.get('color'),
emoji=c_info.get('emoji'), emoji=c_info.get('emoji'),
photo=thread['image'].get('uri'), own_nickname=c_info.get('own_nickname'),
name=thread.get('name'), photo=user['big_image_src'].get('uri'),
message_count=thread.get('messages_count') message_count=thread.get('messages_count')
) )
else: else: