Removed unneeded code and fixed small typos

This commit is contained in:
Manuel Cortez 2022-11-20 14:54:10 -06:00
parent e42bd85274
commit 8850e5fdde
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790
3 changed files with 4 additions and 4 deletions

View File

@ -1247,10 +1247,9 @@ class Controller(object):
def mastodon_new_conversation(self, conversation, session_name): def mastodon_new_conversation(self, conversation, session_name):
buffer = self.search_buffer("direct_messages", session_name) buffer = self.search_buffer("direct_messages", session_name)
if buffer == None: if buffer == None:
print("Buffer not found.") log.error("Buffer not found: direct_messages on {}".format(session_name))
return # Direct messages buffer is hidden return # Direct messages buffer is hidden
new_position, number_of_items = buffer.order_buffer([conversation]) new_position, number_of_items = buffer.order_buffer([conversation])
print(new_position, number_of_items)
buffer.put_items_on_list(number_of_items) buffer.put_items_on_list(number_of_items)
if new_position > -1: if new_position > -1:
buffer.buffer.list.select_item(new_position) buffer.buffer.list.select_item(new_position)

View File

@ -13,7 +13,6 @@ class StreamListener(mastodon.StreamListener):
pub.sendMessage("mastodon.status_received", status=status, session_name=self.session_name) pub.sendMessage("mastodon.status_received", status=status, session_name=self.session_name)
def on_conversation(self, conversation): def on_conversation(self, conversation):
print("New conversation: {}".format(conversation))
pub.sendMessage("mastodon.conversation_received", conversation=conversation, session_name=self.session_name) pub.sendMessage("mastodon.conversation_received", conversation=conversation, session_name=self.session_name)
def on_notification(self, notification): def on_notification(self, notification):

View File

@ -35,13 +35,15 @@ def is_audio_or_video(post):
def is_image(post): def is_image(post):
if post.reblog != None: if post.reblog != None:
return is_audio_or_video(post.reblog) return is_image(post.reblog)
# Checks firstly for Mastodon native videos and audios. # Checks firstly for Mastodon native videos and audios.
for media in post.media_attachments: for media in post.media_attachments:
if media["type"] == "gifv" or media["type"] == "image": if media["type"] == "gifv" or media["type"] == "image":
return True return True
def get_media_urls(post): def get_media_urls(post):
if hasattr(post, "reblog") and post.reblog != None:
return get_media_urls(post.reblog)
urls = [] urls = []
for media in post.media_attachments: for media in post.media_attachments:
if media.get("type") == "audio" or media.get("type") == "video": if media.get("type") == "audio" or media.get("type") == "video":