Mastodon: Implemented setting to disable Streaming API endpoints on sessions

This commit is contained in:
Manuel Cortez 2023-02-05 19:09:27 -06:00
parent ef2e63e195
commit 24e91235f3
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790
4 changed files with 10 additions and 1 deletions

View File

@ -31,6 +31,7 @@ class accountSettingsController(globalSettingsController):
self.dialog.create_general_account()
# widgetUtils.connect_event(self.dialog.general.userAutocompletionScan, widgetUtils.BUTTON_PRESSED, self.on_autocompletion_scan)
# widgetUtils.connect_event(self.dialog.general.userAutocompletionManage, widgetUtils.BUTTON_PRESSED, self.on_autocompletion_manage)
self.dialog.set_value("general", "disable_streaming", self.config["general"]["disable_streaming"])
self.dialog.set_value("general", "relative_time", self.config["general"]["relative_times"])
self.dialog.set_value("general", "read_preferences_from_instance", self.config["general"]["read_preferences_from_instance"])
self.dialog.set_value("general", "show_screen_names", self.config["general"]["show_screen_names"])
@ -112,6 +113,10 @@ class accountSettingsController(globalSettingsController):
self.needs_restart = True
log.debug("Triggered app restart due to change in relative times.")
self.config["general"]["relative_times"] = self.dialog.get_value("general", "relative_time")
if self.config["general"]["disable_streaming"] != self.dialog.get_value("general", "disable_streaming"):
self.needs_restart = True
log.debug("Triggered app restart due to change in streaming settings.")
self.config["general"]["disable_streaming"] = self.dialog.get_value("general", "disable_streaming")
self.config["general"]["read_preferences_from_instance"] = self.dialog.get_value("general", "read_preferences_from_instance")
self.config["general"]["show_screen_names"] = self.dialog.get_value("general", "show_screen_names")
self.config["general"]["hide_emojis"] = self.dialog.get_value("general", "hide_emojis")

View File

@ -15,6 +15,7 @@ show_screen_names = boolean(default=False)
hide_emojis = boolean(default=False)
buffer_order = list(default=list('home', 'local', 'mentions', 'direct_messages', 'sent', 'favorites', 'bookmarks', 'followers', 'following', 'blocked', 'muted', 'notifications'))
boost_mode = string(default="ask")
disable_streaming = boolean(default=False)
[sound]
volume = float(default=1.0)

View File

@ -223,7 +223,8 @@ class Session(base.baseSession):
return "Mastodon: {}@{}".format(user, instance)
def start_streaming(self):
if config.app["app-settings"]["no_streaming"]:
if self.settings["general"]["disable_streaming"]:
log.info("Streaming is disabled for session {}. Skipping...".format(self.get_name()))
return
listener = streaming.StreamListener(session_name=self.get_name(), user_id=self.db["user_id"])
try:

View File

@ -20,6 +20,8 @@ class generalAccount(wx.Panel, baseDialog.BaseWXDialog):
autocompletionSizer.Add(self.userAutocompletionScan, 0, wx.ALL, 5)
autocompletionSizer.Add(self.userAutocompletionManage, 0, wx.ALL, 5)
sizer.Add(autocompletionSizer, 0, wx.ALL, 5)
self.disable_streaming = wx.CheckBox(self, wx.ID_ANY, _("Disable Streaming API endpoints"))
sizer.Add(self.disable_streaming, 0, wx.ALL, 5)
self.relative_time = wx.CheckBox(self, wx.ID_ANY, _("Relative timestamps"))
sizer.Add(self.relative_time, 0, wx.ALL, 5)
self.read_preferences_from_instance = wx.CheckBox(self, wx.ID_ANY, _("Read preferences from instance (default visibility when publishing and displaying sensitive content)"))