Skip to content

Commit

Permalink
fix: set_current_user not commit, should_show_current_user logic
Browse files Browse the repository at this point in the history
  • Loading branch information
hlf20010508 committed Dec 27, 2023
1 parent f4f8e1a commit 8946234
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions modules/handlers/drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import subprocess
from modules.client import tg_bot, onedrive
from modules.env import tg_user_name
from modules.utils import check_in_group, check_tg_login, cmd_parser, CMDException
from modules.utils import check_in_group, check_tg_login, cmd_parser
from modules.handlers.auth import od_auth


Expand Down Expand Up @@ -96,7 +96,8 @@ async def drive_handler(event):
raise events.StopPropagation

if index < len(users):
should_show_current_user = onedrive.logout(users[index])
should_show_current_user = True if users[index] == onedrive.session.username else False
onedrive.logout(users[index])
if should_show_current_user:
current_user = onedrive.session.current_user
logout_res = f"OneDrive logout successfully.\nCurrent account is {current_user}"
Expand Down
1 change: 1 addition & 0 deletions modules/onedrive/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def set_current_user(self, username):
insert into current_user(user_id) values(?);
'''
self.execute(command, params=(user_id,))
self.commit()

def get_user_id(self, username):
command = '''
Expand Down
4 changes: 2 additions & 2 deletions modules/onedrive/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ def logout(self, username=''):

else:
self.db.delete_user(username)
# don't show current user
return False
# has other users
return True

def change_user(self, username):
record = self.db.get_user(username)
Expand Down

0 comments on commit 8946234

Please sign in to comment.