From 0041fc69467a0739ee5048661167ff01970460b3 Mon Sep 17 00:00:00 2001 From: kshitij <82637225+kshitijk4poor@users.noreply.github.com> Date: Sat, 8 Aug 2026 13:46:04 +0530 Subject: [PATCH] refactor(simplex): hoist json.dumps above branch in _standalone_send MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Deduplicate the composed JSON payload construction — both the group and DM branches build the identical json.dumps result, so hoist it above the if/else to match the pattern already used in send(). --- plugins/platforms/simplex/adapter.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/plugins/platforms/simplex/adapter.py b/plugins/platforms/simplex/adapter.py index 2f9dd4e493229..9eaa4d856e880 100644 --- a/plugins/platforms/simplex/adapter.py +++ b/plugins/platforms/simplex/adapter.py @@ -1262,16 +1262,13 @@ async def _standalone_send( return {"error": "SimpleX standalone send: SIMPLEX_WS_URL is required"} try: + composed = json.dumps( + [{"msgContent": {"type": "text", "text": message}}] + ) if chat_id.startswith("group:"): group_id = chat_id[6:] - composed = json.dumps( - [{"msgContent": {"type": "text", "text": message}}] - ) cmd_str = f"/_send #{group_id} json {composed}" else: - composed = json.dumps( - [{"msgContent": {"type": "text", "text": message}}] - ) cmd_str = f"/_send @{chat_id} json {composed}" payload = {