Arreglado un problema con inicio de sesiones

This commit is contained in:
Jesús Pavón Abián
2026-02-01 20:15:10 +01:00
parent 8402bc6d82
commit 86adf2311a
5 changed files with 93 additions and 12 deletions

View File

@@ -122,7 +122,27 @@ def is_image(post):
"""
actual_post = g(post, "post", post)
embed = g(actual_post, "embed", None)
return len(_extract_images_from_embed(embed)) > 0
if not embed:
return False
etype = g(embed, "$type") or g(embed, "py_type") or ""
# Direct images embed
if "images" in etype.lower():
images = g(embed, "images", [])
if images and len(images) > 0:
return True
# Check in recordWithMedia wrapper
if "recordwithmedia" in etype.lower():
media = g(embed, "media", {})
mtype = g(media, "$type") or g(media, "py_type") or ""
if "images" in mtype.lower():
images = g(media, "images", [])
if images and len(images) > 0:
return True
return False
def get_image_urls(post):

View File

@@ -44,7 +44,7 @@ class Session(base.baseSession):
if self.settings["mastodon"]["access_token"] != None and self.settings["mastodon"]["instance"] != None:
try:
log.debug("Logging in to Mastodon instance {}...".format(self.settings["mastodon"]["instance"]))
self.api = mastodon.Mastodon(access_token=self.settings["mastodon"]["access_token"], api_base_url=self.settings["mastodon"]["instance"], mastodon_version=MASTODON_VERSION, user_agent="TWBlue/{}".format(application.version), version_check_mode=self.version_check_mode)
self.api = mastodon.Mastodon(access_token=self.settings["mastodon"]["access_token"], api_base_url=self.settings["mastodon"]["instance"], mastodon_version=MASTODON_VERSION, user_agent="TWBlue/{}".format(application.version), version_check_mode=self.version_check_mode, request_timeout=30)
if verify_credentials == True:
credentials = self.api.account_verify_credentials()
self.db["user_name"] = credentials["username"]