Pyrofork: Storage: MongoStorage: Check if fragment usernames need to be updated

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
wulan17 2023-10-27 13:42:35 +07:00
parent 7fca0e87bb
commit 2900a03dc5
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5

View file

@ -165,6 +165,8 @@ class MongoStorage(Storage):
{'peer_id': 1, 'last_update_on': 1})
if r2 is None:
raise KeyError(f"Username not found: {username}")
if abs(time.time() - r2['last_update_on']) > self.USERNAME_TTL:
raise KeyError(f"Username expired: {username}")
r = await self._peer.find_one({'_id': r2['peer_id']},
{'_id': 1, 'access_hash': 1, 'type': 1, 'last_update_on': 1})
if r is None: