From 925b7b29508c0fa6371781c15c2041d4cf8e596e Mon Sep 17 00:00:00 2001 From: Sudo-Ivan Date: Sat, 3 Jan 2026 19:23:53 -0600 Subject: [PATCH] feat(announces): fix announce handling by adding identity and destination hash filters; ensure UTC formatting for created_at and updated_at timestamps; introduce message font size configuration --- meshchatx/meshchat.py | 25 +++++++++++++++++---- meshchatx/src/backend/config_manager.py | 1 + meshchatx/src/backend/database/announces.py | 8 +++++++ meshchatx/src/backend/markdown_renderer.py | 2 +- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/meshchatx/meshchat.py b/meshchatx/meshchat.py index 26dcc89..88adfe1 100644 --- a/meshchatx/meshchat.py +++ b/meshchatx/meshchat.py @@ -5004,7 +5004,10 @@ class ReticulumMeshChat: # limit results if limit is not None: - results = results[: int(limit)] + try: + results = results[: int(limit)] + except (ValueError, TypeError): + pass # process announces lxmf_propagation_nodes = [] @@ -5058,6 +5061,15 @@ class ReticulumMeshChat: is_propagation_enabled = propagation_node_data["enabled"] per_transfer_limit = propagation_node_data["per_transfer_limit"] + # ensure created_at and updated_at have Z suffix for UTC if they don't have a timezone + created_at = str(announce["created_at"]) + if created_at and "+" not in created_at and "Z" not in created_at: + created_at += "Z" + + updated_at = str(announce["updated_at"]) + if updated_at and "+" not in updated_at and "Z" not in updated_at: + updated_at += "Z" + lxmf_propagation_nodes.append( { "destination_hash": announce["destination_hash"], @@ -5065,8 +5077,8 @@ class ReticulumMeshChat: "operator_display_name": operator_display_name, "is_propagation_enabled": is_propagation_enabled, "per_transfer_limit": per_transfer_limit, - "created_at": announce["created_at"], - "updated_at": announce["updated_at"], + "created_at": created_at, + "updated_at": updated_at, }, ) @@ -7267,7 +7279,6 @@ class ReticulumMeshChat: if "auth_enabled" in data: value = self._parse_bool(data["auth_enabled"]) self.config.auth_enabled.set(value) - self.auth_enabled = value # if disabling auth, also remove the password hash from config if not value: @@ -7314,6 +7325,9 @@ class ReticulumMeshChat: if "banished_color" in data: self.config.banished_color.set(data["banished_color"]) + if "message_font_size" in data: + self.config.message_font_size.set(int(data["message_font_size"])) + # update desktop settings if "desktop_open_calls_in_separate_window" in data: self.config.desktop_open_calls_in_separate_window.set( @@ -8210,6 +8224,9 @@ class ReticulumMeshChat: "banished_effect_enabled": ctx.config.banished_effect_enabled.get(), "banished_text": ctx.config.banished_text.get(), "banished_color": ctx.config.banished_color.get(), + "message_font_size": ctx.config.message_font_size.get(), + "translator_enabled": ctx.config.translator_enabled.get(), + "libretranslate_url": ctx.config.libretranslate_url.get(), "desktop_open_calls_in_separate_window": ctx.config.desktop_open_calls_in_separate_window.get(), "desktop_hardware_acceleration_enabled": ctx.config.desktop_hardware_acceleration_enabled.get(), } diff --git a/meshchatx/src/backend/config_manager.py b/meshchatx/src/backend/config_manager.py index f4bac80..660336c 100644 --- a/meshchatx/src/backend/config_manager.py +++ b/meshchatx/src/backend/config_manager.py @@ -234,6 +234,7 @@ class ConfigManager: "banished_color", "#dc2626", ) + self.message_font_size = self.IntConfig(self, "message_font_size", 14) def get(self, key: str, default_value=None) -> str | None: return self.db.config.get(key, default_value) diff --git a/meshchatx/src/backend/database/announces.py b/meshchatx/src/backend/database/announces.py index 4a86001..080a1bc 100644 --- a/meshchatx/src/backend/database/announces.py +++ b/meshchatx/src/backend/database/announces.py @@ -58,6 +58,8 @@ class AnnounceDAO: self, aspect=None, search_term=None, + identity_hash=None, + destination_hash=None, limit=None, offset=0, ): @@ -66,6 +68,12 @@ class AnnounceDAO: if aspect: query += " AND aspect = ?" params.append(aspect) + if identity_hash: + query += " AND identity_hash = ?" + params.append(identity_hash) + if destination_hash: + query += " AND destination_hash = ?" + params.append(destination_hash) if search_term: query += " AND (destination_hash LIKE ? OR identity_hash LIKE ?)" like_term = f"%{search_term}%" diff --git a/meshchatx/src/backend/markdown_renderer.py b/meshchatx/src/backend/markdown_renderer.py index a1c90c3..3ae1ec2 100644 --- a/meshchatx/src/backend/markdown_renderer.py +++ b/meshchatx/src/backend/markdown_renderer.py @@ -24,7 +24,7 @@ class MarkdownRenderer: code = match.group(2) placeholder = f"[[CB{len(code_blocks)}]]" code_blocks.append( - f'
{code}
' + f'
{code}
' ) return placeholder