From fefd88b71cf4325a85b36915f13b51142e2c5a01 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Wed, 16 Nov 2022 11:01:52 -0600 Subject: [PATCH] Create valid account buffers even when session cannot login to the network (works for ignored sessions) --- src/controller/mainController.py | 11 ++++------- src/controller/mastodon/handler.py | 2 +- src/controller/twitter/handler.py | 2 +- src/sessions/mastodon/session.py | 2 +- src/sessions/twitter/session.py | 5 ++++- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/controller/mainController.py b/src/controller/mainController.py index cf65f3e1..ee592e1f 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -275,12 +275,7 @@ class Controller(object): self.streams_checker_function.start() def create_ignored_session_buffer(self, session): - self.accounts.append(session.settings["twitter"]["user_name"]) - account = buffers.base.AccountBuffer(self.view.nb, session.settings["twitter"]["user_name"], session.settings["twitter"]["user_name"], session.session_id) - account.logged = False - account.setup_account() - self.buffers.append(account) - self.view.add_buffer(account.buffer , name=session.settings["twitter"]["user_name"]) + pub.sendMessage("core.create_account", name=session.get_name(), session_id=session.session_id) def login_account(self, session_id): for i in sessions.sessions: @@ -291,9 +286,11 @@ class Controller(object): handler.create_buffers(session=session, controller=self, createAccounts=False) self.start_buffers(session) - def create_account_buffer(self, name, session_id): + def create_account_buffer(self, name, session_id, logged=False): self.accounts.append(name) account = buffers.base.AccountBuffer(self.view.nb, name, name, session_id) + if logged == False: + account.logged = logged account.setup_account() self.buffers.append(account) self.view.add_buffer(account.buffer , name=name) diff --git a/src/controller/mastodon/handler.py b/src/controller/mastodon/handler.py index 7d925967..fe415470 100644 --- a/src/controller/mastodon/handler.py +++ b/src/controller/mastodon/handler.py @@ -15,7 +15,7 @@ class Handler(object): session.get_user_info() name = session.get_name() if createAccounts == True: - pub.sendMessage("core.create_account", name=name, session_id=session.session_id) + pub.sendMessage("core.create_account", name=name, session_id=session.session_id, logged=True) root_position =controller.view.search(name, name) for i in session.settings['general']['buffer_order']: if i == 'home': diff --git a/src/controller/twitter/handler.py b/src/controller/twitter/handler.py index de8dfb01..01e19448 100644 --- a/src/controller/twitter/handler.py +++ b/src/controller/twitter/handler.py @@ -21,7 +21,7 @@ class Handler(object): session.get_user_info() name = session.get_name() if createAccounts == True: - pub.sendMessage("core.create_account", name=name, session_id=session.session_id) + pub.sendMessage("core.create_account", name=name, session_id=session.session_id, logged=True) root_position =controller.view.search(name, name) for i in session.settings['general']['buffer_order']: if i == 'home': diff --git a/src/sessions/mastodon/session.py b/src/sessions/mastodon/session.py index 499688cf..7bca9c21 100644 --- a/src/sessions/mastodon/session.py +++ b/src/sessions/mastodon/session.py @@ -175,5 +175,5 @@ class Session(base.baseSession): def get_name(self): instance = self.settings["mastodon"]["instance"] instance = instance.replace("https://", "") - user = self.db["user_name"] + user = self.settings["mastodon"]["user_name"] return "Mastodon: {}@{}".format(user, instance) \ No newline at end of file diff --git a/src/sessions/twitter/session.py b/src/sessions/twitter/session.py index 3898addc..a957f069 100644 --- a/src/sessions/twitter/session.py +++ b/src/sessions/twitter/session.py @@ -674,4 +674,7 @@ class Session(base.baseSession): pub.sendMessage("sent-dm", data=item, session_name=self.get_name()) def get_name(self): - return "Twitter: {}".format(self.db["user_name"]) \ No newline at end of file + if self.logged: + return "Twitter: {}".format(self.db["user_name"]) + else: + return "Twitter: {}".format(self.settings["twitter"]["user_name"]) \ No newline at end of file