Fix initial session state load

This commit is contained in:
Lonami Exo 2022-05-16 19:01:05 +02:00
parent c16fb0dae6
commit 09b9cd8193
2 changed files with 8 additions and 2 deletions

View File

@ -543,7 +543,7 @@ class TelegramBaseClient(abc.ABC):
for entity_id, state in await self.session.get_update_states():
if entity_id == 0:
# TODO current session doesn't store self-user info but adding that is breaking on downstream session impls
ss = SessionState(0, 0, False, state.pts, state.qts, state.date, state.seq, None)
ss = SessionState(0, 0, False, state.pts, state.qts, int(state.date.timestamp()), state.seq, None)
else:
cs.append(ChannelState(entity_id, state.pts))

View File

@ -219,7 +219,13 @@ class SQLiteSession(MemorySession):
c = self._cursor()
try:
rows = c.execute('select id, pts, qts, date, seq from update_state').fetchall()
return ((row[0], types.updates.State(*row[1:], unread_count=0)) for row in rows)
return ((row[0], types.updates.State(
pts=row[1],
qts=row[2],
date=datetime.datetime.fromtimestamp(row[3], tz=datetime.timezone.utc),
seq=row[4],
unread_count=0)
) for row in rows)
finally:
c.close()