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
This commit is contained in:
@@ -5004,7 +5004,10 @@ class ReticulumMeshChat:
|
|||||||
|
|
||||||
# limit results
|
# limit results
|
||||||
if limit is not None:
|
if limit is not None:
|
||||||
results = results[: int(limit)]
|
try:
|
||||||
|
results = results[: int(limit)]
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
pass
|
||||||
|
|
||||||
# process announces
|
# process announces
|
||||||
lxmf_propagation_nodes = []
|
lxmf_propagation_nodes = []
|
||||||
@@ -5058,6 +5061,15 @@ class ReticulumMeshChat:
|
|||||||
is_propagation_enabled = propagation_node_data["enabled"]
|
is_propagation_enabled = propagation_node_data["enabled"]
|
||||||
per_transfer_limit = propagation_node_data["per_transfer_limit"]
|
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(
|
lxmf_propagation_nodes.append(
|
||||||
{
|
{
|
||||||
"destination_hash": announce["destination_hash"],
|
"destination_hash": announce["destination_hash"],
|
||||||
@@ -5065,8 +5077,8 @@ class ReticulumMeshChat:
|
|||||||
"operator_display_name": operator_display_name,
|
"operator_display_name": operator_display_name,
|
||||||
"is_propagation_enabled": is_propagation_enabled,
|
"is_propagation_enabled": is_propagation_enabled,
|
||||||
"per_transfer_limit": per_transfer_limit,
|
"per_transfer_limit": per_transfer_limit,
|
||||||
"created_at": announce["created_at"],
|
"created_at": created_at,
|
||||||
"updated_at": announce["updated_at"],
|
"updated_at": updated_at,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -7267,7 +7279,6 @@ class ReticulumMeshChat:
|
|||||||
if "auth_enabled" in data:
|
if "auth_enabled" in data:
|
||||||
value = self._parse_bool(data["auth_enabled"])
|
value = self._parse_bool(data["auth_enabled"])
|
||||||
self.config.auth_enabled.set(value)
|
self.config.auth_enabled.set(value)
|
||||||
self.auth_enabled = value
|
|
||||||
|
|
||||||
# if disabling auth, also remove the password hash from config
|
# if disabling auth, also remove the password hash from config
|
||||||
if not value:
|
if not value:
|
||||||
@@ -7314,6 +7325,9 @@ class ReticulumMeshChat:
|
|||||||
if "banished_color" in data:
|
if "banished_color" in data:
|
||||||
self.config.banished_color.set(data["banished_color"])
|
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
|
# update desktop settings
|
||||||
if "desktop_open_calls_in_separate_window" in data:
|
if "desktop_open_calls_in_separate_window" in data:
|
||||||
self.config.desktop_open_calls_in_separate_window.set(
|
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_effect_enabled": ctx.config.banished_effect_enabled.get(),
|
||||||
"banished_text": ctx.config.banished_text.get(),
|
"banished_text": ctx.config.banished_text.get(),
|
||||||
"banished_color": ctx.config.banished_color.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_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(),
|
"desktop_hardware_acceleration_enabled": ctx.config.desktop_hardware_acceleration_enabled.get(),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -234,6 +234,7 @@ class ConfigManager:
|
|||||||
"banished_color",
|
"banished_color",
|
||||||
"#dc2626",
|
"#dc2626",
|
||||||
)
|
)
|
||||||
|
self.message_font_size = self.IntConfig(self, "message_font_size", 14)
|
||||||
|
|
||||||
def get(self, key: str, default_value=None) -> str | None:
|
def get(self, key: str, default_value=None) -> str | None:
|
||||||
return self.db.config.get(key, default_value)
|
return self.db.config.get(key, default_value)
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ class AnnounceDAO:
|
|||||||
self,
|
self,
|
||||||
aspect=None,
|
aspect=None,
|
||||||
search_term=None,
|
search_term=None,
|
||||||
|
identity_hash=None,
|
||||||
|
destination_hash=None,
|
||||||
limit=None,
|
limit=None,
|
||||||
offset=0,
|
offset=0,
|
||||||
):
|
):
|
||||||
@@ -66,6 +68,12 @@ class AnnounceDAO:
|
|||||||
if aspect:
|
if aspect:
|
||||||
query += " AND aspect = ?"
|
query += " AND aspect = ?"
|
||||||
params.append(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:
|
if search_term:
|
||||||
query += " AND (destination_hash LIKE ? OR identity_hash LIKE ?)"
|
query += " AND (destination_hash LIKE ? OR identity_hash LIKE ?)"
|
||||||
like_term = f"%{search_term}%"
|
like_term = f"%{search_term}%"
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class MarkdownRenderer:
|
|||||||
code = match.group(2)
|
code = match.group(2)
|
||||||
placeholder = f"[[CB{len(code_blocks)}]]"
|
placeholder = f"[[CB{len(code_blocks)}]]"
|
||||||
code_blocks.append(
|
code_blocks.append(
|
||||||
f'<pre class="bg-gray-800 dark:bg-zinc-900 text-gray-100 p-4 rounded-lg my-4 overflow-x-auto border border-gray-700 dark:border-zinc-800 font-mono text-sm"><code class="language-{lang}">{code}</code></pre>'
|
f'<pre class="bg-gray-800 dark:bg-zinc-900 text-zinc-100 dark:text-zinc-100 p-4 rounded-lg my-4 overflow-x-auto border border-gray-700 dark:border-zinc-800 font-mono text-sm"><code class="language-{lang} text-inherit">{code}</code></pre>'
|
||||||
)
|
)
|
||||||
return placeholder
|
return placeholder
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user