Update graphql.py
This commit is contained in:
committed by
GitHub
parent
778e827277
commit
0e0845914b
@@ -5,7 +5,6 @@ import json
|
|||||||
import re
|
import re
|
||||||
from .models import *
|
from .models import *
|
||||||
from .utils import *
|
from .utils import *
|
||||||
import ast
|
|
||||||
|
|
||||||
# Shameless copy from https://stackoverflow.com/a/8730674
|
# Shameless copy from https://stackoverflow.com/a/8730674
|
||||||
FLAGS = re.VERBOSE | re.MULTILINE | re.DOTALL
|
FLAGS = re.VERBOSE | re.MULTILINE | re.DOTALL
|
||||||
@@ -173,9 +172,9 @@ def graphql_to_plan(a):
|
|||||||
)
|
)
|
||||||
rtn.uid = a.get('event_id')
|
rtn.uid = a.get('event_id')
|
||||||
rtn.author_id = a.get('event_creator_id')
|
rtn.author_id = a.get('event_creator_id')
|
||||||
guests = ast.literal_eval(a.get('guest_state_list'))
|
guests = json.loads(a.get('guest_state_list'))
|
||||||
else:
|
else:
|
||||||
rtn = Event(
|
rtn = Plan(
|
||||||
time=a.get('time'),
|
time=a.get('time'),
|
||||||
title=a.get('event_title'),
|
title=a.get('event_title'),
|
||||||
location=a.get('location_name')
|
location=a.get('location_name')
|
||||||
@@ -215,7 +214,7 @@ def graphql_to_user(user):
|
|||||||
if user.get('profile_picture') is None:
|
if user.get('profile_picture') is None:
|
||||||
user['profile_picture'] = {}
|
user['profile_picture'] = {}
|
||||||
c_info = get_customization_info(user)
|
c_info = get_customization_info(user)
|
||||||
plan = graphql_to_plan(user['event_reminders']['nodes'][0]) if user.get('event_reminders') else []
|
plan = graphql_to_plan(user['event_reminders']['nodes'][0]) if user.get('event_reminders') else None
|
||||||
return User(
|
return User(
|
||||||
user['id'],
|
user['id'],
|
||||||
url=user.get('url'),
|
url=user.get('url'),
|
||||||
@@ -253,7 +252,7 @@ def graphql_to_thread(thread):
|
|||||||
else:
|
else:
|
||||||
last_name = user.get('name').split(first_name, 1).pop().strip()
|
last_name = user.get('name').split(first_name, 1).pop().strip()
|
||||||
|
|
||||||
plan = graphql_to_plan(thread['event_reminders']['nodes'][0]) if thread.get('event_reminders') else []
|
plan = graphql_to_plan(thread['event_reminders']['nodes'][0]) if thread.get('event_reminders') else None
|
||||||
|
|
||||||
return User(
|
return User(
|
||||||
user['id'],
|
user['id'],
|
||||||
@@ -283,7 +282,7 @@ def graphql_to_group(group):
|
|||||||
last_message_timestamp = None
|
last_message_timestamp = None
|
||||||
if 'last_message' in group:
|
if 'last_message' in group:
|
||||||
last_message_timestamp = group['last_message']['nodes'][0]['timestamp_precise']
|
last_message_timestamp = group['last_message']['nodes'][0]['timestamp_precise']
|
||||||
plan = graphql_to_plan(group['event_reminders']['nodes'][0]) if group.get('event_reminders') else []
|
plan = graphql_to_plan(group['event_reminders']['nodes'][0]) if group.get('event_reminders') else None
|
||||||
return Group(
|
return Group(
|
||||||
group['thread_key']['thread_fbid'],
|
group['thread_key']['thread_fbid'],
|
||||||
participants=set([node['messaging_actor']['id'] for node in group['all_participants']['nodes']]),
|
participants=set([node['messaging_actor']['id'] for node in group['all_participants']['nodes']]),
|
||||||
@@ -301,7 +300,7 @@ def graphql_to_room(room):
|
|||||||
if room.get('image') is None:
|
if room.get('image') is None:
|
||||||
room['image'] = {}
|
room['image'] = {}
|
||||||
c_info = get_customization_info(room)
|
c_info = get_customization_info(room)
|
||||||
plan = graphql_to_plan(room['event_reminders']['nodes'][0]) if room.get('event_reminders') else []
|
plan = graphql_to_plan(room['event_reminders']['nodes'][0]) if room.get('event_reminders') else None
|
||||||
return Room(
|
return Room(
|
||||||
room['thread_key']['thread_fbid'],
|
room['thread_key']['thread_fbid'],
|
||||||
participants=set([node['messaging_actor']['id'] for node in room['all_participants']['nodes']]),
|
participants=set([node['messaging_actor']['id'] for node in room['all_participants']['nodes']]),
|
||||||
@@ -324,7 +323,7 @@ def graphql_to_page(page):
|
|||||||
page['profile_picture'] = {}
|
page['profile_picture'] = {}
|
||||||
if page.get('city') is None:
|
if page.get('city') is None:
|
||||||
page['city'] = {}
|
page['city'] = {}
|
||||||
plan = graphql_to_plan(page['event_reminders']['nodes'][0]) if page.get('event_reminders') else []
|
plan = graphql_to_plan(page['event_reminders']['nodes'][0]) if page.get('event_reminders') else None
|
||||||
return Page(
|
return Page(
|
||||||
page['id'],
|
page['id'],
|
||||||
url=page.get('url'),
|
url=page.get('url'),
|
||||||
|
Reference in New Issue
Block a user