Skip to content

Commit cde373e

Browse files
authored
Merge pull request Fatal1ty#47 from baldurh/410-timestamp
Add support for timestamp
2 parents 3e8c694 + 1234cdc commit cde373e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

aioapns/common.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,19 @@ def __init__(
4848

4949

5050
class NotificationResult:
51-
__slots__ = ("notification_id", "status", "description")
51+
__slots__ = ("notification_id", "status", "description", "timestamp")
5252

5353
def __init__(
5454
self,
5555
notification_id: str,
5656
status: str,
5757
description: Optional[str] = None,
58+
timestamp: Optional[int] = None,
5859
):
5960
self.notification_id = notification_id
6061
self.status = status
6162
self.description = description
63+
self.timestamp = timestamp
6264

6365
@property
6466
def is_successful(self) -> bool:

aioapns/connection.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ def on_response_received(self, headers: Dict[bytes, bytes]) -> None:
266266
def on_data_received(self, raw_data: bytes, stream_id: int) -> None:
267267
data = json.loads(raw_data.decode())
268268
reason = data.get("reason", "")
269+
timestamp = data.get("timestamp")
270+
269271
if not reason:
270272
return
271273

@@ -276,7 +278,10 @@ def on_data_received(self, raw_data: bytes, stream_id: int) -> None:
276278
# TODO: Теоретически здесь может быть ошибка, если нет ключа
277279
status = self.request_statuses.pop(notification_id)
278280
result = NotificationResult(
279-
notification_id, status, description=reason
281+
notification_id,
282+
status,
283+
description=reason,
284+
timestamp=timestamp,
280285
)
281286
request.set_result(result)
282287
else:

0 commit comments

Comments
 (0)