Move graphql_to_live_location -> LiveLocationAttachment._from_pull
This commit is contained in:
@@ -3010,7 +3010,7 @@ class Client(object):
|
|||||||
for l in i["messageLiveLocations"]:
|
for l in i["messageLiveLocations"]:
|
||||||
mid = l["messageId"]
|
mid = l["messageId"]
|
||||||
author_id = str(l["senderId"])
|
author_id = str(l["senderId"])
|
||||||
location = graphql_to_live_location(l)
|
location = LiveLocationAttachment._from_pull(l)
|
||||||
self.onLiveLocation(
|
self.onLiveLocation(
|
||||||
mid=mid,
|
mid=mid,
|
||||||
location=location,
|
location=location,
|
||||||
|
@@ -202,21 +202,6 @@ def graphql_to_subattachment(a):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def graphql_to_live_location(a):
|
|
||||||
return LiveLocationAttachment(
|
|
||||||
uid=a["id"],
|
|
||||||
latitude=a["coordinate"]["latitude"] / (10 ** 8)
|
|
||||||
if not a.get("stopReason")
|
|
||||||
else None,
|
|
||||||
longitude=a["coordinate"]["longitude"] / (10 ** 8)
|
|
||||||
if not a.get("stopReason")
|
|
||||||
else None,
|
|
||||||
name=a.get("locationTitle"),
|
|
||||||
expiration_time=a["expirationTime"],
|
|
||||||
is_expired=bool(a.get("stopReason")),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def graphql_to_plan(a):
|
def graphql_to_plan(a):
|
||||||
if a.get("event_members"):
|
if a.get("event_members"):
|
||||||
rtn = Plan(
|
rtn = Plan(
|
||||||
|
@@ -46,3 +46,18 @@ class LiveLocationAttachment(LocationAttachment):
|
|||||||
super(LiveLocationAttachment, self).__init__(**kwargs)
|
super(LiveLocationAttachment, self).__init__(**kwargs)
|
||||||
self.expiration_time = expiration_time
|
self.expiration_time = expiration_time
|
||||||
self.is_expired = is_expired
|
self.is_expired = is_expired
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _from_pull(cls, data):
|
||||||
|
return cls(
|
||||||
|
uid=data["id"],
|
||||||
|
latitude=data["coordinate"]["latitude"] / (10 ** 8)
|
||||||
|
if not data.get("stopReason")
|
||||||
|
else None,
|
||||||
|
longitude=data["coordinate"]["longitude"] / (10 ** 8)
|
||||||
|
if not data.get("stopReason")
|
||||||
|
else None,
|
||||||
|
name=data.get("locationTitle"),
|
||||||
|
expiration_time=data["expirationTime"],
|
||||||
|
is_expired=bool(data.get("stopReason")),
|
||||||
|
)
|
||||||
|
@@ -12,7 +12,6 @@ from ._graphql import (
|
|||||||
graphql_to_attachment,
|
graphql_to_attachment,
|
||||||
graphql_to_extensible_attachment,
|
graphql_to_extensible_attachment,
|
||||||
graphql_to_subattachment,
|
graphql_to_subattachment,
|
||||||
graphql_to_live_location,
|
|
||||||
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