Skip to content

Commit

Permalink
Fix Token System Related Errors (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
modebomb authored Jan 4, 2025
1 parent f3e8174 commit 9d81f0f
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions bot/helper/ext_utils/db_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ async def update_user_data(self, user_id):
del data["rclone_config"]
if data.get("token_pickle"):
del data["token_pickle"]
if data.get("token"):
del data["token"]
if data.get("time"):
del data["time"]
await self.db.users.replace_one({"_id": user_id}, data, upsert=True)

async def update_user_doc(self, user_id, key, path=""):
Expand Down Expand Up @@ -164,6 +168,51 @@ async def add_incomplete_task(self, cid, link, tag):
{"_id": link, "cid": cid, "tag": tag},
)

async def update_user_tdata(self, user_id, token, time):
if self._return:
return
await self.db.access_token.update_one(
{"_id": user_id},
{"$set": {"token": token, "time": time}},
upsert=True,
)

async def update_user_token(self, user_id, token):
if self._return:
return
await self.db.access_token.update_one(
{"_id": user_id},
{"$set": {"token": token}},
upsert=True,
)

async def get_token_expiry(self, user_id):
if self._return:
return None
user_data = await self.db.access_token.find_one({"_id": user_id})
if user_data:
return user_data.get("time")
return None

async def delete_user_token(self, user_id):
if self._return:
return
await self.db.access_token.delete_one({"_id": user_id})

async def get_user_token(self, user_id):
if self._return:
return None
user_data = await self.db.access_token.find_one({"_id": user_id})
if user_data:
return user_data.get("token")
return None

async def delete_all_access_tokens(self):
if self._return:
return
await self.db.access_token.delete_many({})


async def rm_complete_task(self, link):
if self._return:
return
Expand Down

0 comments on commit 9d81f0f

Please sign in to comment.