From 4ad01d783308b34acfd9a1228f8e8e657fb3ccbf Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Fri, 25 Jun 2021 13:13:00 -0500 Subject: [PATCH] Retrieve user objects from the users list stored in SqlDict as opposed to loading it from tweet objects --- src/controller/buffers/twitterBuffers.py | 15 ++++++++------- src/controller/mainController.py | 24 ++++++++++++------------ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/controller/buffers/twitterBuffers.py b/src/controller/buffers/twitterBuffers.py index 25081b72..6141319d 100644 --- a/src/controller/buffers/twitterBuffers.py +++ b/src/controller/buffers/twitterBuffers.py @@ -413,7 +413,8 @@ class baseBufferController(baseBuffers.buffer): @_tweets_exist def reply(self, *args, **kwargs): tweet = self.get_right_tweet() - screen_name = tweet.user.screen_name + user = self.session.get_user(tweet.user) + screen_name = user.screen_name id = tweet.id twishort_enabled = hasattr(tweet, "twishort") users = utils.get_all_mentioned(tweet, self.session.db, field="screen_name") @@ -466,8 +467,8 @@ class baseBufferController(baseBuffers.buffer): screen_name = tweet.screen_name users = [screen_name] else: - screen_name = tweet.user.screen_name - users = utils.get_all_users(tweet, self.session.db) + screen_name = self.session.get_user(tweet.user).screen_name + users = utils.get_all_users(tweet, self.session) dm = messages.dm(self.session, _(u"Direct message to %s") % (screen_name,), _(u"New direct message"), users) if dm.message.get_response() == widgetUtils.OK: screen_name = dm.message.get("cb") @@ -508,12 +509,12 @@ class baseBufferController(baseBuffers.buffer): comments = tweet.full_text else: comments = tweet.text - retweet = messages.tweet(self.session, _(u"Quote"), _(u"Add your comment to the tweet"), u"“@%s: %s ”" % (tweet.user.screen_name, comments), max=256, messageType="retweet") + retweet = messages.tweet(self.session, _(u"Quote"), _(u"Add your comment to the tweet"), u"“@%s: %s ”" % (self.session.get_user(tweet.user).screen_name, comments), max=256, messageType="retweet") if comment != '': retweet.message.set_text(comment) if retweet.message.get_response() == widgetUtils.OK: text = retweet.message.get_text() - text = text+" https://twitter.com/{0}/status/{1}".format(tweet.user.screen_name, id) + text = text+" https://twitter.com/{0}/status/{1}".format(self.session.get_user(tweet.user).screen_name, id) if retweet.image == None: item = self.session.api_call(call_name="update_status", _sound="retweet_send.ogg", status=text, in_reply_to_status_id=id, tweet_mode="extended") if item != None: @@ -616,7 +617,7 @@ class baseBufferController(baseBuffers.buffer): elif self.type == "people": users = [tweet.screen_name] else: - users = utils.get_all_users(tweet, self.session.db) + users = utils.get_all_users(tweet, self.session) dlg = dialogs.utils.selectUserDialog(title=_(u"User details"), users=users) if dlg.get_response() == widgetUtils.OK: user.profileController(session=self.session, user=dlg.get_user()) @@ -634,7 +635,7 @@ class baseBufferController(baseBuffers.buffer): def open_in_browser(self, *args, **kwargs): tweet = self.get_tweet() output.speak(_(u"Opening item in web browser...")) - url = "https://twitter.com/{screen_name}/status/{tweet_id}".format(screen_name=tweet.user.screen_name, tweet_id=tweet.id) + url = "https://twitter.com/{screen_name}/status/{tweet_id}".format(screen_name=self.session.get_user(tweet.user).screen_name, tweet_id=tweet.id) webbrowser.open(url) class directMessagesController(baseBufferController): diff --git a/src/controller/mainController.py b/src/controller/mainController.py index f37f7677..da92d8eb 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -530,7 +530,7 @@ class Controller(object): elif buff.type == "dm": users = [buff.session.get_user(tweet.message_create["sender_id"]).screen_name] else: - users = utils.get_all_users(tweet, buff.session.db) + users = utils.get_all_users(tweet, buff.session) dlg = dialogs.utils.selectUserDialog(_(u"Select the user"), users) if dlg.get_response() == widgetUtils.OK: user = dlg.get_user() @@ -547,7 +547,7 @@ class Controller(object): elif buff.type == "dm": users = [buff.session.get_user(tweet.message_create["sender_id"]).screen_name] else: - users = utils.get_all_users(tweet, buff.session.db) + users = utils.get_all_users(tweet, buff.session) dlg = dialogs.utils.selectUserDialog(_(u"Select the user"), users) if dlg.get_response() == widgetUtils.OK: user = dlg.get_user() @@ -575,7 +575,7 @@ class Controller(object): elif buff.type == "dm": users = [buff.session.get_user(tweet.message_create["sender_id"]).screen_name] else: - users = utils.get_all_users(tweet, buff.session.db) + users = utils.get_all_users(tweet, buff.session) dlg = dialogs.utils.selectUserDialog(_(u"Select the user"), users) if dlg.get_response() == widgetUtils.OK: user = dlg.get_user() @@ -669,7 +669,7 @@ class Controller(object): elif buff.type == "dm": users = [buff.session.get_user(tweet.message_create["sender_id"]).screen_name] else: - users = utils.get_all_users(tweet, buff.session.db) + users = utils.get_all_users(tweet, buff.session) u = userActionsController.userActionsController(buff, users) def unfollow(self, *args, **kwargs): @@ -681,7 +681,7 @@ class Controller(object): elif buff.type == "dm": users = [buff.session.get_user(tweet.message_create["sender_id"]).screen_name] else: - users = utils.get_all_users(tweet, buff.session.db) + users = utils.get_all_users(tweet, buff.session) u = userActionsController.userActionsController(buff, users, "unfollow") def mute(self, *args, **kwargs): @@ -693,7 +693,7 @@ class Controller(object): elif buff.type == "dm": users = [buff.session.get_user(tweet.message_create["sender_id"]).screen_name] else: - users = utils.get_all_users(tweet, buff.session.db) + users = utils.get_all_users(tweet, buff.session) u = userActionsController.userActionsController(buff, users, "mute") def unmute(self, *args, **kwargs): @@ -705,7 +705,7 @@ class Controller(object): elif buff.type == "dm": users = [buff.session.get_user(tweet.message_create["sender_id"]).screen_name] else: - users = utils.get_all_users(tweet, buff.session.db) + users = utils.get_all_users(tweet, buff.session) u = userActionsController.userActionsController(buff, users, "unmute") def block(self, *args, **kwargs): @@ -717,7 +717,7 @@ class Controller(object): elif buff.type == "dm": users = [buff.session.get_user(tweet.message_create["sender_id"]).screen_name] else: - users = utils.get_all_users(tweet, buff.session.db) + users = utils.get_all_users(tweet, buff.session) u = userActionsController.userActionsController(buff, users, "block") def unblock(self, *args, **kwargs): @@ -729,7 +729,7 @@ class Controller(object): elif buff.type == "dm": users = [buff.session.get_user(tweet.message_create["sender_id"]).screen_name] else: - users = utils.get_all_users(tweet, buff.session.db) + users = utils.get_all_users(tweet, buff.session) u = userActionsController.userActionsController(buff, users, "unblock") def report(self, *args, **kwargs): @@ -741,7 +741,7 @@ class Controller(object): elif buff.type == "dm": users = [buff.session.get_user(tweet.message_create["sender_id"]).screen_name] else: - users = utils.get_all_users(tweet, buff.session.db) + users = utils.get_all_users(tweet, buff.session) u = userActionsController.userActionsController(buff, users, "report") def post_tweet(self, event=None): @@ -828,7 +828,7 @@ class Controller(object): elif buff.type == "dm": users = [buff.session.get_user(tweet.message_create["sender_id"]).screen_name] else: - users = utils.get_all_users(tweet, buff.session.db) + users = utils.get_all_users(tweet, buff.session) dlg = dialogs.userSelection.selectUserDialog(users=users, default=default) if dlg.get_response() == widgetUtils.OK: usr = utils.if_user_exists(buff.session.twitter, dlg.get_user()) @@ -924,7 +924,7 @@ class Controller(object): def open_conversation(self, *args, **kwargs): buffer = self.get_current_buffer() id = buffer.get_right_tweet().id_str - user = buffer.get_right_tweet().user.screen_name + user = buff.session.get_user(buffer.get_right_tweet().user).screen_name search = twitterBuffers.conversationBufferController(self.view.nb, "search", "%s-searchterm" % (id,), buffer.session, buffer.session.db["user_name"], bufferType="searchPanel", sound="search_updated.ogg", since_id=id, q="@{0}".format(user,)) search.tweet = buffer.get_right_tweet() search.start_stream(start=True)