Make ActiveStatus.last_active a datetime object

This commit is contained in:
Mads Marquart
2019-09-08 13:02:57 +02:00
parent aef64e5c29
commit 61842b199f

View File

@@ -183,7 +183,7 @@ class User(Thread):
class ActiveStatus: class ActiveStatus:
#: Whether the user is active now #: Whether the user is active now
active = attr.ib(None) active = attr.ib(None)
#: Timestamp when the user was last active #: Datetime when the user was last active
last_active = attr.ib(None) last_active = attr.ib(None)
#: Whether the user is playing Messenger game now #: Whether the user is playing Messenger game now
in_game = attr.ib(None) in_game = attr.ib(None)
@@ -192,7 +192,7 @@ class ActiveStatus:
def _from_chatproxy_presence(cls, id_, data): def _from_chatproxy_presence(cls, id_, data):
return cls( return cls(
active=data["p"] in [2, 3] if "p" in data else None, active=data["p"] in [2, 3] if "p" in data else None,
last_active=data.get("lat"), last_active=_util.millis_to_datetime(data.get("lat")),
in_game=int(id_) in data.get("gamers", {}), in_game=int(id_) in data.get("gamers", {}),
) )
@@ -200,6 +200,6 @@ class ActiveStatus:
def _from_buddylist_overlay(cls, data, in_game=None): def _from_buddylist_overlay(cls, data, in_game=None):
return cls( return cls(
active=data["a"] in [2, 3] if "a" in data else None, active=data["a"] in [2, 3] if "a" in data else None,
last_active=data.get("la"), last_active=_util.millis_to_datetime(data.get("la")),
in_game=None, in_game=None,
) )