From 2900a03dc503ca1e6ec6a8b8f4986dacd945b720 Mon Sep 17 00:00:00 2001 From: wulan17 Date: Fri, 27 Oct 2023 13:42:35 +0700 Subject: [PATCH] Pyrofork: Storage: MongoStorage: Check if fragment usernames need to be updated Signed-off-by: wulan17 --- pyrogram/storage/mongo_storage.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyrogram/storage/mongo_storage.py b/pyrogram/storage/mongo_storage.py index 2dc563da..2538bf2a 100644 --- a/pyrogram/storage/mongo_storage.py +++ b/pyrogram/storage/mongo_storage.py @@ -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: