From f5e52c6387f431151c953b2f392fe182b3c2bc90 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Wed, 16 Nov 2022 10:06:14 -0600 Subject: [PATCH] Honor custom character limit if reported by the instance --- src/controller/mastodon/messages.py | 5 +++-- src/sessions/mastodon/session.py | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/controller/mastodon/messages.py b/src/controller/mastodon/messages.py index b23691af..4620132f 100644 --- a/src/controller/mastodon/messages.py +++ b/src/controller/mastodon/messages.py @@ -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) diff --git a/src/sessions/mastodon/session.py b/src/sessions/mastodon/session.py index 308def98..499688cf 100644 --- a/src/sessions/mastodon/session.py +++ b/src/sessions/mastodon/session.py @@ -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):