Skip to content

Commit 8834570

Browse files
committed
add env variables to ignore download of attachments and stories in json-rpc mode
see #723
1 parent 4102331 commit 8834570

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,6 @@ There are a bunch of environmental variables that can be set inside the docker c
150150
* `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.
151151

152152
* `LOG_LEVEL`: Allows to set the log level. Supported values: `debug`, `info`, `warn`, `error`. If nothing is specified, it defaults to `info`.
153+
154+
* `JSON_RPC_IGNORE_ATTACHMENTS`: When set to `true`, attachments are not automatically downloaded in json-rpc mode (default: `false`)
155+
* `JSON_RPC_IGNORE_STORIES`: When set to `true`, stories are not automatically downloaded in json-rpc mode (default: `false`)

src/scripts/jsonrpc2-helper.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
const supervisorctlConfigTemplate = `
1414
[program:%s]
1515
process_name=%s
16-
command=bash -c "nc -l -p %d <%s | signal-cli --output=json --config %s jsonRpc >%s"
16+
command=bash -c "nc -l -p %d <%s | signal-cli --output=json --config %s jsonRpc%s%s >%s"
1717
autostart=true
1818
autorestart=true
1919
startretries=10
@@ -58,6 +58,18 @@ func main() {
5858
log.Fatal("Couldn't change permissions of fifo with name ", fifoPathname, ": ", err.Error())
5959
}
6060

61+
signalCliIgnoreAttachments := ""
62+
ignoreAttachments := utils.GetEnv("JSON_RPC_IGNORE_ATTACHMENTS", "")
63+
if ignoreAttachments == "true" {
64+
signalCliIgnoreAttachments = " --ignore-attachments"
65+
}
66+
67+
signalCliIgnoreStories := ""
68+
ignoreStories := utils.GetEnv("JSON_RPC_IGNORE_STORIES", "")
69+
if ignoreStories == "true" {
70+
signalCliIgnoreStories = " --ignore-stories"
71+
}
72+
6173
supervisorctlProgramName := "signal-cli-json-rpc-1"
6274
supervisorctlLogFolder := "/var/log/" + supervisorctlProgramName
6375
_, err = exec.Command("mkdir", "-p", supervisorctlLogFolder).Output()
@@ -72,7 +84,8 @@ func main() {
7284

7385

7486
supervisorctlConfig := fmt.Sprintf(supervisorctlConfigTemplate, supervisorctlProgramName, supervisorctlProgramName,
75-
tcpPort, fifoPathname, signalCliConfigDir, fifoPathname, supervisorctlProgramName, supervisorctlProgramName)
87+
tcpPort, fifoPathname, signalCliConfigDir, signalCliIgnoreAttachments, signalCliIgnoreStories, fifoPathname,
88+
supervisorctlProgramName, supervisorctlProgramName)
7689

7790

7891
err = ioutil.WriteFile(supervisorctlConfigFilename, []byte(supervisorctlConfig), 0644)

0 commit comments

Comments
 (0)