Honor custom character limit if reported by the instance

This commit is contained in:
Manuel Cortez 2022-11-16 10:06:14 -06:00
parent 4c43f82b60
commit f5e52c6387
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790
2 changed files with 8 additions and 2 deletions

View File

@ -9,8 +9,9 @@ from sessions.mastodon import templates
from wxUI.dialogs.mastodon import tootDialogs
class toot(messages.basicTweet):
def __init__(self, session, title, caption, text="", max=500, *args, **kwargs):
self.max = max
def __init__(self, session, title, caption, text="", *args, **kwargs):
# take max character limit from session as this might be different for some instances.
self.max = session.char_limit
self.title = title
self.session = session
self.message = tootDialogs.Toot(caption=caption, text=text, *args, **kwargs)

View File

@ -28,6 +28,7 @@ class Session(base.baseSession):
self.supported_languages = []
self.type = "mastodon"
self.db["pagination_info"] = dict()
self.char_limit = 500
def login(self, verify_credentials=True):
if self.settings["mastodon"]["access_token"] != None and self.settings["mastodon"]["instance"] != None:
@ -73,6 +74,10 @@ class Session(base.baseSession):
self.supported_languages = self.api.instance().languages
self.get_lists()
self.get_muted_users()
# determine instance custom characters limit.
instance = self.api.instance()
if hasattr(instance, "max_toot_chars"):
self.char_limit = instance.max_toot_chars
self.settings.write()
def get_lists(self):