Move graphql_to_poll -> Poll._from_graphql
This commit is contained in:
@@ -2836,7 +2836,7 @@ class Client(object):
|
|||||||
thread_id, thread_type = getThreadIdAndThreadType(metadata)
|
thread_id, thread_type = getThreadIdAndThreadType(metadata)
|
||||||
event_type = delta["untypedData"]["event_type"]
|
event_type = delta["untypedData"]["event_type"]
|
||||||
poll_json = json.loads(delta["untypedData"]["question_json"])
|
poll_json = json.loads(delta["untypedData"]["question_json"])
|
||||||
poll = graphql_to_poll(poll_json)
|
poll = Poll._from_graphql(poll_json)
|
||||||
if event_type == "question_creation":
|
if event_type == "question_creation":
|
||||||
# User created group poll
|
# User created group poll
|
||||||
self.onPollCreated(
|
self.onPollCreated(
|
||||||
|
@@ -217,16 +217,6 @@ def graphql_to_live_location(a):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def graphql_to_poll(a):
|
|
||||||
rtn = Poll(
|
|
||||||
title=a.get("title") if a.get("title") else a.get("text"),
|
|
||||||
options=[PollOption._from_graphql(m) for m in a.get("options")],
|
|
||||||
)
|
|
||||||
rtn.uid = int(a["id"])
|
|
||||||
rtn.options_count = a.get("total_count")
|
|
||||||
return rtn
|
|
||||||
|
|
||||||
|
|
||||||
def graphql_to_plan(a):
|
def graphql_to_plan(a):
|
||||||
if a.get("event_members"):
|
if a.get("event_members"):
|
||||||
rtn = Plan(
|
rtn = Plan(
|
||||||
|
@@ -17,6 +17,15 @@ class Poll(object):
|
|||||||
#: Options count
|
#: Options count
|
||||||
options_count = attr.ib(None, init=False)
|
options_count = attr.ib(None, init=False)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _from_graphql(cls, data):
|
||||||
|
return cls(
|
||||||
|
uid=int(data["id"]),
|
||||||
|
title=data.get("title") if data.get("title") else data.get("text"),
|
||||||
|
options=[PollOption._from_graphql(m) for m in data.get("options")],
|
||||||
|
options_count=data.get("total_count"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@attr.s(cmp=False)
|
@attr.s(cmp=False)
|
||||||
class PollOption(object):
|
class PollOption(object):
|
||||||
|
@@ -13,7 +13,6 @@ from ._graphql import (
|
|||||||
graphql_to_extensible_attachment,
|
graphql_to_extensible_attachment,
|
||||||
graphql_to_subattachment,
|
graphql_to_subattachment,
|
||||||
graphql_to_live_location,
|
graphql_to_live_location,
|
||||||
graphql_to_poll,
|
|
||||||
graphql_to_plan,
|
graphql_to_plan,
|
||||||
graphql_to_quick_reply,
|
graphql_to_quick_reply,
|
||||||
graphql_to_message,
|
graphql_to_message,
|
||||||
|
Reference in New Issue
Block a user