From 88345704214a5290129a9098261a4f0096cbe630 Mon Sep 17 00:00:00 2001 From: Bernhard B Date: Sat, 19 Jul 2025 22:13:31 +0200 Subject: [PATCH] add env variables to ignore download of attachments and stories in json-rpc mode see #723 --- README.md | 3 +++ src/scripts/jsonrpc2-helper.go | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1952cec..448e239 100644 --- a/README.md +++ b/README.md @@ -150,3 +150,6 @@ There are a bunch of environmental variables that can be set inside the docker c * `DEFAULT_SIGNAL_TEXT_MODE`: Allows to set the default text mode that should be used when sending a message (supported values: `normal`, `styled`). The setting is only used in case the `text_mode` is not explicitly set in the payload of the `send` method. * `LOG_LEVEL`: Allows to set the log level. Supported values: `debug`, `info`, `warn`, `error`. If nothing is specified, it defaults to `info`. + +* `JSON_RPC_IGNORE_ATTACHMENTS`: When set to `true`, attachments are not automatically downloaded in json-rpc mode (default: `false`) +* `JSON_RPC_IGNORE_STORIES`: When set to `true`, stories are not automatically downloaded in json-rpc mode (default: `false`) diff --git a/src/scripts/jsonrpc2-helper.go b/src/scripts/jsonrpc2-helper.go index 36eda4f..a05db04 100644 --- a/src/scripts/jsonrpc2-helper.go +++ b/src/scripts/jsonrpc2-helper.go @@ -13,7 +13,7 @@ import ( const supervisorctlConfigTemplate = ` [program:%s] process_name=%s -command=bash -c "nc -l -p %d <%s | signal-cli --output=json --config %s jsonRpc >%s" +command=bash -c "nc -l -p %d <%s | signal-cli --output=json --config %s jsonRpc%s%s >%s" autostart=true autorestart=true startretries=10 @@ -58,6 +58,18 @@ func main() { log.Fatal("Couldn't change permissions of fifo with name ", fifoPathname, ": ", err.Error()) } + signalCliIgnoreAttachments := "" + ignoreAttachments := utils.GetEnv("JSON_RPC_IGNORE_ATTACHMENTS", "") + if ignoreAttachments == "true" { + signalCliIgnoreAttachments = " --ignore-attachments" + } + + signalCliIgnoreStories := "" + ignoreStories := utils.GetEnv("JSON_RPC_IGNORE_STORIES", "") + if ignoreStories == "true" { + signalCliIgnoreStories = " --ignore-stories" + } + supervisorctlProgramName := "signal-cli-json-rpc-1" supervisorctlLogFolder := "/var/log/" + supervisorctlProgramName _, err = exec.Command("mkdir", "-p", supervisorctlLogFolder).Output() @@ -72,7 +84,8 @@ func main() { supervisorctlConfig := fmt.Sprintf(supervisorctlConfigTemplate, supervisorctlProgramName, supervisorctlProgramName, - tcpPort, fifoPathname, signalCliConfigDir, fifoPathname, supervisorctlProgramName, supervisorctlProgramName) + tcpPort, fifoPathname, signalCliConfigDir, signalCliIgnoreAttachments, signalCliIgnoreStories, fifoPathname, + supervisorctlProgramName, supervisorctlProgramName) err = ioutil.WriteFile(supervisorctlConfigFilename, []byte(supervisorctlConfig), 0644)