From 48a5da8958f55763f7cd07bb5c7f38e112ac9f9d Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Fri, 31 May 2019 16:36:20 +0200
Subject: [PATCH] Let FutureSalt(s) attributes be plain integer instead of
datetime values
---
pyrogram/api/core/future_salt.py | 7 +++----
pyrogram/api/core/future_salts.py | 5 ++---
pyrogram/session/session.py | 3 ++-
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/pyrogram/api/core/future_salt.py b/pyrogram/api/core/future_salt.py
index 4ee8197b..c4ccea3d 100644
--- a/pyrogram/api/core/future_salt.py
+++ b/pyrogram/api/core/future_salt.py
@@ -16,7 +16,6 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
-from datetime import datetime
from io import BytesIO
from .object import Object
@@ -30,15 +29,15 @@ class FutureSalt(Object):
QUALNAME = "FutureSalt"
- def __init__(self, valid_since: int or datetime, valid_until: int or datetime, salt: int):
+ def __init__(self, valid_since: int, valid_until: int, salt: int):
self.valid_since = valid_since
self.valid_until = valid_until
self.salt = salt
@staticmethod
def read(b: BytesIO, *args) -> "FutureSalt":
- valid_since = datetime.fromtimestamp(Int.read(b))
- valid_until = datetime.fromtimestamp(Int.read(b))
+ valid_since = Int.read(b)
+ valid_until = Int.read(b)
salt = Long.read(b)
return FutureSalt(valid_since, valid_until, salt)
diff --git a/pyrogram/api/core/future_salts.py b/pyrogram/api/core/future_salts.py
index cf6a9902..91ee7b51 100644
--- a/pyrogram/api/core/future_salts.py
+++ b/pyrogram/api/core/future_salts.py
@@ -16,7 +16,6 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
-from datetime import datetime
from io import BytesIO
from . import FutureSalt
@@ -31,7 +30,7 @@ class FutureSalts(Object):
QUALNAME = "FutureSalts"
- def __init__(self, req_msg_id: int, now: int or datetime, salts: list):
+ def __init__(self, req_msg_id: int, now: int, salts: list):
self.req_msg_id = req_msg_id
self.now = now
self.salts = salts
@@ -39,7 +38,7 @@ class FutureSalts(Object):
@staticmethod
def read(b: BytesIO, *args) -> "FutureSalts":
req_msg_id = Long.read(b)
- now = datetime.fromtimestamp(Int.read(b))
+ now = Int.read(b)
count = Int.read(b)
salts = [FutureSalt.read(b) for _ in range(count)]
diff --git a/pyrogram/session/session.py b/pyrogram/session/session.py
index 66207037..e4260be4 100644
--- a/pyrogram/session/session.py
+++ b/pyrogram/session/session.py
@@ -350,7 +350,8 @@ class Session:
# Seconds to wait until middle-overlap, which is
# 15 minutes before/after the current/next salt end/start time
- dt = (self.current_salt.valid_until - now).total_seconds() - 900
+ valid_until = datetime.fromtimestamp(self.current_salt.valid_until)
+ dt = (valid_until - now).total_seconds() - 900
log.debug("Current salt: {} | Next salt in {:.0f}m {:.0f}s ({})".format(
self.current_salt.salt,