Fixed traceback happened when attempting to send streaming data to not logged sessions

This commit is contained in:
Manuel Cortez 2021-07-03 11:51:11 -05:00
parent 864ebdf96d
commit 7eb2d8930f

View File

@ -108,7 +108,6 @@ class Session(base.baseSession):
self.db["sent_direct_messages"] = sent_objects self.db["sent_direct_messages"] = sent_objects
pub.sendMessage("sent-dms-updated", total=sent, account=self.db["user_name"]) pub.sendMessage("sent-dms-updated", total=sent, account=self.db["user_name"])
return incoming return incoming
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
@ -515,6 +514,8 @@ class Session(base.baseSession):
def handle_new_status(self, status, user): def handle_new_status(self, status, user):
""" Handles a new status present in the Streaming API. """ """ Handles a new status present in the Streaming API. """
if self.logged == False:
return
# Discard processing the status if the streaming sends a tweet for another account. # Discard processing the status if the streaming sends a tweet for another account.
if self.db["user_name"] != user: if self.db["user_name"] != user:
return return
@ -559,5 +560,7 @@ class Session(base.baseSession):
self.start_streaming() self.start_streaming()
def handle_connected(self, user): def handle_connected(self, user):
if self.logged == False:
return
if user != self.db["user_name"]: if user != self.db["user_name"]:
log.debug("Connected streaming endpoint on account {}".format(user)) log.debug("Connected streaming endpoint on account {}".format(user))