add env variables to ignore download of attachments and stories in json-rpc mode

see #723
This commit is contained in:
Bernhard B 2025-07-19 22:13:31 +02:00
parent 4102331404
commit 8834570421
2 changed files with 18 additions and 2 deletions

View File

@ -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`)

View File

@ -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)