refactor(simplex): hoist json.dumps above branch in _standalone_send

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().
This commit is contained in:
kshitij 2026-08-08 13:46:04 +05:30
parent eb048772f6
commit 0041fc6946
1 changed files with 3 additions and 6 deletions

View File

@ -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 = {